diff --git a/rs_bindings_from_cc/BUILD b/rs_bindings_from_cc/BUILD index 439360f6f..0934168bb 100644 --- a/rs_bindings_from_cc/BUILD +++ b/rs_bindings_from_cc/BUILD @@ -43,6 +43,10 @@ _PROFILING_RUSTC_FLAGS = select({ "//conditions:default": [], }) +# Undefine NDEBUG to ensure assertions (including inlined Clang AST assertions) +# remain active even in opt compilation mode (see b/541930690). +_CRUBIT_COPTS = ["-UNDEBUG"] + rust_bindings_from_cc_binary( name = "rs_bindings_from_cc", binary = ":rs_bindings_from_cc_main", @@ -93,6 +97,7 @@ crubit_rust_binary( cc_library( name = "rs_bindings_from_cc_impl", srcs = ["rs_bindings_from_cc.cc"], + copts = _CRUBIT_COPTS, # Defines CRUBIT_HEAP_PROFILING when --define=enable_heap_profiling=1 is passed, # enabling heap profile recording in rs_bindings_from_cc.cc. defines = select({ @@ -123,6 +128,7 @@ cc_library( name = "generate_bindings_and_metadata", srcs = ["generate_bindings_and_metadata.cc"], hdrs = ["generate_bindings_and_metadata.h"], + copts = _CRUBIT_COPTS, visibility = [ "//cargo:__subpackages__", ], @@ -181,6 +187,7 @@ cc_library( name = "ast_util", srcs = ["ast_util.cc"], hdrs = ["ast_util.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ ":cc_ir", @@ -224,6 +231,7 @@ cc_library( name = "type_map", srcs = ["type_map.cc"], hdrs = ["type_map.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ ":cc_ir", @@ -237,6 +245,7 @@ cc_library( name = "annotations_consumer", srcs = ["annotations_consumer.cc"], hdrs = ["annotations_consumer.h"], + copts = _CRUBIT_COPTS, deps = [ ":cc_ir", "//common:annotation_reader", @@ -252,6 +261,7 @@ cc_library( name = "cmdline", srcs = ["cmdline.cc"], hdrs = ["cmdline.h"], + copts = _CRUBIT_COPTS, visibility = [ "//cargo:__subpackages__", ], @@ -277,6 +287,7 @@ cc_library( cc_library( name = "cmdline_flags", hdrs = ["cmdline_flags.h"], + copts = _CRUBIT_COPTS, deps = [ "@abseil-cpp//absl/flags:flag", "@abseil-cpp//absl/strings:string_view", @@ -305,6 +316,7 @@ crubit_cc_test( cc_library( name = "decl_importer", hdrs = ["decl_importer.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ "cc_ir", @@ -332,6 +344,7 @@ cc_library( name = "frontend_action", srcs = ["frontend_action.cc"], hdrs = ["frontend_action.h"], + copts = _CRUBIT_COPTS, deps = [ ":ast_consumer", ":decl_importer", @@ -346,6 +359,7 @@ cc_library( name = "ast_consumer", srcs = ["ast_consumer.cc"], hdrs = ["ast_consumer.h"], + copts = _CRUBIT_COPTS, deps = [ ":decl_importer", ":importer", @@ -359,6 +373,7 @@ cc_library( name = "importer", srcs = ["importer.cc"], hdrs = ["importer.h"], + copts = _CRUBIT_COPTS, deps = [ ":annotations_consumer", ":ast_util", @@ -444,6 +459,7 @@ cc_library( name = "cc_ir", srcs = ["ir.cc"], hdrs = ["ir.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ ":bazel_types", @@ -539,6 +555,7 @@ cc_library( name = "ir_from_cc", srcs = ["ir_from_cc.cc"], hdrs = ["ir_from_cc.h"], + copts = _CRUBIT_COPTS, deps = [ ":bazel_types", ":cc_ir", @@ -568,6 +585,7 @@ cc_library( testonly = 1, srcs = ["ir_from_cc_dependency.cc"], hdrs = ["ir_from_cc_dependency.h"], + copts = _CRUBIT_COPTS, deps = [ ":bazel_types", ":cc_ir", @@ -584,6 +602,7 @@ cc_library( name = "proto_from_cc", testonly = 1, srcs = ["proto_from_cc.cc"], + copts = _CRUBIT_COPTS, deps = [ ":cc_ir", ":cmdline_flags", @@ -623,6 +642,7 @@ cc_library( "src_code_gen_ffi_serialized_proto.cc", ], hdrs = ["src_code_gen_ffi.h"], + copts = _CRUBIT_COPTS, deps = [ ":profiling", "//common:cc_ffi_types", @@ -650,6 +670,7 @@ cc_library( name = "src_code_gen", srcs = ["src_code_gen.cc"], hdrs = ["src_code_gen.h"], + copts = _CRUBIT_COPTS, deps = [ ":cc_ir", ":profiling", @@ -667,6 +688,7 @@ cc_library( name = "ast_convert", srcs = ["ast_convert.cc"], hdrs = ["ast_convert.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ ":ast_util", @@ -686,6 +708,7 @@ cc_library( name = "recording_diagnostic_consumer", srcs = ["recording_diagnostic_consumer.cc"], hdrs = ["recording_diagnostic_consumer.h"], + copts = _CRUBIT_COPTS, visibility = [ "//:__subpackages__", ], @@ -746,6 +769,7 @@ cc_library( name = "cc_collect_instantiations", srcs = ["collect_instantiations.cc"], hdrs = ["collect_instantiations.h"], + copts = _CRUBIT_COPTS, deps = [ ":collect_instantiations", # build_cleaner: keep "//common:cc_ffi_types", @@ -797,6 +821,7 @@ cc_library( name = "collect_namespaces", srcs = ["collect_namespaces.cc"], hdrs = ["collect_namespaces.h"], + copts = _CRUBIT_COPTS, visibility = ["//:__subpackages__"], deps = [ ":bazel_types", diff --git a/rs_bindings_from_cc/importers/BUILD b/rs_bindings_from_cc/importers/BUILD index 8689cc2e0..63fb15dac 100644 --- a/rs_bindings_from_cc/importers/BUILD +++ b/rs_bindings_from_cc/importers/BUILD @@ -8,10 +8,15 @@ package( default_visibility = ["//:__subpackages__"], ) +# Undefine NDEBUG to ensure assertions (including inlined Clang AST assertions) +# remain active even in opt compilation mode (see b/541930690). +_CRUBIT_COPTS = ["-UNDEBUG"] + cc_library( name = "class_template", srcs = ["class_template.cc"], hdrs = ["class_template.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:cc_ir", "//rs_bindings_from_cc:decl_importer", @@ -23,6 +28,7 @@ cc_library( name = "cxx_record", srcs = ["cxx_record.cc"], hdrs = ["cxx_record.h"], + copts = _CRUBIT_COPTS, deps = [ "//common:annotation_reader", "//common:status_macros", @@ -53,6 +59,7 @@ cc_library( name = "enum", srcs = ["enum.cc"], hdrs = ["enum.h"], + copts = _CRUBIT_COPTS, deps = [ "//lifetime_annotations:type_lifetimes", "//rs_bindings_from_cc:ast_util", @@ -70,6 +77,7 @@ cc_library( name = "enum_constant", srcs = ["enum_constant.cc"], hdrs = ["enum_constant.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:ast_util", "//rs_bindings_from_cc:cc_ir", @@ -85,6 +93,7 @@ cc_library( name = "var", srcs = ["var.cc"], hdrs = ["var.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:ast_util", "//rs_bindings_from_cc:cc_ir", @@ -100,6 +109,7 @@ cc_library( name = "friend", srcs = ["friend.cc"], hdrs = ["friend.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:cc_ir", "//rs_bindings_from_cc:decl_importer", @@ -113,6 +123,7 @@ cc_library( name = "function", srcs = ["function.cc"], hdrs = ["function.h"], + copts = _CRUBIT_COPTS, deps = [ "//common:annotation_reader", "//lifetime_annotations", @@ -143,6 +154,7 @@ cc_library( name = "function_template", srcs = ["function_template.cc"], hdrs = ["function_template.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:cc_ir", "//rs_bindings_from_cc:decl_importer", @@ -155,6 +167,7 @@ cc_library( name = "namespace", srcs = ["namespace.cc"], hdrs = ["namespace.h"], + copts = _CRUBIT_COPTS, deps = [ "//rs_bindings_from_cc:ast_util", "//rs_bindings_from_cc:cc_ir", @@ -168,6 +181,7 @@ cc_library( name = "type_alias", srcs = ["type_alias.cc"], hdrs = ["type_alias.h"], + copts = _CRUBIT_COPTS, deps = [ "//lifetime_annotations:type_lifetimes", "//rs_bindings_from_cc:ast_util", @@ -187,6 +201,7 @@ cc_library( name = "existing_rust_type", srcs = ["existing_rust_type.cc"], hdrs = ["existing_rust_type.h"], + copts = _CRUBIT_COPTS, deps = [ "//common:annotation_reader", "//common:status_macros",