diff --git a/crosstool/cc_toolchain_config.bzl b/crosstool/cc_toolchain_config.bzl index dbbc6bf..ce3e497 100644 --- a/crosstool/cc_toolchain_config.bzl +++ b/crosstool/cc_toolchain_config.bzl @@ -2077,7 +2077,6 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new "-g0", "-O2", "-DNDEBUG", - "-DNS_BLOCK_ASSERTIONS=1", ], ), ], @@ -2116,6 +2115,31 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new ], ) + ns_block_assertions_feature = feature( + name = "ns_block_assertions", + enabled = True, + flag_sets = [ + flag_set( + actions = [ + ACTION_NAMES.assemble, + ACTION_NAMES.preprocess_assemble, + ACTION_NAMES.linkstamp_compile, + ACTION_NAMES.c_compile, + ACTION_NAMES.cpp_compile, + ACTION_NAMES.cpp_header_parsing, + ACTION_NAMES.cpp_module_compile, + ACTION_NAMES.cpp_module_codegen, + ACTION_NAMES.lto_backend, + ACTION_NAMES.clif_match, + ACTION_NAMES.objc_compile, + ACTION_NAMES.objcpp_compile, + ], + flag_groups = [flag_group(flags = ["-DNS_BLOCK_ASSERTIONS=1"])], + with_features = [with_feature_set(features = ["opt"])], + ), + ], + ) + objcopy_embed_flags_feature = feature( name = "objcopy_embed_flags", enabled = True, @@ -2656,6 +2680,7 @@ please file an issue at https://github.com/bazelbuild/apple_support/issues/new # Features with more configuration link_libcpp_feature, default_compile_flags_feature, + ns_block_assertions_feature, debug_prefix_map_pwd_is_dot_feature, remap_xcode_path_feature, generate_dsym_file_feature, diff --git a/test/compiling_tests.bzl b/test/compiling_tests.bzl index d0f0de0..39898a7 100644 --- a/test/compiling_tests.bzl +++ b/test/compiling_tests.bzl @@ -7,6 +7,21 @@ load( default_test = make_action_command_line_test_rule() +opt_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:compilation_mode": "opt", + }, +) + +disable_ns_block_assertions_feature_test = make_action_command_line_test_rule( + config_settings = { + "//command_line_option:compilation_mode": "opt", + "//command_line_option:features": [ + "-ns_block_assertions", + ], + }, +) + def compiling_test_suite(name): """Tests for compilation behavior. @@ -26,6 +41,30 @@ def compiling_test_suite(name): target_under_test = "//test/test_data:cc_main", ) + opt_test( + name = "{}_opt_link_test".format(name), + tags = [name], + expected_argv = [ + "-DNDEBUG", + "-DNS_BLOCK_ASSERTIONS=1", + ], + mnemonic = "CppCompile", + target_under_test = "//test/test_data:cc_main", + ) + + disable_ns_block_assertions_feature_test( + name = "{}_disable_ns_block_assertions_feature_test".format(name), + tags = [name], + expected_argv = [ + "-DNDEBUG", + ], + not_expected_argv = [ + "-DNS_BLOCK_ASSERTIONS=1", + ], + mnemonic = "CppCompile", + target_under_test = "//test/test_data:cc_main", + ) + native.test_suite( name = name, tags = [name],