Skip to content

[ABLD-525] Make FIPS a property of the target platform - #56440

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
regis.desgroppes/abld-525-msgo-toolchain
Nov 12, 2026
Merged

gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
mainfrom
regis.desgroppes/abld-525-msgo-toolchain

Conversation

@rdesgroppes

@rdesgroppes rdesgroppes commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Request FIPS builds with --platforms=//bazel/platforms:<os>_<cpu>_fips, whose flags select the msgo SDK, instead of the retired fips value of //packages/agent:flavor.

Key the FIPS config_settings, @openssl's and the FIPS package names on the //bazel/platforms:fips constraint, and have the omnibus helpers pass the FIPS platform.

Register a test toolchain so that bazel test works on FIPS platforms, and remove the unused macOS FIPS platforms.

Have the installer's symbol test require msgo's OpenSSL or CNG backend on the Linux or Windows FIPS platforms, and reject it elsewhere.

💡 This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS binaries load, nor lifting #59511's guard against them, which will be addressed in:

Motivation

The FIPS platforms' constraint selected nothing, and the fips flavor selected the FIPS tags but kept the upstream SDK, both silently producing non-FIPS binaries, which #59511 had to block.

Since #58511 made msgo a toolchain, the platform now carries both the constraint and the SDK choice.

Describe how you validated your changes

  • //cmd/agent builds with msgo and the FIPS tags on the FIPS platforms, requirefips being Linux-only, and with the upstream SDK and no FIPS tags on the others,
  • the agent, installer, loader and packaging targets, and @openssl, analyze with no ambiguous select() on the Linux and Windows platforms, FIPS or not,
  • bazel test passes on a FIPS platform,
  • the installer's symbol test passes on the Linux and Windows FIPS platforms, and fails when expecting a package the binary lacks.

Additional Notes

The retired flavor value now fails the analysis of packaging targets.

//cmd/dogstatsd drops its cgo select, whose FIPS branch was a no-op, #58511's msgo SDK building its OpenSSL backend without cgo through ms_nocgo_opensslcrypto, the default of msgo 1.27, leaving dd_agent_go_binary's identical default.

//cmd/loader:trace_loader_all_files only excludes Windows, like :loader, instead of listing Linux and macOS.

Groundwork:

@rdesgroppes rdesgroppes added changelog/no-changelog No changelog entry needed qa/no-code-change No code change in Agent code requiring validation labels Sep 16, 2026
@dd-octo-sts dd-octo-sts Bot added the internal Identify a non-fork PR label Sep 16, 2026
@github-actions github-actions Bot added the long review PR is complex, plan time to review it label Sep 16, 2026
@datadog-datadog-us1-prod

datadog-datadog-us1-prod Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 66.93% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 4b5adc0 | Docs | Give us feedback!

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review by Codex (OpenAI) - workflow run

The patch is incorrect: Windows FIPS task invocation fails on typical hosts, and ARM64/Windows FIPS platforms do not select Microsoft Go. The required module lockfile update is also missing. Review was static; builds were not run.

(outdated)

Comment thread tasks/libs/build/bazel.py Resolved
Comment thread bazel/platform_mappings Resolved
Comment thread deps/go.MODULE.bazel Resolved
@dd-octo-sts

dd-octo-sts Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 8a3389a
📊 Static Quality Gates Dashboard
🔗 SQG Job

33 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
✅ agent_deb_amd64 766.013 MiB
✅ agent_deb_amd64_fips 696.509 MiB
✅ agent_heroku_amd64 314.337 MiB
✅ agent_msi 671.887 MiB
✅ agent_rpm_amd64 765.990 MiB
✅ agent_rpm_amd64_fips 696.485 MiB
✅ agent_rpm_arm64 735.223 MiB
✅ agent_rpm_arm64_fips 671.504 MiB
✅ agent_suse_amd64 765.990 MiB
✅ agent_suse_amd64_fips 696.485 MiB
✅ agent_suse_arm64 735.223 MiB
✅ agent_suse_arm64_fips 671.504 MiB
✅ docker_agent_amd64 821.653 MiB
✅ docker_agent_arm64 815.580 MiB
✅ docker_agent_jmx_amd64 1012.580 MiB
✅ docker_agent_jmx_arm64 995.225 MiB
✅ docker_cws_instrumentation_amd64 9.513 MiB
✅ docker_cws_instrumentation_arm64 8.877 MiB
✅ docker_dogstatsd_amd64 40.334 MiB
✅ docker_dogstatsd_arm64 38.334 MiB
✅ docker_host_profiler_amd64 282.577 MiB
✅ docker_host_profiler_arm64 295.263 MiB
✅ dogstatsd_deb_amd64 31.086 MiB
✅ dogstatsd_deb_arm64 28.997 MiB
✅ dogstatsd_rpm_amd64 31.086 MiB
✅ dogstatsd_suse_amd64 31.086 MiB
✅ iot_agent_deb_amd64 48.378 MiB
✅ iot_agent_deb_arm64 44.751 MiB
✅ iot_agent_deb_armhf 45.525 MiB
✅ iot_agent_rpm_amd64 48.379 MiB
✅ iot_agent_suse_amd64 48.378 MiB
✅ docker_cluster_agent_amd64 218.322 MiB
✅ docker_cluster_agent_arm64 231.045 MiB

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 58d5a9fc-bfd2-49b1-827e-4fa840a16ed8

Baseline: 9335a62
Comparison: c8a96ba
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
➖ quality_gate_idle_all_features memory utilization +0.18 [+0.10, +0.26] 1 Logs bounds checks dashboard
➖ quality_gate_idle memory utilization +0.04 [-0.00, +0.09] 1 Logs bounds checks dashboard
➖ quality_gate_private_action_runner memory utilization +0.02 [-0.10, +0.15] 1 Logs bounds checks dashboard
➖ quality_gate_security_no_fs_load memory utilization -0.06 [-0.12, +0.00] 1 Logs bounds checks dashboard
➖ python_openmetrics % cpu utilization -0.17 [-0.82, +0.48] 1 Logs bounds checks dashboard
➖ quality_gate_security_idle memory utilization -0.17 [-0.22, -0.12] 1 Logs bounds checks dashboard
➖ dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization -0.42 [-0.70, -0.15] 1 Logs
➖ quality_gate_metrics_logs memory utilization -0.66 [-0.89, -0.44] 1 Logs bounds checks dashboard
➖ quality_gate_security_mean_fs_load memory utilization -0.67 [-0.71, -0.63] 1 Logs bounds checks dashboard
➖ dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization -0.69 [-0.91, -0.47] 1 Logs
➖ quality_gate_logs % cpu utilization -1.45 [-2.38, -0.53] 1 Logs bounds checks dashboard
➖ dsd_uds_client_drop_detector_cpu % cpu utilization -1.45 [-1.99, -0.92] 1 Logs

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
✅ python_openmetrics checks_execution_time 10/10 82.55 ≤ 100 bounds checks dashboard
✅ python_openmetrics cpu_usage 10/10 1350.55 ≤ 1500 bounds checks dashboard
✅ python_openmetrics memory_usage 10/10 4.31GiB ≤ 4.75GiB bounds checks dashboard
✅ quality_gate_idle intake_connections 10/10 5 ≤ 5 bounds checks dashboard
✅ quality_gate_idle memory_usage 10/10 184.37MiB ≤ 190MiB bounds checks dashboard
✅ quality_gate_idle total_bytes_received 10/10 767.66KiB ≤ 819.20KiB bounds checks dashboard
✅ quality_gate_idle_all_features intake_connections 10/10 2 ≤ 5 bounds checks dashboard
✅ quality_gate_idle_all_features memory_usage 10/10 479.48MiB ≤ 544MiB bounds checks dashboard
✅ quality_gate_idle_all_features total_bytes_received 10/10 1.17MiB ≤ 1.25MiB bounds checks dashboard
✅ quality_gate_logs intake_connections 10/10 17 ≤ 40 bounds checks dashboard
✅ quality_gate_logs memory_usage 10/10 223.05MiB ≤ 234MiB bounds checks dashboard
✅ quality_gate_logs missed_bytes 10/10 0B ≤ 0B bounds checks dashboard
✅ quality_gate_logs total_bytes_received 10/10 263.96MiB ≤ 292MiB bounds checks dashboard
✅ quality_gate_metrics_logs cpu_usage 10/10 357.99 ≤ 2000 bounds checks dashboard
✅ quality_gate_metrics_logs intake_connections 10/10 19 ≤ 40 bounds checks dashboard
✅ quality_gate_metrics_logs memory_usage 10/10 421.26MiB ≤ 463MiB bounds checks dashboard
✅ quality_gate_metrics_logs missed_bytes 10/10 0B ≤ 0B bounds checks dashboard
✅ quality_gate_metrics_logs total_bytes_received 10/10 969.94MiB ≤ 1.04GiB bounds checks dashboard
✅ quality_gate_private_action_runner memory_usage 10/10 75.02MiB ≤ 78MiB bounds checks dashboard
✅ quality_gate_security_idle cpu_usage 10/10 28.30 ≤ 100 bounds checks dashboard
✅ quality_gate_security_idle memory_usage 10/10 331.16MiB ≤ 365MiB bounds checks dashboard
✅ quality_gate_security_mean_fs_load cpu_usage 10/10 41.73 ≤ 200 bounds checks dashboard
✅ quality_gate_security_mean_fs_load memory_usage 10/10 309.46MiB ≤ 343MiB bounds checks dashboard
✅ quality_gate_security_no_fs_load cpu_usage 10/10 23.55 ≤ 100 bounds checks dashboard
✅ quality_gate_security_no_fs_load memory_usage 10/10 342.85MiB ≤ 356MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

✅ Passed. All Quality Gates passed.

  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.

rdesgroppes added a commit that referenced this pull request Sep 17, 2026
### What does this PR do?
Registers the Microsoft build of Go (msgo) as an additional toolchain
and selects it for the agent's fips flavor through --platforms, via
bazel/platform_mappings (wired in .bazelrc, since it is not at the
default workspace-root location) mapping
//bazel/platforms:linux_x86_64_fips to
--@rules_go//go/toolchain:sdk_name=msgo.
fips becomes an orthogonal //bazel/platforms:crypto constraint rather
than a flavor value: packages/agent:flavor drops "fips" from its
allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/
windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now
match on that constraint instead of the flag.
linux_fips is a plain config_setting repeating linux_default's
criteria (base_flavor and linux) plus fips_flavor, rather than a
sibling of it behind a selects.config_setting_group alias, so Bazel's
own select() specialization rule (a match wins if its criteria are a
strict superset of another match's) picks it automatically, with no
separate exclusion needed.
The @@ canonical-repository prefix is dropped from labels inside
packages/agent/BUILD.bazel itself, since a plain // there already
resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which
is injected as a different repo's own root BUILD file and genuinely
needs it.
packages/rules/package_naming.bzl's product-name injection reads the
same constraint directly (ctx.target_platform_has_constraint), since
the flavor value it used to read can no longer be "fips".
A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored
in omnibus/lib/ostools.rb) computes the right --platforms=...fips
value for the current host; every place that used to pass the retired
--//packages/agent:flavor=fips now calls it instead, including the
omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the
cws-instrumentation, installer, security-agent,
secret-generic-connector, otel-agent and process-agent invoke tasks.

Also fixes four issues surfaced once CI ran on this PR (#56440).
bazel:mod-tidy and bazel:run-buildifier-test
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528)
failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries
were single-line; buildifier wraps each sdks value and the experiments
list, the same rule already applied to packages/agent/BUILD.bazel's
linux_fips config_setting.
Reformatted to match.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172)
failed with "No fips platform for win32/AMD64": platform.machine()
returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only
had lowercase keys.
Lower-cased the lookup.

installer-fips-amd64-oci
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644)
failed compiling msgo's own crypto/internal/backend/fips140/fips140.go
with "undefined: systemFIPSMode" and "undefined: backendEnabled", right
after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on
Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by
setting GOEXPERIMENT=ms_nocgo_opensslcrypto."
The failing action is go_tool_binary building msgo's own
builder/pack/covdata tools, which has no C toolchain wired in.
deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside
systemcrypto, and a new rules_go patch
(bazel/patches/rules_go-tool-binary-goexperiment.patch) threads
sdk.experiments into that rule's own GOEXPERIMENT env, which
go_tool_binary never set for either SDK.

bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64
and bazel:test:windows-amd64
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261)
failed resolving toolchains for
test_fips_flavor_{product_name,multiword,single_word}_inner with "No
matching toolchains found for types:
@@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS
tests transition --platforms, and package_name_variables's unconditional
find_cc_toolchain() then needs a cross C++ toolchain none of those hosts
register, for fields these tests never check.
package_naming.bzl gains flavor_naming_subject, a toolchain-free rule
exposing just _inject_flavor()'s product_name, and the three FIPS tests
now build against it instead of package_name_variables.

### Motivation
rules_go's own toolchain selection is driven by
--@rules_go//go/toolchain:sdk_name, matched via target_settings on its
auto-generated toolchain() targets; deriving that flag from a custom
one would need either patching go_transition (go_binary's rule()
already claims the one incoming-transition slot Bazel allows) or
hand-writing toolchain() registrations that duplicate rules_go's own
exec/target platform matrix.
platform_mappings avoids both: it is the native Bazel mechanism for
mapping a --platforms value to other flag values, so this needs no
patch and no duplicated toolchain logic.
fips is orthogonal to flavor because omnibus's AgentFlavor enum, which
packages/agent:flavor mirrored, conflates the two and makes a heroku
or iot fips build unrepresentable; that conflation is legacy
scaffolding being migrated away from, not a constraint worth carrying
into new Bazel-only logic.
Retiring "fips" as a flavor value without fixing its remaining callers
would have left them silently building non-fips output:
--//packages/agent:flavor=fips is no longer valid, but most of the
affected builds never force analysis of the flavor flag itself, so the
invalid value is dropped rather than rejected.

### Describe how you validated your changes
Confirmed with cquery/aquery that
--platforms=//bazel/platforms:linux_x86_64_fips resolves
cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects
requirefips/goexperiment.systemcrypto into its GoCompilePkg action,
while a plain build with no flag resolves to @go_work_sdk and injects
neither, both before and after moving platform_mappings under bazel/.
Confirmed the same tags/toolchain split for cmd/dogstatsd and
cmd/installer, and confirmed packages/agent/linux:debian (the actual
.deb packaging target) and @openssl//:openssl analyze successfully
under both configurations with no ambiguous select() matches.
Reproduced the regression this fixes before fixing it: bazel test
//packages/rules:* hard-failed on
test_fips_flavor_product_name/multiword/single_word with "invalid
value 'fips'", and cmd/installer silently resolved to @go_work_sdk
with no fips tags under the retired flag.
After the fix, the same test suite and
tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and
cmd/installer resolves to @msgo with the fips tags present.
Confirmed the ambiguous-select error this design avoids is real by
temporarily removing the exclusion and rebuilding, confirmed
datadog-heroku-agent/datadog-agent package names are unaffected, and
confirmed buildifier is clean on packages/agent/BUILD.bazel with no
canonical-repository or other findings.

Confirmed each of the four fixes above directly against real job traces
fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed
--raw, run on the host with no dev-env container), quoting the exact
failures cited above.
After the fixes, bazel run //bazel/buildifier:test is clean repo-wide,
bazel mod tidy --lockfile_mode=off produces no diff, bazel test
//packages/rules:* passes all 8 targets,
tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via
pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips
//cmd/agent:agent succeeds, with go version -m on the resulting binary
still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the
expected requirefips/goexperiment.systemcrypto tags.

### Additional Notes
//:gazelle_binary built together with --platforms=...fips in the same
invocation still inherits msgo, since nothing separates its
configuration from cmd/agent's in that case.
This is benign: cmd/agent's own build has no go_tool_transition-reached
dependencies for msgo to leak into, and nobody invokes gazelle with a
platform override in practice.
cmd/agent and cmd/dogstatsd never force analysis of
//packages/agent:flavor itself, so the retired
--//packages/agent:flavor=fips invocation silently falls back to a
non-fips build for them rather than erroring; that direction is safe,
since BuiltForFIPS() correctly reports false rather than a false
positive.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from 7d11ade to ea7c3fe Compare September 17, 2026 11:30
rdesgroppes added a commit that referenced this pull request Sep 17, 2026
### What does this PR do?
Registers the Microsoft build of Go (msgo) as an additional toolchain
and selects it for the agent's fips flavor through --platforms, via
bazel/platform_mappings (wired in .bazelrc, since it is not at the
default workspace-root location) mapping
//bazel/platforms:linux_x86_64_fips to
--@rules_go//go/toolchain:sdk_name=msgo.
fips becomes an orthogonal //bazel/platforms:crypto constraint rather
than a flavor value: packages/agent:flavor drops "fips" from its
allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/
windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now
match on that constraint instead of the flag.
linux_fips is a plain config_setting repeating linux_default's
criteria (base_flavor and linux) plus fips_flavor, rather than a
sibling of it behind a selects.config_setting_group alias, so Bazel's
own select() specialization rule (a match wins if its criteria are a
strict superset of another match's) picks it automatically, with no
separate exclusion needed.
The @@ canonical-repository prefix is dropped from labels inside
packages/agent/BUILD.bazel itself, since a plain // there already
resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which
is injected as a different repo's own root BUILD file and genuinely
needs it.
packages/rules/package_naming.bzl's product-name injection reads the
same constraint directly (ctx.target_platform_has_constraint), since
the flavor value it used to read can no longer be "fips".
A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored
in omnibus/lib/ostools.rb) computes the right --platforms=...fips
value for the current host; every place that used to pass the retired
--//packages/agent:flavor=fips now calls it instead, including the
omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the
cws-instrumentation, installer, security-agent,
secret-generic-connector, otel-agent and process-agent invoke tasks.

Also fixes four issues surfaced once CI ran on this PR (#56440).
bazel:mod-tidy and bazel:run-buildifier-test
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528)
failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries
were single-line; buildifier wraps each sdks value and the experiments
list, the same rule already applied to packages/agent/BUILD.bazel's
linux_fips config_setting.
Reformatted to match.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172)
failed with "No fips platform for win32/AMD64": platform.machine()
returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only
had lowercase keys.
Lower-cased the lookup.

installer-fips-amd64-oci
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644)
failed compiling msgo's own crypto/internal/backend/fips140/fips140.go
with "undefined: systemFIPSMode" and "undefined: backendEnabled", right
after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on
Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by
setting GOEXPERIMENT=ms_nocgo_opensslcrypto."
The failing action is go_tool_binary building msgo's own
builder/pack/covdata tools, which has no C toolchain wired in.
deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside
systemcrypto, and a new rules_go patch
(bazel/patches/rules_go-tool-binary-goexperiment.patch) threads
sdk.experiments into that rule's own GOEXPERIMENT env, which
go_tool_binary never set for either SDK.

bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64
and bazel:test:windows-amd64
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261)
failed resolving toolchains for
test_fips_flavor_{product_name,multiword,single_word}_inner with "No
matching toolchains found for types:
@@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS
tests transition --platforms, and package_name_variables's unconditional
find_cc_toolchain() then needs a cross C++ toolchain none of those hosts
register, for fields these tests never check.
package_naming.bzl gains flavor_naming_subject, a toolchain-free rule
exposing just _inject_flavor()'s product_name, and the three FIPS tests
now build against it instead of package_name_variables.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378) then
failed in build_object_files's bazel test
--platforms=//bazel/platforms:windows_x86_64_fips
//pkg/ebpf:verify_generated_files with "While resolving toolchains for
target //pkg/windowsdriver/procmon:types_godefs_test: No matching
toolchains found for types:
@@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin
test toolchain requires the execution platform to match every constraint
of the target platform, and no auto-detected host platform carries the
artificial :fips constraint value now baked into --platforms.
Reproduced the same failure locally against
//bazel/platforms:linux_x86_64_fips, confirming it is not
Windows-specific.
MODULE.bazel now registers linux_x86_64_fips, linux_arm64_fips and
windows_x86_64_fips (the platforms fips_platform_flag() can produce) as
execution platforms too, so a fips build's own host still qualifies as
its exec platform.

### Motivation
rules_go's own toolchain selection is driven by
--@rules_go//go/toolchain:sdk_name, matched via target_settings on its
auto-generated toolchain() targets; deriving that flag from a custom
one would need either patching go_transition (go_binary's rule()
already claims the one incoming-transition slot Bazel allows) or
hand-writing toolchain() registrations that duplicate rules_go's own
exec/target platform matrix.
platform_mappings avoids both: it is the native Bazel mechanism for
mapping a --platforms value to other flag values, so this needs no
patch and no duplicated toolchain logic.
fips is orthogonal to flavor because omnibus's AgentFlavor enum, which
packages/agent:flavor mirrored, conflates the two and makes a heroku
or iot fips build unrepresentable; that conflation is legacy
scaffolding being migrated away from, not a constraint worth carrying
into new Bazel-only logic.
Retiring "fips" as a flavor value without fixing its remaining callers
would have left them silently building non-fips output:
--//packages/agent:flavor=fips is no longer valid, but most of the
affected builds never force analysis of the flavor flag itself, so the
invalid value is dropped rather than rejected.

### Describe how you validated your changes
Confirmed with cquery/aquery that
--platforms=//bazel/platforms:linux_x86_64_fips resolves
cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects
requirefips/goexperiment.systemcrypto into its GoCompilePkg action,
while a plain build with no flag resolves to @go_work_sdk and injects
neither, both before and after moving platform_mappings under bazel/.
Confirmed the same tags/toolchain split for cmd/dogstatsd and
cmd/installer, and confirmed packages/agent/linux:debian (the actual
.deb packaging target) and @openssl//:openssl analyze successfully
under both configurations with no ambiguous select() matches.
Reproduced the regression this fixes before fixing it: bazel test
//packages/rules:* hard-failed on
test_fips_flavor_product_name/multiword/single_word with "invalid
value 'fips'", and cmd/installer silently resolved to @go_work_sdk
with no fips tags under the retired flag.
After the fix, the same test suite and
tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and
cmd/installer resolves to @msgo with the fips tags present.
Confirmed the ambiguous-select error this design avoids is real by
temporarily removing the exclusion and rebuilding, confirmed
datadog-heroku-agent/datadog-agent package names are unaffected, and
confirmed buildifier is clean on packages/agent/BUILD.bazel with no
canonical-repository or other findings.

Confirmed each of the four fixes above directly against real job traces
fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed
--raw, run on the host with no dev-env container), quoting the exact
failures cited above.
After the fixes, bazel run //bazel/buildifier:test is clean repo-wide,
bazel mod tidy --lockfile_mode=off produces no diff, bazel test
//packages/rules:* passes all 8 targets,
tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via
pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips
//cmd/agent:agent succeeds, with go version -m on the resulting binary
still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the
expected requirefips/goexperiment.systemcrypto tags.

Confirmed windows_msi_and_bosh_zip_x64-a7-fips's fix too: bazel test
--platforms=//bazel/platforms:linux_x86_64_fips
//pkg/ebpf:verify_generated_files now passes locally with no
--extra_execution_platforms override needed, and a plain (non-fips)
bazel test //pkg/ebpf:verify_generated_files is unaffected.

### Additional Notes
//:gazelle_binary built together with --platforms=...fips in the same
invocation still inherits msgo, since nothing separates its
configuration from cmd/agent's in that case.
This is benign: cmd/agent's own build has no go_tool_transition-reached
dependencies for msgo to leak into, and nobody invokes gazelle with a
platform override in practice.
cmd/agent and cmd/dogstatsd never force analysis of
//packages/agent:flavor itself, so the retired
--//packages/agent:flavor=fips invocation silently falls back to a
non-fips build for them rather than erroring; that direction is safe,
since BuiltForFIPS() correctly reports false rather than a false
positive.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from ea7c3fe to 37220eb Compare September 17, 2026 14:55
rdesgroppes added a commit that referenced this pull request Sep 17, 2026
### What does this PR do?
Registers the Microsoft build of Go (msgo) as an additional toolchain
and selects it for the agent's fips flavor through --platforms, via
bazel/platform_mappings (wired in .bazelrc, since it is not at the
default workspace-root location) mapping
//bazel/platforms:linux_x86_64_fips to
--@rules_go//go/toolchain:sdk_name=msgo.
fips becomes an orthogonal //bazel/platforms:crypto constraint rather
than a flavor value: packages/agent:flavor drops "fips" from its
allowed values, and fips_flavor/linux_x86_64_fips/linux_arm64_fips/
windows_x86_64_fips and deps/openssl.BUILD.bazel's fips_windows now
match on that constraint instead of the flag.
linux_fips is a plain config_setting repeating linux_default's
criteria (base_flavor and linux) plus fips_flavor, rather than a
sibling of it behind a selects.config_setting_group alias, so Bazel's
own select() specialization rule (a match wins if its criteria are a
strict superset of another match's) picks it automatically, with no
separate exclusion needed.
The @@ canonical-repository prefix is dropped from labels inside
packages/agent/BUILD.bazel itself, since a plain // there already
resolves to the same repo; it stays in deps/openssl.BUILD.bazel, which
is injected as a different repo's own root BUILD file and genuinely
needs it.
packages/rules/package_naming.bzl's product-name injection reads the
same constraint directly (ctx.target_platform_has_constraint), since
the flavor value it used to read can no longer be "fips".
A new fips_platform_flag() helper (tasks/libs/build/bazel.py, mirrored
in omnibus/lib/ostools.rb) computes the right --platforms=...fips
value for the current host; every place that used to pass the retired
--//packages/agent:flavor=fips now calls it instead, including the
omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the
cws-instrumentation, installer, security-agent,
secret-generic-connector, otel-agent and process-agent invoke tasks.

Also fixes four issues surfaced once CI ran on this PR (#56440).
bazel:mod-tidy and bazel:run-buildifier-test
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528)
failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries
were single-line; buildifier wraps each sdks value and the experiments
list, the same rule already applied to packages/agent/BUILD.bazel's
linux_fips config_setting.
Reformatted to match.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172)
failed with "No fips platform for win32/AMD64": platform.machine()
returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only
had lowercase keys.
Lower-cased the lookup.

installer-fips-amd64-oci
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644)
failed compiling msgo's own crypto/internal/backend/fips140/fips140.go
with "undefined: systemFIPSMode" and "undefined: backendEnabled", right
after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on
Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by
setting GOEXPERIMENT=ms_nocgo_opensslcrypto."
The failing action is go_tool_binary building msgo's own
builder/pack/covdata tools, which has no C toolchain wired in.
deps/go.MODULE.bazel now sets ms_nocgo_opensslcrypto alongside
systemcrypto, and a new rules_go patch
(bazel/patches/rules_go-tool-binary-goexperiment.patch) threads
sdk.experiments into that rule's own GOEXPERIMENT env, which
go_tool_binary never set for either SDK.

bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64
and bazel:test:windows-amd64
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261)
failed resolving toolchains for
test_fips_flavor_{product_name,multiword,single_word}_inner with "No
matching toolchains found for types:
@@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS
tests transition --platforms, and package_name_variables's unconditional
find_cc_toolchain() then needs a cross C++ toolchain none of those hosts
register, for fields these tests never check.
package_naming.bzl gains flavor_naming_subject, a toolchain-free rule
exposing just _inject_flavor()'s product_name, and the three FIPS tests
now build against it instead of package_name_variables.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378) then
failed in build_object_files's bazel test
--platforms=//bazel/platforms:windows_x86_64_fips
//pkg/ebpf:verify_generated_files with "While resolving toolchains for
target //pkg/windowsdriver/procmon:types_godefs_test: No matching
toolchains found for types:
@@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin
test toolchain requires the execution platform to match every constraint
of the target platform, and no auto-detected host platform carries the
artificial :fips constraint value now baked into --platforms.
Reproduced the same failure locally against
//bazel/platforms:linux_x86_64_fips, confirming it is not
Windows-specific.
Registering those platforms as execution platforms did fix that, but a
follow-up push then broke bazel:test:windows-amd64 (a plain, non-fips
job) with "no such target
'@@toolchains_llvm++llvm+llvm_toolchain_llvm//:install-name-tool'": that
registration also makes linux_x86_64_fips and linux_arm64_fips candidate
execution platforms for unrelated toolchain resolution repo-wide, and
//bazel/tools:install_name_tool's own select() on @platforms//os then
picked the linux branch on a real Windows host, whose actual
@llvm_toolchain_llvm archive naturally has no such target.
Confirmed bazel:test:windows-amd64 passes on main's own latest pipeline,
ruling out a pre-existing, unrelated cause.
Replaced that with a toolchain() (bazel/platforms:fips_test_toolchain)
registered for just
@bazel_tools//tools/test:default_test_toolchain_type, restricted via
target_compatible_with to :fips and without
use_target_platform_constraints, exactly the override the
toolchain_type's own no_match_error suggests; this registers no new
execution platform at all.

### Motivation
rules_go's own toolchain selection is driven by
--@rules_go//go/toolchain:sdk_name, matched via target_settings on its
auto-generated toolchain() targets; deriving that flag from a custom
one would need either patching go_transition (go_binary's rule()
already claims the one incoming-transition slot Bazel allows) or
hand-writing toolchain() registrations that duplicate rules_go's own
exec/target platform matrix.
platform_mappings avoids both: it is the native Bazel mechanism for
mapping a --platforms value to other flag values, so this needs no
patch and no duplicated toolchain logic.
fips is orthogonal to flavor because omnibus's AgentFlavor enum, which
packages/agent:flavor mirrored, conflates the two and makes a heroku
or iot fips build unrepresentable; that conflation is legacy
scaffolding being migrated away from, not a constraint worth carrying
into new Bazel-only logic.
Retiring "fips" as a flavor value without fixing its remaining callers
would have left them silently building non-fips output:
--//packages/agent:flavor=fips is no longer valid, but most of the
affected builds never force analysis of the flavor flag itself, so the
invalid value is dropped rather than rejected.

### Describe how you validated your changes
Confirmed with cquery/aquery that
--platforms=//bazel/platforms:linux_x86_64_fips resolves
cmd/agent:agent to @msgo//:go_linux_amd64-impl and injects
requirefips/goexperiment.systemcrypto into its GoCompilePkg action,
while a plain build with no flag resolves to @go_work_sdk and injects
neither, both before and after moving platform_mappings under bazel/.
Confirmed the same tags/toolchain split for cmd/dogstatsd and
cmd/installer, and confirmed packages/agent/linux:debian (the actual
.deb packaging target) and @openssl//:openssl analyze successfully
under both configurations with no ambiguous select() matches.
Reproduced the regression this fixes before fixing it: bazel test
//packages/rules:* hard-failed on
test_fips_flavor_product_name/multiword/single_word with "invalid
value 'fips'", and cmd/installer silently resolved to @go_work_sdk
with no fips tags under the retired flag.
After the fix, the same test suite and
tasks/unit_tests/libs/build/bazel_tests.py both pass in full, and
cmd/installer resolves to @msgo with the fips tags present.
Confirmed the ambiguous-select error this design avoids is real by
temporarily removing the exclusion and rebuilding, confirmed
datadog-heroku-agent/datadog-agent package names are unaffected, and
confirmed buildifier is clean on packages/agent/BUILD.bazel with no
canonical-repository or other findings.

Confirmed each of the four fixes above directly against real job traces
fetched with ddgl (ddtool auth gitlab login, then ddgl logs --failed
--raw, run on the host with no dev-env container), quoting the exact
failures cited above.
After the fixes, bazel run //bazel/buildifier:test is clean repo-wide,
bazel mod tidy --lockfile_mode=off produces no diff, bazel test
//packages/rules:* passes all 8 targets,
tasks/unit_tests/libs/build/bazel_tests.py passes all 23 cases via
pytest, and bazel build --platforms=//bazel/platforms:linux_x86_64_fips
//cmd/agent:agent succeeds, with go version -m on the resulting binary
still showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the
expected requirefips/goexperiment.systemcrypto tags.

Confirmed windows_msi_and_bosh_zip_x64-a7-fips's fix still holds with
fips_test_toolchain in place: bazel test
--platforms=//bazel/platforms:linux_x86_64_fips
//pkg/ebpf:verify_generated_files and a plain (non-fips) bazel test
//pkg/ebpf:verify_generated_files both pass locally, with no
--extra_execution_platforms override needed and no new execution
platform registered.

### Additional Notes
//:gazelle_binary built together with --platforms=...fips in the same
invocation still inherits msgo, since nothing separates its
configuration from cmd/agent's in that case.
This is benign: cmd/agent's own build has no go_tool_transition-reached
dependencies for msgo to leak into, and nobody invokes gazelle with a
platform override in practice.
cmd/agent and cmd/dogstatsd never force analysis of
//packages/agent:flavor itself, so the retired
--//packages/agent:flavor=fips invocation silently falls back to a
non-fips build for them rather than erroring; that direction is safe,
since BuiltForFIPS() correctly reports false rather than a false
positive.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from 37220eb to 0280e9c Compare September 17, 2026 16:33
rdesgroppes added a commit that referenced this pull request Sep 28, 2026
### What does this PR do?
Register the Microsoft build of Go (msgo) as an additional toolchain and
select it for the agent's fips flavor through --platforms, via
bazel/platform_mappings (wired in .bazelrc, since it is not at the
default workspace-root location) mapping
//bazel/platforms:linux_x86_64_fips to
--@rules_go//go/toolchain:sdk_name=msgo.
Make fips an orthogonal //bazel/platforms:crypto constraint rather than
a flavor value: drop "fips" from packages/agent:flavor's allowed values,
and match
fips_flavor/linux_x86_64_fips/linux_arm64_fips/windows_x86_64_fips and
deps/openssl.BUILD.bazel's fips_windows on that constraint instead of
the flag.
Define linux_fips as a plain config_setting repeating linux_default's
criteria (base_flavor and linux) plus fips_flavor, rather than a sibling
of it behind a selects.config_setting_group alias, so Bazel's own
select() specialization rule (a match wins if its criteria are a strict
superset of another match's) picks it automatically, with no separate
exclusion needed.
Drop the @@ canonical-repository prefix from labels inside
packages/agent/BUILD.bazel itself, since a plain // there already
resolves to the same repo; keep it in deps/openssl.BUILD.bazel, which is
injected as a different repo's own root BUILD file and genuinely needs
it.
Read the same constraint directly in packages/rules/package_naming.bzl's
product-name injection (ctx.target_platform_has_constraint), since the
flavor value it used to read can no longer be "fips".
Add a new fips_platform_flag() helper (tasks/libs/build/bazel.py,
mirrored in omnibus/lib/ostools.rb) that computes the right
--platforms=...fips value for the current host, and call it wherever the
retired --//packages/agent:flavor=fips used to be passed, including the
omnibus-driven _insert_omnibazel_flags/omnibazel_flags path and the
cws-instrumentation, installer, security-agent,
secret-generic-connector, otel-agent and process-agent invoke tasks.

Also fix four issues surfaced once CI ran on this PR (#56440).
bazel:mod-tidy and bazel:run-buildifier-test
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049165432,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049156528)
failed because deps/go.MODULE.bazel's new msgo sdks/experiments entries
were single-line; buildifier wraps each sdks value and the experiments
list, the same rule already applied to packages/agent/BUILD.bazel's
linux_fips config_setting.
Reformat to match.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049288172)
failed with "No fips platform for win32/AMD64": platform.machine()
returns "AMD64" on Windows, but fips_platform_flag()'s lookup dict only
had lowercase keys.
Lower-case the lookup.

installer-fips-amd64-oci
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049201644)
failed compiling msgo's own crypto/internal/backend/fips140/fips140.go
with "undefined: systemFIPSMode" and "undefined: backendEnabled", right
after msgo's own compiler warned "Using GOEXPERIMENT=systemcrypto on
Linux requires CGO_ENABLED=1. Consider using our cgo-less experiment by
setting GOEXPERIMENT=ms_nocgo_opensslcrypto."
The failing action is go_tool_binary building msgo's own
builder/pack/covdata tools, which has no C toolchain wired in.
Set ms_nocgo_opensslcrypto alongside systemcrypto in
deps/go.MODULE.bazel.
go_tool_binary's missing GOEXPERIMENT forwarding was a rules_go bug, not
something to patch locally: fixed upstream as
bazel-contrib/rules_go#4717, now included by MODULE.bazel's rules_go
pin, so no local patch is needed.

bazel:test:linux-arm64, bazel:test:macos-amd64, bazel:test:macos-arm64
and bazel:test:windows-amd64
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049226552,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049254274,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049237446,
https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2049292261)
failed resolving toolchains for
test_fips_flavor_{product_name,multiword,single_word}_inner with "No
matching toolchains found for types:
@@bazel_tools//tools/cpp:toolchain_type": package_naming_test.bzl's FIPS
tests transition --platforms, and package_name_variables's unconditional
find_cc_toolchain() then needs a cross C++ toolchain none of those hosts
register, for fields these tests never check.
Add flavor_naming_subject to package_naming.bzl, a toolchain-free rule
exposing just _inject_flavor()'s product_name, and build the three FIPS
tests against it instead of package_name_variables.

windows_msi_and_bosh_zip_x64-a7-fips
(https://gitlab.ddbuild.io/DataDog/datadog-agent/-/jobs/2053088378)
failed in build_object_files's bazel test
--platforms=//bazel/platforms:windows_x86_64_fips
//pkg/ebpf:verify_generated_files with "While resolving toolchains for
target //pkg/windowsdriver/procmon:types_godefs_test: No matching
toolchains found for types:
@@bazel_tools//tools/test:default_test_toolchain_type": Bazel's builtin
test toolchain requires the execution platform to match every constraint
of the target platform, and no auto-detected host platform carries the
artificial :fips constraint value now baked into --platforms.
Add a toolchain() (bazel/platforms:fips_test_toolchain) registered for
just @bazel_tools//tools/test:default_test_toolchain_type, restricted
via target_compatible_with to :fips and without
use_target_platform_constraints, exactly the override the
toolchain_type's own no_match_error suggests; this registers no new
execution platform.

### Motivation
rules_go's own toolchain selection is driven by
--@rules_go//go/toolchain:sdk_name, matched via target_settings on its
auto-generated toolchain() targets; deriving that flag from a custom
one would need either patching go_transition (go_binary's rule()
already claims the one incoming-transition slot Bazel allows) or
hand-writing toolchain() registrations that duplicate rules_go's own
exec/target platform matrix.
platform_mappings avoids both: it is the native Bazel mechanism for
mapping a --platforms value to other flag values, so this needs no
patch and no duplicated toolchain logic.
fips is orthogonal to flavor because omnibus's AgentFlavor enum, which
packages/agent:flavor mirrored, conflates the two and makes a heroku
or iot fips build unrepresentable; that conflation is legacy
scaffolding being migrated away from, not a constraint worth carrying
into new Bazel-only logic.
Retiring "fips" as a flavor value is safe against a caller anyone
forgets to update: every FIPS-tagged target's own gotags select() forces
evaluation of //packages/agent:flavor, so passing the retired
--//packages/agent:flavor=fips hard-errors at analysis time ("invalid
value 'fips'") rather than silently building a mislabeled non-fips
binary.

### Describe how you validated your changes
--platforms=//bazel/platforms:linux_x86_64_fips resolves cmd/agent:agent
to @msgo//:go_linux_amd64-impl and injects
requirefips/goexperiment.systemcrypto into its GoCompilePkg action,
while a plain build with no flag resolves to @go_work_sdk and injects
neither.
The same tags/toolchain split holds for cmd/dogstatsd and cmd/installer,
and packages/agent/linux:debian (the actual .deb packaging target) and
@openssl//:openssl analyze successfully under both configurations with
no ambiguous select() matches.

bazel test //packages/rules:* (8 targets) and
tasks/unit_tests/libs/build/bazel_tests.py (23 cases via pytest) both
pass, cmd/installer resolves to @msgo with the fips tags present,
datadog-heroku-agent/datadog-agent package names are unaffected, and
bazel run //bazel/buildifier:test and bazel mod tidy --lockfile_mode=off
are clean repo-wide with no diff.

bazel build --platforms=//bazel/platforms:linux_x86_64_fips
//cmd/agent:agent succeeds, with go version -m on the resulting binary
showing GOEXPERIMENT=systemcrypto,ms_nocgo_opensslcrypto and the
expected requirefips/goexperiment.systemcrypto tags.
bazel test --platforms=//bazel/platforms:linux_x86_64_fips
//pkg/ebpf:verify_generated_files and a plain (non-fips) bazel test
//pkg/ebpf:verify_generated_files both pass locally, with no new
execution platform registered.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch 2 times, most recently from ac07444 to 8d6999c Compare September 28, 2026 17:30
rdesgroppes added a commit that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
rdesgroppes added a commit that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
rdesgroppes added a commit that referenced this pull request Sep 29, 2026
### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer`
and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to
`v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly
runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against
`v10.1.0`, which allows us to drop a patch whose purpose is now subsumed
by upstream's own generalized `*.bazel` glob in `runner.bash.template`
(bazel-contrib/buildtools#1463).

Apply `bazel run //bazel/buildifier`'s resulting formatting fixes across
matched files.

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so
newer `buildozer` capabilities were unavailable, which surfaced while
working on #56440: an `invoke` task needs to update a dict-of-lists
attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that
shape: `dict_set` only accepts a scalar value, and `dict_list_add`
silently sorts the list it builds, which would swap `filename` and
`sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in
bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move
past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
`module-docstring` is suppressed in `.buildifier.json` for unrelated,
pre-existing reasons predating this PR.

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Sep 29, 2026
…57078)

### What does this PR do?
Bump the pinned Bazel `buildtools` binaries (`buildifier`, `buildozer` and `unused-deps`) from `v8.2.1` (former `bazelbuild/buildtools`) to `v10.1.0` (now `bazel-contrib/buildtools`) in:
- `bazel/prebuilt_buildtools.json`,
- the corresponding `http_archive` in `MODULE.bazel` (invocation helpers).

Add a `go_shim` target to `buildozer` so the bumped binary is directly runnable via `bazel run //:buildozer -- ...`.

Regenerate `bazel/patches/buildifier-runner-bat-template.patch` against `v10.1.0`, which allows us to drop a patch whose purpose is now subsumed by upstream's own generalized `*.bazel` glob in `runner.bash.template` (bazel-contrib/buildtools#1463).

### Motivation
Bazel `buildtools` were pinned to `v8.2.1`, well behind upstream, so newer `buildozer` capabilities were unavailable, which surfaced while working on #56440: an `invoke` task needs to update a dict-of-lists attribute via `buildozer` (`msgo` SDK bump for [ABLD-525]).

At `v8.2.1`, `buildozer`'s dict-editing commands are unsafe for that shape: `dict_set` only accepts a scalar value, and `dict_list_add` silently sorts the list it builds, which would swap `filename` and `sha256` whereas `rules_go` unpacks that pair **positionally**.

The fix, a `set attr:expr <literal>` command, landed in bazel-contrib/buildtools#1448 for `v10.0.1`, requiring the pin to move past it.

### Describe how you validated your changes
`bazel run //bazel/buildifier` works on both Linux **and Windows**.

### Additional Notes
This change was too large, leading to the extraction of following prerequisites:
- #57087
- #57088
- #57090

[ABLD-525]: https://datadoghq.atlassian.net/browse/ABLD-525?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Co-authored-by: regis.desgroppes <[email protected]>
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from 8d6999c to 85feaca Compare September 29, 2026 17:25
@ofek ofek mentioned this pull request Oct 1, 2026
@rdesgroppes
rdesgroppes requested a review from a team as a code owner November 11, 2026 14:33
@rdesgroppes
rdesgroppes requested a review from jack0x2 November 11, 2026 14:33
@github-actions github-actions Bot deleted a comment from chatgpt-codex-connector Bot Nov 11, 2026
@github-actions github-actions Bot deleted a comment from chatgpt-codex-connector Bot Nov 11, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review by Codex (OpenAI) - workflow run

The patch is correct based on static review. No actionable issues were identified in the changed lines. Bazel builds and tests were not run because the environment is read-only and network-restricted.

@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from 0311b31 to d9157f1 Compare November 11, 2026 14:41
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from d9157f1 to 95bddbb Compare November 11, 2026 15:32
@rdesgroppes
rdesgroppes requested review from a team as code owners November 11, 2026 15:32
@rdesgroppes
rdesgroppes requested a review from pgimalac November 11, 2026 15:32
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch 2 times, most recently from 4ed747b to c466352 Compare November 11, 2026 15:55
@dd-octo-sts dd-octo-sts Bot removed the stale label Nov 11, 2026
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from c466352 to ee380eb Compare November 11, 2026 16:40
@rdesgroppes
rdesgroppes requested a review from a team as a code owner November 11, 2026 16:40
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from ee380eb to b33124a Compare November 11, 2026 17:01
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch 2 times, most recently from 697e7a8 to 69bfbf8 Compare November 11, 2026 17:26
### What does this PR do?

Request FIPS builds with
`--platforms=//bazel/platforms:<os>_<cpu>_fips`, whose `flags` select
the `msgo` SDK, instead of the retired `fips` value of
`//packages/agent:flavor`.
Key the FIPS `config_setting`s, `@openssl`'s and the FIPS package names
on the `//bazel/platforms:fips` constraint, and have the omnibus helpers
pass the FIPS platform.
Register a test toolchain so that `bazel test` works on FIPS platforms,
and remove the unused macOS FIPS platforms.
Have the installer's symbol test require `msgo`'s OpenSSL or CNG
backend on the Linux or Windows FIPS platforms, and reject it elsewhere.
This doesn't cover the RUNPATH of the OpenSSL that Bazel-built FIPS
binaries load, nor lifting #59511's guard against them, which depends
on it.

### Motivation

The FIPS platforms' constraint selected nothing, and the `fips` flavor
selected the FIPS tags but kept the upstream SDK, both silently
producing non-FIPS binaries, which #59511 had to block.
Since #58511 made `msgo` a toolchain, the platform now carries both the
constraint and the SDK choice.

### Describe how you validated your changes

- `//cmd/agent` builds with `msgo` and the FIPS tags on the FIPS
  platforms, `requirefips` being Linux-only, and with the upstream SDK
  and no FIPS tags on the others,
- the agent, installer, loader and packaging targets, and `@openssl`,
  analyze with no ambiguous `select()` on the Linux and Windows
  platforms, FIPS or not,
- `bazel test` passes on a FIPS platform,
- the installer's symbol test passes on the Linux and Windows FIPS
  platforms, and fails when expecting a package the binary lacks.

### Additional Notes

The retired flavor value now fails the analysis of packaging targets.
`//cmd/dogstatsd` drops its `cgo` select, whose FIPS branch was a no-op,
#58511's `msgo` SDK building its OpenSSL backend without cgo through
`ms_nocgo_opensslcrypto`, the default of `msgo` 1.27
(https://devblogs.microsoft.com/go/go-1-27-0-1-microsoft-build-now-available/),
leaving `dd_agent_go_binary`'s identical default.
`//cmd/loader:trace_loader_all_files` only excludes Windows, like
`:loader`, instead of listing Linux and macOS.
Groundwork:
- #56351
- #56865
- #57078
- #57223
- #58511
- #58530
- #59501
- #59511
- #59840
- #60181
@rdesgroppes
rdesgroppes force-pushed the regis.desgroppes/abld-525-msgo-toolchain branch from 69bfbf8 to 4b5adc0 Compare November 11, 2026 17:37
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit c8a96ba into main Nov 12, 2026
565 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants