| # Copyright 2016 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. |
| |
| config("compiler") { |
| asmflags = [] |
| cflags = [] |
| cflags_c = [] |
| cflags_cc = [ "-fvisibility-inlines-hidden" ] |
| cflags_objc = [] |
| cflags_objcc = [ "-fvisibility-inlines-hidden" ] |
| ldflags = [] |
| defines = [] |
| configs = [] |
| |
| if (is_debug) { |
| cflags += [ "-g" ] |
| } |
| |
| if (current_os == "fuchsia") { |
| configs += [ "//build/config/fuchsia:compiler" ] |
| } else { |
| cflags_c += [ "-std=c11" ] |
| cflags_cc += [ |
| "-std=c++14", |
| "-stdlib=libc++", |
| ] |
| if (current_os == "linux") { |
| # On linux, we want to statically link against our libc++.a and |
| # libc++abi.a which are shipped as part of the toolchain |
| ldflags += [ |
| "-stdlib=libc++", |
| "-static-libstdc++", |
| |
| # libc++ and libc++abi are separate in our current toolchain, |
| # so we have to explicitly statically link it |
| "-Wl,-Bstatic", |
| "-lc++abi", |
| "-Wl,-Bdynamic", |
| |
| # Set rpath to find dynamically linked libraries placed next to executables in the host |
| # build directory. |
| "-Wl,-rpath=\$ORIGIN/", |
| ] |
| } |
| } |
| |
| asmflags += cflags |
| asmflags += cflags_c |
| } |
| |
| config("debug_prefix_map") { |
| # Make the debugging information independent of the absolute file path. |
| absolute_path = rebase_path("//.") |
| cflags = [ "-fdebug-prefix-map=$absolute_path=." ] |
| } |
| |
| config("debug") { |
| cflags = [ |
| "-g", |
| "-O0", |
| ] |
| } |
| |
| config("release") { |
| cflags = [ "-O2" ] |
| defines = [ "NDEBUG=1" ] |
| } |
| |
| config("no_exceptions") { |
| cflags_cc = [ "-fno-exceptions" ] |
| cflags_objcc = cflags_cc |
| } |
| |
| config("no_rtti") { |
| cflags_cc = [ "-fno-rtti" ] |
| cflags_objcc = cflags_cc |
| } |
| |
| config("default_include_dirs") { |
| include_dirs = [ |
| "//", |
| root_gen_dir, |
| ] |
| if (!is_fuchsia) { |
| if (current_cpu == "x64") { |
| include_dirs += [ "//out/magenta-host-x86_64/include" ] |
| } else if (current_cpu == "arm64") { |
| include_dirs += [ "//out/magenta-host-aarch64/include" ] |
| } else { |
| assert(false, |
| "unable to determine path to host copies of magenta includes") |
| } |
| } |
| } |
| |
| config("default_warnings") { |
| cflags = [ |
| "-Wall", |
| "-Wextra", |
| "-Wno-unused-parameter", |
| ] |
| if (current_os == "fuchsia") { |
| cflags += [ |
| # TODO(TO-99): Remove once all the cases of unused 'this' lamda capture |
| # have been removed from our codebase. |
| "-Wno-unused-lambda-capture", |
| |
| # TODO(TO-100): Remove once comparator types provide const call operator. |
| "-Wno-user-defined-warnings", |
| ] |
| } |
| } |
| |
| config("symbol_visibility_hidden") { |
| cflags = [ "-fvisibility=hidden" ] |
| } |
| |
| config("shared_library_config") { |
| configs = [] |
| cflags = [] |
| |
| if (current_os == "fuchsia") { |
| configs += [ "//build/config/fuchsia:shared_library_config" ] |
| } else if (current_os == "linux") { |
| cflags += [ "-fPIC" ] |
| } |
| } |
| |
| config("executable_config") { |
| configs = [] |
| |
| if (current_os == "fuchsia") { |
| configs += [ |
| "//build/config/fuchsia:executable_config", |
| "//build/config/fuchsia:mxio_config", |
| ] |
| } |
| } |