Skip to content

Commit

Permalink
[build] Port libc++ defines from downstream to reduce include overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
fhanau committed Nov 10, 2024
1 parent 4affda6 commit d77b0fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,13 @@ build:unix --copt="-mno-relax-all" --host_copt="-mno-relax-all"
# Limit transitive header includes within libc++. This improves compliance with IWYU, helps avoid
# errors with downstream projects that implicitly define this already and reduces total include size.
https://libcxx.llvm.org/DesignDocs/HeaderRemovalPolicy.html
build:unix --cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
build:unix --host_cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
build:unix --cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES --host_cxxopt=-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
# Do not enable libc++ ABI tags. This makes mangled symbol names and thus include overhead and code
# size slightly smaller and is safe as long as we don't link with several copies of libc++.
build:unix --cxxopt=-D_LIBCPP_NO_ABI_TAG --host_cxxopt=-D_LIBCPP_NO_ABI_TAG
# Disable the experimental (and currently incomplete) parallel STL implementation as with
# downstream, this reduces the include overhead for <algorithm>.
build:unix --cxxopt=-D_LIBCPP_HAS_NO_INCOMPLETE_PSTL --host_cxxopt=-D_LIBCPP_HAS_NO_INCOMPLETE_PSTL

# V8 redefines the _WIN32_WINNT set by bazel, disable warnings for redefined macros. Since V8 uses
# a global define for this, we need to apply it for everything.
Expand Down
2 changes: 2 additions & 0 deletions compile_flags.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
-isystembazel-bin/src/rust/cxx-integration-test/_virtual_includes/cxx-integration-test@cxx
-D_FORTIFY_SOURCE=1
-D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES
-D_LIBCPP_NO_ABI_TAG
-D_LIBCPP_HAS_NO_INCOMPLETE_PSTL
-DCAPNP_VERSION=11000
-DDEBUG
-DGOOGLE3
Expand Down

0 comments on commit d77b0fa

Please sign in to comment.