| # 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. |
| |
| if (is_debug) { |
| # TODO(fxbug.dev/89149): consider "debug" |
| default_optimize = "none" |
| } else { |
| default_optimize = "size" |
| } |
| |
| # 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 |
| # * `default`: default optimization level |
| # * `size`: optimized for space rather than purely for speed |
| # * `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 = default_optimize |
| } |
| |
| _optimize_valid = [ |
| "none", |
| "debug", |
| "default", |
| "size", |
| "speed", |
| "sanitizer", |
| "profile", |
| "coverage", |
| ] |
| |
| assert(_optimize_valid + [ optimize ] - [ optimize ] != _optimize_valid, |
| "`optimize=\"...\"` must be one of $_optimize_valid") |
| |
| 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(fxbug.dev/26814): Use DWARF 4 for the kernel proper and physboot |
| # until the GDB used by kernel developers fully supports DWARF 5. |
| # TODO(fxbug.dev/87422): 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") |