Skip to content

fix(compdb): reject conflicting -D values and forward the driver flags - #44

Merged
sameehj merged 2 commits into
masterfrom
fix/compdb-conflicting-defines
Oct 22, 2026
Merged

sameehj merged 2 commits into
masterfrom
fix/compdb-conflicting-defines

Conversation

@Frauschi

Copy link
Copy Markdown
Member

Found while integrating wolfCert.

  • compdb_sbom.py merged every entry's -D tokens into one set, so -DFOO=10 in one file and -DFOO=2 in another both reached the capture and the SBOM recorded a configuration that matched neither. It now exits with the macro, each value and an example file, and points at --include / --exclude. A macro that only some entries define still merges as before.
  • It now forwards --license-override, --license-text, --supplier, --component-type, --dep-wolfssl, --dep-wolfcrypt, --dep-openssl and --dep-version, and accepts --options-h in place of the -D capture. Before, these SBOMs fell back to the inferred licence and listed no wolfSSL dependency.

Copilot AI balanced review requested due to automatic review settings October 19, 2026 17:47

Copilot AI 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.

🟡 Changes recommended

Conflict detection rejects equivalent definitions and blocks configurations explicitly supplied through an options header.

2 open issues
What changed in this PR

Updates the compilation-database SBOM frontend to detect conflicting macro values and forward configuration and metadata to the driver.

Changes:

  • Adds conflict diagnostics with example source files.
  • Forwards identity and dependency flags and supports --options-h.
  • Adds frontend tests and runs them in CI.
File Description
tests/​test_compdb_sbom.py Tests conflict handling and driver argument forwarding.
share/​frontends/​compdb_sbom.py Adds conflict detection and driver options.
.github/​workflows/​selftest.yml Includes the new frontend tests in CI.

Review effort: Balanced

Comment thread share/frontends/compdb_sbom.py Outdated
Comment thread share/frontends/compdb_sbom.py Outdated
@Frauschi
Frauschi force-pushed the fix/compdb-conflicting-defines branch from 210c32c to 5994232 Compare October 19, 2026 18:01
@Frauschi
Frauschi requested a review from sameehj October 19, 2026 18:08
@Frauschi
Frauschi force-pushed the fix/compdb-conflicting-defines branch 2 times, most recently from 25e8091 to 516f764 Compare October 22, 2026 12:37
compdb_sbom.py merged the -D tokens of every selected compile command into
one set. When two entries defined the same macro with different values
(-DFOO=10 in one, -DFOO=2 in another), both tokens reached the capture and
whichever the compiler saw last won, so the SBOM recorded a configuration
that matched neither build. The frontend now keys the merged set by macro
name and exits with the macro, each value and an example file when the
selected entries disagree, pointing at --include/--exclude to split the
database into one configuration per SBOM. A bare -DFOO counts as -DFOO=1,
as the compiler defines it. A macro that only some entries define still
merges as before, since per-file -D flags are normal. With --options-h the
-D tokens are not captured, so their conflicts are not checked.

The frontend also dropped flags the driver supports, so a compdb SBOM fell
back to the inferred licence, listed no wolfSSL dependency and could not
use a pre-expanded header. It now forwards --license-override,
--license-text, --supplier, --component-type, --dep-wolfssl,
--dep-wolfcrypt, --dep-openssl and --dep-version, and accepts --options-h
in place of the -D capture. --options-h with --settings-h or --include-dir
is an error, since those only feed the capture.

tests/test_compdb_sbom.py covers the conflict, the merge, --exclude as the
way out, and the forwarding through a stub driver. It is wired into
selftest.yml.
…e -include

A Zephyr build's compile_commands.json lists every kernel, driver and
application file next to the module's sources. compdb_sbom.py checked
--root before --include/--exclude, so each of those files printed a
"skipping source outside --root" warning even when the include filter
would have dropped it anyway: about 200 lines for wolfssl and 285 for
wolfCert. The filters now run first, and only a selected source outside
--root is warned about.

The driver also refused a relative --settings-h unless it existed under
the current directory, although the compdb help gives
wolfssl/wolfcrypt/settings.h as the example. It now checks only an
absolute path and leaves a relative one to the compiler's -include search,
which tries the current directory, then the -I dirs in --cflags, then each
--include-dir.

--include and --exclude gain help text saying they are re.search
patterns, not globs.
@Frauschi
Frauschi force-pushed the fix/compdb-conflicting-defines branch from 516f764 to 58a9376 Compare October 22, 2026 13:11
@sameehj
sameehj merged commit 443ef5f into master Oct 22, 2026
3 checks passed
@Frauschi
Frauschi deleted the fix/compdb-conflicting-defines branch October 22, 2026 14:27
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.

4 participants