Propagate the profile changelist when MemProf comes from an fdo_profile rule. `BUILD_MEMPROF_PROFILE_CHANGELIST` is stamped as `0` for almost every PGHO-optimized binary in the fleet, even though the MemProf profile is applied correctly. On 2026-09-16, of the binaries reporting `pgho_type=opt`, 243.0M GCUs across 12,949 targets stamped `0`, versus 58.2M GCUs across 28 targets that stamped a real changelist. The cause is in `_create_fdo_context`. When the MemProf profile arrives through an explicit `--memprof_profile`, the rule's `MemProfProfileInfo` is forwarded intact and keeps its `changelist`. When it instead arrives as the `memprof_profile` attribute of an `fdo_profile` (or `fdo_optimize`, or the configless AutoFDO `xbinary_fdo` path), a fresh `MemProfProfileInfo` was synthesized from the artifact alone, dropping `changelist`. The later `getattr(mem_prof_profile, "changelist", None)` then returned `None`, so `get_linkstamp_stamps` skipped the define and `builddata_globals.cc` fell back to its `0` default. Forward `FdoProfileInfo.changelist` into the synthesized `MemProfProfileInfo` in all three fallback branches. `fdo_profile.changelist` already defaults to `"0"`, so targets that do not set it keep the same stamped value as before; the only behavioral difference for them is an explicit `-DBUILD_MEMPROF_PROFILE_CHANGELIST=0` instead of relying on the header default. This only affects the recorded provenance of the profile, not which profile is selected or how the binary is optimized. PiperOrigin-RevId: 985317805 Change-Id: I015d2cd31fb19e7d89d958775b72836ba255dd89
This repository contains C, C++, and Objective-C language support for the Bazel build system.
For this module's main reference, see the Bazel documentation.
Follow the official instructions to Install Bazel.
Add the latest release to your MODULE.bazel project file.
In a BUILD.bazel file, import and use the rules:
load("@rules_cc//cc:cc_binary.bzl", "cc_binary") cc_binary( name = "hello_world", srcs = ["hello_world.cc"], )
Build and run your C/C++ binary with one command:
$ bazel run hello_world
To build the project without running the binary, use Bazel's build subcommand:
$ bazel build hello_world
rules_cc includes an auto-configured toolchain that uses the local compiler installed on the host machine.
You can disable the autoconfigured C/C++ toolchain by adding the following Bazel flag to your project's .bazelrc file:
--repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
Configuring a hermetic toolchain makes your build more deterministic. rules_cc itself does not yet offer a hermetic toolchain distribution. Other community owned and maintained projects offer hermetic C/C++ toolchains:
Bazel and rules_cc are the work of many contributors. We appreciate your help!
To contribute, please read the contribution guidelines: CONTRIBUTING.md.
Note that the rules_cc use the GitHub issue tracker for bug reports and feature requests only. For asking questions see:
rules_cc mailing list#cc on slack.bazel.build