Revert toolchain expansions and introduce profile changelist defines to linkstamp compile. In https://github.com/rules_cc/bazel/commit/9cff17dd44cb500a06591355ce39bac66695aecf I added cpp build variables to with the expecation that I would use them in linkstamp compile but it turns out there is a direct approach which avoids this. So in this change, I've reverted the changes to compile_build_variables and introduced the necessary changes to cc_helper_internal.bzl. PiperOrigin-RevId: 941422065 Change-Id: If1155391ad9fb3f180646cbb0ed18d387402c16a
diff --git a/cc/common/cc_helper_internal.bzl b/cc/common/cc_helper_internal.bzl index df6b198..6ced37f 100644 --- a/cc/common/cc_helper_internal.bzl +++ b/cc/common/cc_helper_internal.bzl
@@ -159,6 +159,15 @@ if fdo_build_stamp: stamps["BUILD_FDO_TYPE"] = fdo_build_stamp + fdo_context = getattr(cc_toolchain, "_fdo_context", None) + if fdo_context: + fdo_profile_changelist = getattr(fdo_context, "fdo_profile_changelist", None) + if fdo_profile_changelist: + stamps["BUILD_FDO_PROFILE_CHANGELIST"] = fdo_profile_changelist + memprof_profile_changelist = getattr(fdo_context, "memprof_profile_changelist", None) + if memprof_profile_changelist: + stamps["BUILD_MEMPROF_PROFILE_CHANGELIST"] = memprof_profile_changelist + if feature_configuration.is_enabled("thin_lto"): stamps["BUILD_LTO_TYPE"] = "thin"
diff --git a/cc/private/compile/compile_build_variables.bzl b/cc/private/compile/compile_build_variables.bzl index f7575da..ed76c6e 100644 --- a/cc/private/compile/compile_build_variables.bzl +++ b/cc/private/compile/compile_build_variables.bzl
@@ -473,15 +473,6 @@ variables["memprof_profile_path"] = memprof_profile_artifact.path branch_fdo_profile = getattr(fdo_context, "branch_fdo_profile", None) - if branch_fdo_profile: - changelist = getattr(fdo_context, "fdo_profile_changelist", None) - if changelist: - variables["fdo_profile_changelist"] = changelist - - if memprof_profile_artifact: - changelist = getattr(fdo_context, "memprof_profile_changelist", None) - if changelist: - variables["memprof_profile_changelist"] = changelist if (branch_fdo_profile and auxiliary_fdo_inputs_list and
diff --git a/cc/private/toolchain/unix_cc_toolchain_config.bzl b/cc/private/toolchain/unix_cc_toolchain_config.bzl index 06d3893..2aba91c 100644 --- a/cc/private/toolchain/unix_cc_toolchain_config.bzl +++ b/cc/private/toolchain/unix_cc_toolchain_config.bzl
@@ -659,12 +659,6 @@ ] + profile_correction_flags, expand_if_available = "fdo_profile_path", ), - flag_group( - expand_if_available = "fdo_profile_changelist", - flags = [ - "-DFDO_PROFILE_CHANGELIST=%{fdo_profile_changelist}", - ], - ), ], ), ], @@ -827,12 +821,6 @@ ] + profile_correction_flags, expand_if_available = "fdo_profile_path", ), - flag_group( - expand_if_available = "fdo_profile_changelist", - flags = [ - "-DFDO_PROFILE_CHANGELIST=%{fdo_profile_changelist}", - ], - ), ], ), ], @@ -851,12 +839,6 @@ ] + profile_correction_flags, expand_if_available = "fdo_profile_path", ), - flag_group( - expand_if_available = "fdo_profile_changelist", - flags = [ - "-DFDO_PROFILE_CHANGELIST=%{fdo_profile_changelist}", - ], - ), ], ), ],