1# Copyright 2020 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://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, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15import("//build_overrides/pigweed.gni") 16 17# See https://github.com/google/sanitizers 18config("sanitize_address") { 19 cflags = [ "-fsanitize=address" ] 20 ldflags = cflags 21} 22 23config("sanitize_memory") { 24 cflags = [ "-fsanitize=memory" ] 25 ldflags = cflags 26} 27 28config("sanitize_undefined") { 29 cflags = [ "-fsanitize=undefined" ] 30 ldflags = cflags 31} 32 33config("sanitize_coverage") { 34 cflags = [ 35 "-fprofile-instr-generate", 36 "-fcoverage-mapping", 37 ] 38 ldflags = cflags 39} 40 41# Locate XCode's sysroot for Clang. 42config("xcode_sysroot") { 43 if (current_os == "mac") { 44 _xcode_sysroot = exec_script("$dir_pw_build/py/pw_build/exec.py", 45 [ 46 "--", 47 "/usr/bin/xcrun", 48 "--show-sdk-path", 49 ], 50 "trim string") 51 cflags = [ "--sysroot=$_xcode_sysroot" ] 52 ldflags = cflags 53 } 54} 55 56# The CIPD provided Clang/LLVM toolchain must link against the matched 57# libc++ which is also from CIPD. However, by default, Clang on Mac (but 58# not on Linux) will fall back to the system libc++, which is 59# incompatible due to an ABI change. 60# 61# Pull the appropriate pathd from our Pigweed env setup. 62config("no_system_libcpp") { 63 if (current_os == "mac") { 64 install_dir = getenv("PW_PIGWEED_CIPD_INSTALL_DIR") 65 assert(install_dir != "", 66 "You forgot to activate the Pigweed environment; " + 67 "did you source pw_env_setup/setup.sh?") 68 ldflags = [ 69 # Force dropping the system libc++ 70 "-nostdlib++", 71 72 # Use the libc++ from CIPD. 73 getenv("PW_PIGWEED_CIPD_INSTALL_DIR") + "/lib/libc++.a", 74 ] 75 } 76} 77