diff --git a/cc/private/toolchain/gcc_deps_scanner_wrapper.sh.tpl b/cc/private/toolchain/gcc_deps_scanner_wrapper.sh.tpl index 2c94f01f8..a43d23971 100644 --- a/cc/private/toolchain/gcc_deps_scanner_wrapper.sh.tpl +++ b/cc/private/toolchain/gcc_deps_scanner_wrapper.sh.tpl @@ -9,4 +9,6 @@ set -eu # Call the C++ compiler -%{cc} -E -x c++ -fmodules-ts -fdeps-file=out.tmp -fdeps-format=p1689r5 "$@" >"$DEPS_SCANNER_OUTPUT_FILE" +%{cc} -E -x c++ -fmodules-ts -fdeps-file="$DEPS_SCANNER_OUTPUT_FILE".tmp -fdeps-format=p1689r5 "$@" + +mv "$DEPS_SCANNER_OUTPUT_FILE".tmp "$DEPS_SCANNER_OUTPUT_FILE" diff --git a/cc/private/toolchain/unix_cc_toolchain_config.bzl b/cc/private/toolchain/unix_cc_toolchain_config.bzl index bc76ec105..bfceaeb71 100644 --- a/cc/private/toolchain/unix_cc_toolchain_config.bzl +++ b/cc/private/toolchain/unix_cc_toolchain_config.bzl @@ -13,6 +13,8 @@ # limitations under the License. """A Starlark cc_toolchain configuration rule""" +#buildifier: disable=bzl-visibility +load("@bazel_features//private:util.bzl", "ge") load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo") load("@rules_cc//cc:action_names.bzl", "ACTION_NAMES") load( @@ -35,6 +37,11 @@ load("@rules_cc//cc/common:cc_common.bzl", "cc_common") load("@rules_cc//cc/toolchains:cc_toolchain_config_info.bzl", "CcToolchainConfigInfo") load("@rules_cc//cc/toolchains:feature_injection.bzl", "FeatureInfo", "convert_feature") +def _cpp_module_extension(compiler): + """Returns the BMI/CMI file extension for cpp_module artifact_name_pattern.""" + if compiler == "gcc" and ge("9.0.0"): + return ".gcm" + return ".pcm" def _target_os_version(ctx): xcode_config = ctx.attr._xcode_config[apple_common.XcodeVersionConfig] return xcode_config.minimum_os_for_platform_type(apple_common.platform_type.macos) @@ -1891,7 +1898,7 @@ def _impl(ctx): artifact_name_pattern( category_name = "cpp_module", prefix = "", - extension = ".pcm", + extension = _cpp_module_extension(ctx.attr.compiler), ), ] features = [