Skip to content

Recognize --target=<value>/-target=<value> equals-sign form (#1158) - #5001

Open
mmido6039 wants to merge 2 commits into
Ericsson:masterfrom
mmido6039:fix-1158-target-equals-sign
Open

Recognize --target=<value>/-target=<value> equals-sign form (#1158)#5001
mmido6039 wants to merge 2 commits into
Ericsson:masterfrom
mmido6039:fix-1158-target-equals-sign

Conversation

@mmido6039

Copy link
Copy Markdown
Contributor

Fixes #1158

Problem

CodeChecker did not differentiate compile database entries with
different Clang -target switches, as described in the issue.

Root cause

__get_target() in log_parser.py only matched the space-separated
form of the target flag ('-target ' / '--target ').
The equals-sign form ('--target=' / '-target='), a
very common cross-compilation syntax, was not recognized at all and
fell through unhandled. As a result, the explicitly requested target
was silently dropped, and the compiler's own native default target
was used instead (verified directly: clang++ --target=aarch64-linux-gnu
ended up analyzed as x86_64-pc-linux-gnu on the test machine).

Fix

Extended __get_target() to also recognize and strip the
'--target='/'-target=' prefix form, in addition to the existing
space-separated form.

Testing

Added a regression test (test_target_equals_sign_form) with a new
fixture covering both the equals-sign and space-separated forms for
the same source file, asserting the exact resolved target for each -
the existing similarly-named test only asserted len(target) > 0,
which would not have caught this regression. All tests in
test_log_parser.py pass; pycodestyle clean.

Known follow-up (out of scope for this PR)

The compiler-info caching key (used to cache implicit include paths/
standard/target per compiler+language+flags) also does not account
for an explicit target, so two different --target= values on the
same compiler binary could still share cached compiler_includes.
Fixing that touches the persisted compiler_info.json cache format
and felt like a separate, riskier change - happy to follow up in a
second PR if useful.

@mmido6039
mmido6039 requested a review from bruntib as a code owner August 2, 2026 18:57
Support parsing of the equals-sign form of the --target option
(e.g. --target=aarch64-linux-gnu) in addition to the existing
space-separated form.

The compilation target is now correctly stored and the original
--target=<value> flag is preserved in analyzer options, ensuring
the analyzer receives the intended target architecture.

Add a regression test covering the equals-sign syntax and update
the test to satisfy pylint.
@mmido6039
mmido6039 force-pushed the fix-1158-target-equals-sign branch from c12f112 to 0ee5586 Compare August 2, 2026 21:48
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.

Multiple target build with Clang is not handled

1 participant