101 lines
3.5 KiB
Plaintext
101 lines
3.5 KiB
Plaintext
import("//build/config/c++/c++.gni")
|
|
import("//build/config/chrome_build.gni")
|
|
import("//build/config/chromeos/ui_mode.gni")
|
|
import("//build/config/compiler/compiler.gni")
|
|
import("//build/config/dcheck_always_on.gni")
|
|
import("//buildtools/deps_revisions.gni")
|
|
|
|
assert(use_custom_libcxx, "should only be used if use_custom_libcxx is set")
|
|
|
|
# This is included by reference in the //build/config/compiler:runtime_library
|
|
# config that is applied to all targets. It is here to separate out the logic
|
|
# that is specific to libc++. Please see that target for advice on what should
|
|
# go in :runtime_library vs. :compiler.
|
|
config("runtime_library") {
|
|
cflags = []
|
|
cflags_cc = []
|
|
defines = []
|
|
include_dirs = []
|
|
ldflags = []
|
|
libs = []
|
|
|
|
# Fixed libc++ configuration macros are in
|
|
# buildtools/third_party/libc++/__config_site. This config only has defines
|
|
# that vary depending on gn args, and non-define flags.
|
|
|
|
if (!libcxx_is_shared) {
|
|
# Don't leak any symbols on a static build.
|
|
defines += [ "_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS" ]
|
|
if (!export_libcxxabi_from_executables && !is_win) {
|
|
defines += [ "_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS" ]
|
|
}
|
|
}
|
|
|
|
include_dirs += [ "//buildtools/third_party/libc++" ]
|
|
|
|
# libc++ has two levels of additional checking:
|
|
# 1. _LIBCPP_ENABLE_ASSERTIONS enables assertions for bounds checking.
|
|
# We always enable this in __config_site, in all build configurations.
|
|
# 2. _LIBCPP_ENABLE_DEBUG_MODE enables iterator debugging and other
|
|
# expensive checks. Enable these only if enable_iterator_debugging is on.
|
|
if (enable_iterator_debugging) {
|
|
defines += [ "_LIBCPP_ENABLE_DEBUG_MODE" ]
|
|
}
|
|
|
|
defines += [ "CR_LIBCXX_REVISION=$libcxx_revision" ]
|
|
|
|
if (is_win) {
|
|
# Intentionally not using libc++abi on Windows because libc++abi only
|
|
# implements the Itanium C++ ABI, and not the Microsoft ABI which we use on
|
|
# Windows (and we need to use in order to interoperate correctly with COM
|
|
# among other things).
|
|
assert(!export_libcxxabi_from_executables,
|
|
"Don't use libcxxabi on Windows.")
|
|
|
|
cflags_cc +=
|
|
[ "-I" + rebase_path("$libcxx_prefix/include", root_build_dir) ]
|
|
|
|
# Add a debug visualizer for Microsoft's debuggers so that they can display
|
|
# libc++ types well.
|
|
if (libcxx_natvis_include) {
|
|
# chrome.natvis listed as an input in //buildtools/third_party/libc++ to
|
|
# guarantee relinking on changes.
|
|
ldflags += [ "/NATVIS:" + rebase_path("libc++.natvis", root_build_dir) ]
|
|
}
|
|
} else {
|
|
cflags_cc += [
|
|
"-nostdinc++",
|
|
"-isystem" + rebase_path("$libcxx_prefix/include", root_build_dir),
|
|
"-isystem" + rebase_path("$libcxxabi_prefix/include", root_build_dir),
|
|
]
|
|
|
|
cflags_objcc = cflags_cc
|
|
|
|
# Make sure we don't link against the system libstdc++ or libc++.
|
|
if (is_clang) {
|
|
ldflags += [ "-nostdlib++" ]
|
|
} else {
|
|
# Gcc has a built-in abs() definition with default visibility.
|
|
# If it was not disabled, it would conflict with libc++'s abs()
|
|
# with hidden visibility.
|
|
cflags += [ "-fno-builtin-abs" ]
|
|
|
|
ldflags += [ "-nodefaultlibs" ]
|
|
|
|
# Unfortunately, there's no way to disable linking against just libc++
|
|
# (gcc doesn't have -notstdlib++:
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83931); -nodefaultlibs
|
|
# removes all of the default libraries, so add back the ones that we need.
|
|
libs += [
|
|
"c",
|
|
"gcc_s",
|
|
"m",
|
|
"rt",
|
|
]
|
|
}
|
|
}
|
|
if (use_custom_libcxx && enable_safe_libcxx) {
|
|
defines += [ "_LIBCPP_ENABLE_ASSERTIONS=1" ]
|
|
}
|
|
}
|