Skip to content

fix(sbom.am): capture build macros with host cc, not cross $(CC) - #18

Open
MarkAtwood wants to merge 1 commit into
fix/autotools-gen-sbom-discoveryfrom
fix/sbom-am-host-cc
Open

fix(sbom.am): capture build macros with host cc, not cross $(CC)#18
MarkAtwood wants to merge 1 commit into
fix/autotools-gen-sbom-discoveryfrom
fix/sbom-am-host-cc

Conversation

@MarkAtwood

Copy link
Copy Markdown

The autotools path expanded the build macros with the configured $(CC) and the full AM_CFLAGS/CFLAGS, so a cross-compiled build baked the cross compiler's target-specific predefined macros into the SBOM — the same product built through a different toolchain produced a different document, breaking the byte-reproducibility the Make/CMake paths honour via their HOSTCC.

Adds SBOM_HOSTCC (default cc) and expands only the -D/-U/-I tokens of the flag set through it, so target arch flags a host cc can't parse are dropped and the capture is toolchain-independent. SBOM_OPTIONS_H (pre-expanded) and config.h handling are unchanged.

Verified the shell filter standalone: representative cross flags (-DWOLFSSL_*, -mcpu=cortex-m4, -mthumb, -Os) → host cc captures every feature macro, drops the arch flags, and leaks no __ARM_ARCH/target builtins; the unfiltered form rejects on cc. (The recipe isn't unit-testable in-repo without a full autotools product; product make sbom CI exercises it.)

⚠️ Stacked on #6 (base fix/autotools-gen-sbom-discovery) — both touch sbom.am. Merge #6 first. Addresses SBOM-gpex.10.

The autotools path expanded the build macros with the configured $(CC)
and the full AM_CFLAGS/CFLAGS, so a cross-compiled build baked the cross
compiler's target-specific predefined macros into the SBOM -- the same
product built through a different toolchain produced a different
document, breaking the byte-reproducibility contract the Make and CMake
paths honour via their HOSTCC.

Add SBOM_HOSTCC (default cc) and expand only the -D/-U/-I tokens of the
flag set through it, so target arch flags it cannot parse are dropped and
the capture is toolchain-independent. SBOM_OPTIONS_H (pre-expanded) and
config.h handling are unchanged.
Copilot AI review requested due to automatic review settings July 24, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the autotools SBOM generation fragment (share/sbom.am) to make macro-capture reproducible across cross toolchains by switching macro expansion to a host compiler and limiting which flags are fed into that expansion.

Changes:

  • Adds SBOM_HOSTCC and uses it (instead of $(CC)) for preprocessor macro capture.
  • Filters macro-capture inputs to only -D/-U/-I tokens from AM_CPPFLAGS/CPPFLAGS/AM_CFLAGS/CFLAGS before invoking the preprocessor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread share/sbom.am
Comment on lines +78 to +82
# the cross compiler's target-specific predefined macros into the SBOM, so the
# same product built through a different toolchain would produce a different
# document. Only the -D/-U/-I tokens are fed to it (see the capture below), so
# it never sees target arch flags it cannot parse.
SBOM_HOSTCC ?= cc
Comment thread share/sbom.am
Comment on lines +173 to +176
sbom_cpp=""; \
for f in $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS); do \
case "$$f" in -D*|-U*|-I*) sbom_cpp="$$sbom_cpp $$f";; esac; \
done; \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants