| # Copyright 2020 The Pigweed Authors |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| # use this file except in compliance with the License. You may obtain a copy of |
| # the License at |
| # |
| # https://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| # License for the specific language governing permissions and limitations under |
| # the License. |
| |
| import("//build_overrides/pigweed.gni") |
| |
| # See https://github.com/google/sanitizers |
| config("sanitize_address") { |
| cflags = [ "-fsanitize=address" ] |
| ldflags = cflags |
| } |
| |
| config("sanitize_memory") { |
| cflags = [ "-fsanitize=memory" ] |
| ldflags = cflags |
| } |
| |
| config("sanitize_undefined") { |
| cflags = [ "-fsanitize=undefined" ] |
| ldflags = cflags |
| } |
| |
| config("sanitize_coverage") { |
| cflags = [ |
| "-fprofile-instr-generate", |
| "-fcoverage-mapping", |
| ] |
| ldflags = cflags |
| } |
| |
| # Locate XCode's sysroot for Clang. |
| config("xcode_sysroot") { |
| if (current_os == "mac") { |
| _xcode_sysroot = exec_script("$dir_pw_build/py/pw_build/exec.py", |
| [ |
| "--", |
| "/usr/bin/xcrun", |
| "--show-sdk-path", |
| ], |
| "trim string") |
| cflags = [ "--sysroot=$_xcode_sysroot" ] |
| ldflags = cflags |
| } |
| } |
| |
| # The CIPD provided Clang/LLVM toolchain must link against the matched |
| # libc++ which is also from CIPD. However, by default, Clang on Mac (but |
| # not on Linux) will fall back to the system libc++, which is |
| # incompatible due to an ABI change. |
| # |
| # Pull the appropriate pathd from our Pigweed env setup. |
| config("no_system_libcpp") { |
| if (current_os == "mac") { |
| install_dir = getenv("PW_PIGWEED_CIPD_INSTALL_DIR") |
| assert(install_dir != "", |
| "You forgot to activate the Pigweed environment; " + |
| "did you source pw_env_setup/setup.sh?") |
| ldflags = [ |
| # Force dropping the system libc++ |
| "-nostdlib++", |
| |
| # Use the libc++ from CIPD. |
| getenv("PW_PIGWEED_CIPD_INSTALL_DIR") + "/lib/libc++.a", |
| ] |
| } |
| } |