diff --git a/cc/cc_library.bzl b/cc/cc_library.bzl index c45c5fd954..2e3a01f12a 100644 --- a/cc/cc_library.bzl +++ b/cc/cc_library.bzl @@ -15,5 +15,39 @@ load("@cc_compatibility_proxy//:proxy.bzl", _cc_library = "cc_library") +_RUSTY_V8_CUSTOM_LIBCXX_COPTS = select({ + "@@//third_party/v8:use_rusty_v8_custom_libcxx": [ + "-nostdinc++", + "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", + "-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE", + "-D_LIBCPP_INSTRUMENTED_WITH_ASAN=0", + "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS", + ], + "//conditions:default": [], +}) + +_RUSTY_V8_CUSTOM_LIBCXX_DEPS = select({ + "@@//third_party/v8:use_rusty_v8_custom_libcxx": [ + "@@//third_party/v8:rusty_v8_custom_libcxx_headers", + ], + "//conditions:default": [], +}) + +_RUSTY_V8_CUSTOM_LIBCXX_REPOS = [ + # V8 and ICU are patched in-tree. These external C++ dependencies still + # build inside the artifact closure once the LLVM toolchain's default + # libc++ headers are suppressed. + "@abseil-cpp+", + "@v8++http_archive+highway", + "@v8++http_archive+simdutf", +] + +def _should_use_rusty_v8_custom_libcxx(): + return native.repository_name() in _RUSTY_V8_CUSTOM_LIBCXX_REPOS + def cc_library(**kwargs): + if _should_use_rusty_v8_custom_libcxx(): + kwargs["copts"] = (kwargs.get("copts", []) or []) + _RUSTY_V8_CUSTOM_LIBCXX_COPTS + kwargs["deps"] = (kwargs.get("deps", []) or []) + _RUSTY_V8_CUSTOM_LIBCXX_DEPS + kwargs["features"] = (kwargs.get("features", []) or []) + ["-module_maps"] _cc_library(**kwargs)