diff --git a/bazel/config/generate_config_header.bzl b/bazel/config/generate_config_header.bzl index 188655d93a5..6cc865bcbe4 100644 --- a/bazel/config/generate_config_header.bzl +++ b/bazel/config/generate_config_header.bzl @@ -24,6 +24,18 @@ def generate_config_header_impl(ctx): action_name = ACTION_NAMES.cpp_compile, variables = compile_variables, ) + + # The config header generation should not fail due to compiler warnings, + # so remove any flags that would treat warnings as errors. + compiler_flags = [ + flag + for flag in compiler_flags + if not ( + flag == "-Werror" or + flag.startswith("-Werror") or + flag == "/WX" + ) + ] link_flags = cc_common.get_memory_inefficient_command_line( feature_configuration = feature_configuration, action_name = ACTION_NAMES.cpp_link_executable, diff --git a/bazel/toolchains/cc/mongo_custom_features.bzl b/bazel/toolchains/cc/mongo_custom_features.bzl index 31c64f9c6b7..6589b47c0ae 100644 --- a/bazel/toolchains/cc/mongo_custom_features.bzl +++ b/bazel/toolchains/cc/mongo_custom_features.bzl @@ -425,7 +425,7 @@ def get_common_features(ctx): ), feature( name = "warnings_as_errors_compile", - enabled = False, + enabled = ctx.attr.warnings_as_errors_enabled, flag_sets = [ flag_set( actions = all_compile_actions,