|
|
@@ -653,10 +653,21 @@ def _impl(ctx):
|
|
|
|
|
|
if clang_version and clang_version <= 16:
|
|
|
libcpp_debug_flags = ["-D_LIBCPP_ENABLE_ASSERTIONS=1"]
|
|
|
- else:
|
|
|
+ libcpp_release_flags = ["-D_LIBCPP_ENABLE_ASSERTIONS=0"]
|
|
|
+ elif clang_version and clang_version <= 17:
|
|
|
# Clang 17 deprecates LIBCPP_ENABLE_ASSERTIONS in favor of
|
|
|
- # HARDENED_MODE.
|
|
|
+ # HARDENED_MODE and DEBUG_MODE.
|
|
|
libcpp_debug_flags = ["-D_LIBCPP_ENABLE_HARDENED_MODE=1"]
|
|
|
+ libcpp_release_flags = ["-D_LIBCPP_ENABLE_HARDENED_MODE=1"]
|
|
|
+ else:
|
|
|
+ # Clang 18 changes HARDENED_MODE to use 4 values:
|
|
|
+ # https://releases.llvm.org/18.1.0/projects/libcxx/docs/Hardening.html#hardening-modes
|
|
|
+ libcpp_debug_flags = [
|
|
|
+ "-D_LIBCPP_ENABLE_HARDENED_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE",
|
|
|
+ ]
|
|
|
+ libcpp_release_flags = [
|
|
|
+ "-D_LIBCPP_ENABLE_HARDENED_MODE=_LIBCPP_HARDENING_MODE_FAST",
|
|
|
+ ]
|
|
|
|
|
|
linux_flags_feature = feature(
|
|
|
name = "linux_flags",
|
|
|
@@ -703,6 +714,13 @@ def _impl(ctx):
|
|
|
with_feature_set(not_features = ["opt"]),
|
|
|
],
|
|
|
),
|
|
|
+ flag_set(
|
|
|
+ actions = all_compile_actions,
|
|
|
+ flag_groups = [flag_group(flags = libcpp_release_flags)],
|
|
|
+ with_features = [
|
|
|
+ with_feature_set(features = ["opt"]),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
flag_set(
|
|
|
actions = [
|
|
|
ACTION_NAMES.cpp_link_executable,
|