1 # Copyright (C) 2017 The Android Open Source Project 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 import("//gn/standalone/sanitizers/sanitizers.gni") 16 17 declare_args() { 18 # Background: 19 # there are mainly two C++ libraries around in the world: (i) GNU's 20 # libstdc++ and LLVM's libc++ (aka libcxx). By default Linux provides libstdc++ 21 # (even building with clang on Linux uses that by default) while Mac and 22 # Android switched to libcxx. 23 # buildtools/libcxx(abi) contains a fixed version of the libcxx, the same one 24 # that Chrome uses on most production configurations (% lagging catching up 25 # with our DEPS). 26 # The variable use_custom_libcxx tells our build system to prefer the 27 # aforementioned copy to the system one. 28 # 29 # Now, there are two reasons for using the checked in copy of libcxx: 30 # 1) LLVM sanitizers require that the c++ library is built from sources, 31 # because they need to be instrumented with -fsanitize as well (see 32 # https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo). 33 # On top of this, they also require that the c++ library is dynamically 34 # linked to prevent duplicate symbol errors when linking (see Chrome's 35 # build/config/c++/c++.gni) 36 # 2) The libstdc++ situation is too wild on Linux. Modern debian distros are 37 # fine but Ubuntu Trusty still ships a libstdc++ that doesn't fully 38 # support C++11. Hence we enable this flag on Linux by default. 39 # We still retain libstdc++ coverage on the Travis bots by overriding 40 # use_custom_libcxx=false when we target a modern library (see the 41 # GCC7 target in .travis.yml). 42 use_custom_libcxx = is_linux && is_clang 43 custom_libcxx_is_static = !using_sanitizer 44 } 45 46 libcxx_prefix = "//buildtools/libcxx" 47 libcxxabi_prefix = "//buildtools/libcxxabi" 48