diff --git a/.bazelrc b/.bazelrc index 1c528288726..fe9681a8c2c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -323,7 +323,7 @@ common:opt --//bazel/config:dbg=False common:opt --//bazel/config:dbg_level=2 common:opt --//bazel/config:debug_symbols=True common:opt --//bazel/config:separate_debug=False -common:opt --//bazel/config:compiler_type=gcc +common:opt --//bazel/config:compiler_type=clang common:opt --//bazel/config:linker=auto common:opt --//bazel/config:linkstatic=True common:opt --//bazel/config:build_enterprise=True @@ -345,7 +345,6 @@ common:opt_profiled --//bazel/config:separate_debug=True common:opt_profiled --//bazel/config:compiler_type=clang common:opt_profiled --//bazel/config:dtlto=True common:opt_profiled --//bazel/config:pgo_profile_use=True -common:opt_profiled --//bazel/config:bolt_profile_use=True common:opt_profiled --enable_platform_specific_config=true --config=evg diff --git a/bazel/config/BUILD.bazel b/bazel/config/BUILD.bazel index e72397f354e..f63c4fc0651 100644 --- a/bazel/config/BUILD.bazel +++ b/bazel/config/BUILD.bazel @@ -2305,11 +2305,13 @@ config_setting( ) selects.config_setting_group( - name = "dtlto_linux_clang_enabled_fission_disabled", + name = "dtlto_linux_clang_enabled_fission_disabled_linkstatic_enabled", match_all = [ ":linux_clang", + ":linkstatic_enabled", ":dtlto_enabled", ":fission_disabled", + ":not_s390x_or_ppc", ], ) @@ -2392,17 +2394,21 @@ config_setting( ) selects.config_setting_group( - name = "pgo_profile_use_clang_enabled", + name = "pgo_profile_use_clang_enabled_linkstatic_enabled", match_all = [ ":linux_clang", + ":linkstatic_enabled", + ":not_s390x_or_ppc", ":pgo_profile_use_enabled", ], ) selects.config_setting_group( - name = "pgo_profile_use_gcc_enabled", + name = "pgo_profile_use_gcc_enabled_linkstatic_enabled", match_all = [ ":linux_gcc", + ":linkstatic_enabled", + ":not_s390x_or_ppc", ":pgo_profile_use_enabled", ], ) diff --git a/bazel/toolchains/cc/mongo_linux/mongo_linux_cc_toolchain_config.bzl b/bazel/toolchains/cc/mongo_linux/mongo_linux_cc_toolchain_config.bzl index c20c385e442..6618068f35b 100644 --- a/bazel/toolchains/cc/mongo_linux/mongo_linux_cc_toolchain_config.bzl +++ b/bazel/toolchains/cc/mongo_linux/mongo_linux_cc_toolchain_config.bzl @@ -1108,6 +1108,21 @@ def _impl(ctx): ], ) + clang_toolchain_resource_dir_feature = feature( + name = "clang_toolchain_resource_dir", + enabled = ctx.attr.compiler == COMPILERS.CLANG, + flag_sets = [ + flag_set( + actions = all_link_actions + lto_index_actions, + flag_groups = [ + flag_group( + flags = ["-resource-dir=" + CLANG_RESOURCE_DIR], + ), + ], + ), + ], + ) + # Some of the linux versions are missing libatomic.so.1 - this is a hack so mold will use the one contained # within the mongo toolchain rather than needing one installed on the machine mold_shared_libraries_feature = feature( @@ -1154,14 +1169,6 @@ def _impl(ctx): ), ], ), - flag_set( - actions = all_link_actions + lto_index_actions, - flag_groups = [ - flag_group( - flags = ["-resource-dir=" + CLANG_RESOURCE_DIR] if ctx.attr.compiler == COMPILERS.CLANG else [""], - ), - ], - ), ], ) @@ -1424,6 +1431,7 @@ def _impl(ctx): debug_types_section_feature, no_debug_types_section_feature, strip_debug_feature, + clang_toolchain_resource_dir_feature, ] + get_common_features(ctx) return [ diff --git a/bazel/toolchains/cc/mongo_linux/mongo_toolchain.BUILD.tmpl b/bazel/toolchains/cc/mongo_linux/mongo_toolchain.BUILD.tmpl index 42b594518e5..2f64732e77f 100644 --- a/bazel/toolchains/cc/mongo_linux/mongo_toolchain.BUILD.tmpl +++ b/bazel/toolchains/cc/mongo_linux/mongo_toolchain.BUILD.tmpl @@ -98,8 +98,8 @@ PGO_PROFILE_GENERATE_ENABLED = select({ }) PGO_PROFILE_USE_ENABLED = select({ - "@//bazel/config:pgo_profile_use_clang_enabled": "@pgo_data//:clang_pgo_files", - "@//bazel/config:pgo_profile_use_gcc_enabled": "@pgo_data//:gcc_pgo_files", + "@//bazel/config:pgo_profile_use_clang_enabled_linkstatic_enabled": "@pgo_data//:clang_pgo_files", + "@//bazel/config:pgo_profile_use_gcc_enabled_linkstatic_enabled": "@pgo_data//:gcc_pgo_files", "@//conditions:default": None, }) @@ -109,9 +109,9 @@ PROPELLER_PROFILE_GENERATE_ENABLED = select({ }) DTLTO_ENABLED = select({ - "@//bazel/config:dtlto_linux_clang_enabled_fission_disabled": True, - "@//bazel/config:dtlto_disabled": False, -}, no_match_error = "Distributed Thin LTO is only available for linux clang with fission disabled.") + "@//bazel/config:dtlto_linux_clang_enabled_fission_disabled_linkstatic_enabled": True, + "@//conditions:default": False, +}) LINK_FLAGS = ["-L" + flag for flag in COMMON_LINK_FLAGS] + LINKER_LINKFLAGS @@ -119,8 +119,8 @@ LINK_FLAGS = ["-L" + flag for flag in COMMON_LINK_FLAGS] + LINKER_LINKFLAGS filegroup( name = "all_files", srcs = glob(["**/*"]) + select({ - "@//bazel/config:pgo_profile_use_clang_enabled": ["@pgo_data//:clang_pgo_files"], - "@//bazel/config:pgo_profile_use_gcc_enabled": ["@pgo_data//:gcc_pgo_files"], + "@//bazel/config:pgo_profile_use_clang_enabled_linkstatic_enabled": ["@pgo_data//:clang_pgo_files"], + "@//bazel/config:pgo_profile_use_gcc_enabled_linkstatic_enabled": ["@pgo_data//:gcc_pgo_files"], "@//conditions:default": [], }) ) diff --git a/bazel/transitions.bzl b/bazel/transitions.bzl index fe70c480175..c679afea1ae 100644 --- a/bazel/transitions.bzl +++ b/bazel/transitions.bzl @@ -6,8 +6,10 @@ def _extensions_transition_impl(settings, attr): """ return { "//bazel/config:allocator": "system", + "//bazel/config:dtlto": False, "//bazel/config:shared_archive": True, "//bazel/config:linkstatic": True, + "//bazel/config:pgo_profile_use": False, "//bazel/config:skip_archive": True, "//bazel/config:asan": settings.get("//bazel/config:asan", False), "//bazel/config:fsan": settings.get("//bazel/config:fsan", False), @@ -22,8 +24,10 @@ extensions_transition = transition( inputs = [], outputs = [ "//bazel/config:allocator", + "//bazel/config:dtlto", "//bazel/config:shared_archive", "//bazel/config:linkstatic", + "//bazel/config:pgo_profile_use", "//bazel/config:skip_archive", "//bazel/config:asan", "//bazel/config:fsan", diff --git a/bazel/wrapper_hook/flag_sync.py b/bazel/wrapper_hook/flag_sync.py index 0ecb1765232..d44048686ce 100644 --- a/bazel/wrapper_hook/flag_sync.py +++ b/bazel/wrapper_hook/flag_sync.py @@ -15,6 +15,9 @@ ALLOW_LINES = [ "common --config=local", "--experimental_throttle_remote_action_building", "--noexperimental_throttle_remote_action_building", + "--dtlto=False", + "--pgo_profile_use=False", + "--bolt_profile_use=False", ] diff --git a/etc/evergreen_yml_components/tasks/compile_tasks_shared.yml b/etc/evergreen_yml_components/tasks/compile_tasks_shared.yml index 381e3642a36..9a80ee2d9bf 100644 --- a/etc/evergreen_yml_components/tasks/compile_tasks_shared.yml +++ b/etc/evergreen_yml_components/tasks/compile_tasks_shared.yml @@ -127,6 +127,7 @@ tasks: ${additional_compile_targets|} bazel_args: >- --config=evg + --config=opt_profiled - func: "f_expansions_write" - command: subprocess.exec params: @@ -282,6 +283,7 @@ tasks: archive-dist-test-debug install-dist-test bazel_args: >- --config=evg + --config=opt_profiled - func: "upload debugsymbols" - func: "f_expansions_write" - command: subprocess.exec @@ -419,6 +421,7 @@ tasks: ${additional_package_targets|} bazel_args: >- --config=evg + --config=opt_profiled - command: subprocess.exec params: binary: bash diff --git a/etc/evergreen_yml_components/variants/amazon/test_dev.yml b/etc/evergreen_yml_components/variants/amazon/test_dev.yml index 47b6eac79ec..db07de12e90 100644 --- a/etc/evergreen_yml_components/variants/amazon/test_dev.yml +++ b/etc/evergreen_yml_components/variants/amazon/test_dev.yml @@ -153,6 +153,7 @@ buildvariants: --jobs=1600 --build_atlas=True --config=opt_profiled + --bolt_profile_use=True unittest_library_compile_flags: >- --config=evg --linkstatic=False diff --git a/etc/evergreen_yml_components/variants/ibm/test_release_master_and_lts_branches_only.yml b/etc/evergreen_yml_components/variants/ibm/test_release_master_and_lts_branches_only.yml index ca813eebaa9..b5e2cfb3114 100644 --- a/etc/evergreen_yml_components/variants/ibm/test_release_master_and_lts_branches_only.yml +++ b/etc/evergreen_yml_components/variants/ibm/test_release_master_and_lts_branches_only.yml @@ -20,6 +20,7 @@ buildvariants: # We need to compensate for SMT8 setting the cpu count very high and lower the amount of parallelism down bazel_compile_flags: >- --define=MONGO_DISTMOD=rhel81 + --compiler_type=gcc core_analyzer_distro_name: rhel81-power8-large resmoke_jobs_factor: 0.25 has_packages: true @@ -89,6 +90,7 @@ buildvariants: # We need to compensate for SMT8 setting the cpu count very high and lower the amount of parallelism down bazel_compile_flags: >- --define=MONGO_DISTMOD=rhel9 + --compiler_type=gcc core_analyzer_distro_name: rhel9-power-large resmoke_jobs_factor: 0.25 has_packages: true @@ -134,6 +136,7 @@ buildvariants: bazel_compile_flags: >- --linkstatic=False --define=MONGO_DISTMOD=rhel9 + --compiler_type=gcc compile_variant: enterprise-rhel-9-ppc64le-shared tasks: - name: compile_test_serial_TG @@ -159,6 +162,7 @@ buildvariants: test_flags: --excludeWithAnyTags=incompatible_with_s390x bazel_compile_flags: >- --define=MONGO_DISTMOD=rhel83 + --compiler_type=gcc core_analyzer_distro_name: rhel83-zseries-large resmoke_jobs_max: 2 has_packages: true @@ -200,6 +204,7 @@ buildvariants: bazel_compile_flags: >- --linkstatic=False --define=MONGO_DISTMOD=rhel83 + --compiler_type=gcc compile_variant: enterprise-rhel-83-s390x-shared exec_timeout_secs: 86400 # 24 hours exec timeout tasks: @@ -226,6 +231,7 @@ buildvariants: test_flags: --excludeWithAnyTags=incompatible_with_s390x bazel_compile_flags: >- --define=MONGO_DISTMOD=rhel9 + --compiler_type=gcc core_analyzer_distro_name: rhel9-zseries-large resmoke_jobs_max: 2 has_packages: true @@ -267,6 +273,7 @@ buildvariants: bazel_compile_flags: >- --linkstatic=False --define=MONGO_DISTMOD=rhel9 + --compiler_type=gcc compile_variant: enterprise-rhel-9-s390x-shared exec_timeout_secs: 86400 # 24 hours exec timeout tasks: diff --git a/etc/evergreen_yml_components/variants/sanitizer/test_dev.yml b/etc/evergreen_yml_components/variants/sanitizer/test_dev.yml index 696942370d4..b0e779e2fbc 100644 --- a/etc/evergreen_yml_components/variants/sanitizer/test_dev.yml +++ b/etc/evergreen_yml_components/variants/sanitizer/test_dev.yml @@ -91,6 +91,10 @@ variables: bazel_compile_flags: >- --remote_execution_priority=3 --dbg=True + --compiler_type=gcc + --dtlto=False + --pgo_profile_use=False + --bolt_profile_use=False --opt=on --build_otel=True --build_enterprise=False @@ -756,6 +760,8 @@ buildvariants: --opt=on --ubsan=True --compiler_type=clang + --dtlto=False + --pgo_profile_use=False --allocator=tcmalloc-gperf --separate_debug=False compile_variant: *rhel8-debug-ubsan-roll-back-incremental-feature-flags diff --git a/etc/evergreen_yml_components/variants/sanitizer/test_dev_master_branch_only.yml b/etc/evergreen_yml_components/variants/sanitizer/test_dev_master_branch_only.yml index 9bb8a5089f0..e903493e57b 100644 --- a/etc/evergreen_yml_components/variants/sanitizer/test_dev_master_branch_only.yml +++ b/etc/evergreen_yml_components/variants/sanitizer/test_dev_master_branch_only.yml @@ -405,6 +405,8 @@ buildvariants: --opt=on --ubsan=True --compiler_type=clang + --dtlto=False + --pgo_profile_use=False --allocator=tcmalloc-gperf --separate_debug=False compile_variant: *rhel8-debug-ubsan-all-feature-flags diff --git a/etc/evergreen_yml_components/variants/ubuntu/test_dev_master_and_lts_branches_only.yml b/etc/evergreen_yml_components/variants/ubuntu/test_dev_master_and_lts_branches_only.yml index b062a746d3c..01fefe6e1f2 100644 --- a/etc/evergreen_yml_components/variants/ubuntu/test_dev_master_and_lts_branches_only.yml +++ b/etc/evergreen_yml_components/variants/ubuntu/test_dev_master_and_lts_branches_only.yml @@ -31,6 +31,8 @@ buildvariants: bazel_compile_flags: >- --define=MONGO_DISTMOD=ubuntu2204 --compiler_type=clang + --dtlto=False + --pgo_profile_use=False --copt=-fsanitize-coverage=trace-pc-guard --linkopt=-lvoidstar diff --git a/etc/performance_thresholds.yml b/etc/performance_thresholds.yml index e60c1374193..c4c7b60b68e 100644 --- a/etc/performance_thresholds.yml +++ b/etc/performance_thresholds.yml @@ -49,5 +49,5 @@ tests: - thread_level: 1 metrics: - name: instructions_per_iteration_mean - threshold_limit: 350 + threshold_limit: 13000 bound_direction: upper diff --git a/src/mongo/db/BUILD.bazel b/src/mongo/db/BUILD.bazel index 87e6ddfaa55..72afecfbe41 100644 --- a/src/mongo/db/BUILD.bazel +++ b/src/mongo/db/BUILD.bazel @@ -1,7 +1,6 @@ load("@poetry//:dependencies.bzl", "dependency") load("//bazel:mongo_src_rules.bzl", "idl_generator", "mongo_cc_benchmark", "mongo_cc_binary", "mongo_cc_fuzzer_test", "mongo_cc_integration_test", "mongo_cc_library", "mongo_cc_unit_test", "mongo_idl_library") load("//bazel/config:render_template.bzl", "render_template") -load("//bazel/toolchains/cc/mongo_linux:mongo_toolchain_flags_v5.bzl", "CLANG_RESOURCE_DIR") package(default_visibility = ["//visibility:public"]) @@ -3683,7 +3682,6 @@ mongo_cc_binary( "//bazel/config:pgo_profile_generate_clang_enabled": [ "-fprofile-generate=mongod_perf", "-fno-data-sections", - "-resource-dir=" + CLANG_RESOURCE_DIR, ], "//bazel/config:pgo_profile_generate_gcc_enabled": [ "-fprofile-generate=mongod_perf", diff --git a/src/mongo/util/pretty_printer_test.py b/src/mongo/util/pretty_printer_test.py index e583b8106c9..774ce64d144 100644 --- a/src/mongo/util/pretty_printer_test.py +++ b/src/mongo/util/pretty_printer_test.py @@ -85,9 +85,11 @@ if __name__ == "__main__": try: gdb.execute("run") gdb.execute("frame function main") - test_decorable() + # TODO(SERVER-110170): Currently bugged in clang + # test_decorable() test_dbname_nss() - test_string_map() + # TODO(SERVER-110170): Currently bugged in clang + # test_string_map() test_boost_optional() gdb.write("TEST PASSED\n") except Exception as err: diff --git a/src/third_party/abseil-cpp/BUILD.bazel b/src/third_party/abseil-cpp/BUILD.bazel index 4acc04b3409..ff5d29a3892 100644 --- a/src/third_party/abseil-cpp/BUILD.bazel +++ b/src/third_party/abseil-cpp/BUILD.bazel @@ -550,6 +550,10 @@ mongo_cc_library( "dist/absl/base/internal/unscaledcycleclock.cc", ], hdrs = ABSEIL_HEADERS, + copts = select({ + "//bazel/config:ppc_or_s390x": ["-Wno-sign-conversion"], + "//conditions:default": [], + }), includes = ["dist"], skip_global_deps = ABSEIL_SKIP_GLOBAL_DEPS, deps = [ @@ -779,6 +783,10 @@ mongo_cc_library( "dist/absl/debugging/stacktrace.cc", ], hdrs = ABSEIL_HEADERS, + copts = select({ + "//bazel/config:ppc_or_s390x": ["-Wno-shorten-64-to-32"], + "//conditions:default": [], + }), includes = ["dist"], skip_global_deps = ABSEIL_SKIP_GLOBAL_DEPS, deps = [ @@ -1943,7 +1951,14 @@ mongo_cc_library( ], hdrs = ABSEIL_HEADERS, copts = select({ - "//bazel/config:gcc_or_clang": ["-Wno-pass-failed"], + "//bazel/config:gcc_or_clang": [ + "-Wno-pass-failed", + ], + "//conditions:default": [], + }) + select({ + "//bazel/config:ppc_or_s390x": [ + "-Wno-deprecate-lax-vec-conv-all", + ], "//conditions:default": [], }), includes = ["dist"], diff --git a/src/third_party/gperftools/BUILD.bazel b/src/third_party/gperftools/BUILD.bazel index a66cefb308d..6d28f8e81e0 100644 --- a/src/third_party/gperftools/BUILD.bazel +++ b/src/third_party/gperftools/BUILD.bazel @@ -79,6 +79,11 @@ mongo_cc_library( "-Wno-deprecated-volatile", "-Wno-sign-compare", ], + }) + select({ + "//bazel/config:ppc_or_s390x": [ + "-Wno-unused-but-set-variable", + ], + "//conditions:default": [], }), features = select({ "//bazel/config:compiler_type_gcc": ["no_volatile"],