| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/compilation_modes.gni") |
| |
| # NOTE: Keep in sync with //build/config/zircon/levels.gni |
| declare_args() { |
| # * `none`: really unoptimized, usually only build-tested and not run |
| # * `debug`: "optimized for debugging", light enough to avoid confusion |
| # * `moderate`: moderate optimization level (clang's default -O2) |
| # * `size`: optimized for space rather than purely for speed |
| # * `size_lto`: optimize for space and use LTO |
| # * `speed`: optimized purely for speed |
| # * `sanitizer`: optimized for sanitizers (ASan, etc.) |
| # * `profile`: optimized for coverage/profile data collection |
| # * `coverage`: optimized for coverage data collection |
| optimize = compilation_settings.optimize |
| } |
| |
| _optimize_valid = [ |
| "none", |
| "debug", |
| "minimal", |
| "moderate", |
| "size", |
| "size_lto", |
| "speed", |
| "sanitizer", |
| "profile", |
| "coverage", |
| ] |
| |
| assert( |
| optimize != "default", |
| "optimize = \"default\" has been renamed to \"moderate\", please update your build args.") |
| |
| assert( |
| _optimize_valid + [ optimize ] - [ optimize ] != _optimize_valid, |
| "`optimize=\"...\"` must be one of $_optimize_valid (\"$optimize\" was specified)") |
| |
| declare_args() { |
| # Controls whether to use -Oz when `optimize` is set to `"size"`. |
| use_oz = false |
| } |
| |
| if (use_oz) { |
| assert(optimize == "size", "clang_use_oz requires `optimize = \"size\"`") |
| } |
| |
| declare_args() { |
| # * `none` means no debugging information |
| # * `backtrace` means sufficient debugging information to symbolize backtraces |
| # * `debug` means debugging information suited for debugging |
| debuginfo = "debug" |
| } |
| |
| _debuginfo_valid = [ |
| "none", |
| "backtrace", |
| "debug", |
| ] |
| |
| assert(_debuginfo_valid + [ debuginfo ] - [ debuginfo ] != _debuginfo_valid, |
| "`debuginfo=\"...\"` must be one of $_debuginfo_valid") |
| |
| declare_args() { |
| # Explicitly specify DWARF version used. |
| dwarf_version = 5 |
| |
| # TODO(https://fxbug.dev/42101274): Use DWARF 4 for the kernel proper and physboot |
| # until the GDB used by kernel developers fully supports DWARF 5. |
| # TODO(https://fxbug.dev/42168542): Use DWARF 4 on macOS to avoid the warning reported |
| # by lld. This matches the default DWARF version currently used by Clang: |
| # https://github.com/llvm/llvm-project/blob/89c94c2/clang/lib/Driver/ToolChains/Darwin.cpp#L1159 |
| if (is_kernel || is_mac) { |
| dwarf_version = 4 |
| } |
| } |
| |
| assert(dwarf_version >= 2 && dwarf_version <= 5, |
| "`dwarf_version=\"...\"` must be between 2 and 5") |
| |
| if (is_gcc) { |
| # TODO(https://fxbug.dev/42076979): GCC doesn't yet support zstd. |
| default_compress_debuginfo = "zlib" |
| } else { |
| default_compress_debuginfo = "zstd" |
| } |
| |
| declare_args() { |
| # Enable compression of debug sections. |
| compress_debuginfo = default_compress_debuginfo |
| } |
| |
| _compress_debuginfo_valid = [ |
| "none", |
| "zlib", |
| "zstd", |
| ] |
| |
| assert(_compress_debuginfo_valid + [ compress_debuginfo ] - |
| [ compress_debuginfo ] != _compress_debuginfo_valid, |
| "`compress_debuginfo=\"...\"` must be one of $_compress_debuginfo_valid") |