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