Use custom libcxx by default on Linux and fix sanitizers This CL: - switches Linux to libcxx by default. - turns libcxx into a DSO for sanitizers. - fixes a bunch of sanitizers build files. - enables the sanitizers cross-checks on the CI. Background: There are mainly two C++ libraries around in the world: (i) GNU's libstdc++ and LLVM's libc++ (aka libcxx). By default Linux provides libstdc++ (even building with clang on Linux uses that by default) while Mac and Android switched to libcxx. buildtools/libcxx(abi) contains a fixed version of the libcxx, the same one that Chrome uses on most production configurations (% lagging catching up with our DEPS). The variable use_custom_libcxx tells our build system to prefer the aforementioned copy to the system one. Now, there are two reasons for using the /buildtools version of libcxx: 1) Sanitizers requires that the c++ library is built from sources, see https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo. 2) The libstdc++ situation is too wild on Linux. Modern debian distros are fine but Ubuntu Trusty still ships a libstdc++ that doesn't fully support C++11. Hence we enable this flag on Linux by default. We still retain libstdc++ coverage on the Travis bots by overriding use_custom_libcxx=false when we target a modern library (see the GCC7 target in .travis.yml). Bug: 68256752 Change-Id: I70a99351cff6582663101bf26583f20460076013
diff --git a/build/BUILDCONFIG.gn b/build/BUILDCONFIG.gn index 1551cc6..52e75b4 100644 --- a/build/BUILDCONFIG.gn +++ b/build/BUILDCONFIG.gn
@@ -19,13 +19,6 @@ declare_args() { ar = "ar" - if (is_clang) { - cc = "clang" - cxx = "clang++" - } else { - cc = "gcc" - cxx = "g++" - } } # Platform detection @@ -56,7 +49,7 @@ "//build:extra_warnings", "//build:no_exceptions", "//build:no_rtti", - "//build:runtime_library", + "//build/libc++:config", "//build/sanitizers:sanitizers_cflags", ] @@ -74,11 +67,14 @@ deps = [] } +# Realistically the only shared_library that we build right now is libc++.so +# when use_custom_libcxx=true (on Linux). Hence don't add a dependency on +# libc++ itself on these targets. set_defaults("shared_library") { configs = default_configs configs += [ "//build:shared_library" ] deps = [ - "//build:exe_and_shlib_deps", + "//build/sanitizers:deps", ] } @@ -86,7 +82,8 @@ configs = default_configs configs += [ "//build:executable" ] deps = [ - "//build:exe_and_shlib_deps", + "//build/libc++:deps", + "//build/sanitizers:deps", ] }