BUG: Allow . and + in -march/-mtune strip regex (issue #6133, backport to release-5.4)#6157
Conversation
|
| Filename | Overview |
|---|---|
| Wrapping/macro_files/itk_auto_load_submodules.cmake | Widens the -march=/-mtune= strip regex character class to include '.', '+', and '_', fixing truncation of extended ARM/x86 micro-architecture strings that caused clang to misinterpret the dangling suffix as a file argument. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["CMAKE_CXX_FLAGS e.g.<br/>-march=armv8.2-a+fp16+rcpc+dotprod+crypto -O2"] --> B["REGEX REPLACE loop over<br/>INVALID_OPTIMIZATION_FLAGS"]
B --> C1["-fopenmp → stripped"]
B --> C2["-march=[A-Za-z0-9._+\-]* → stripped (entire token)"]
B --> C3["-mtune=[A-Za-z0-9._+\-]* → stripped (entire token)"]
B --> C4["-mfma → stripped"]
C1 & C2 & C3 & C4 --> D["Cleaned _castxml_cc_flags<br/>e.g. -O2"]
D --> E["separate_arguments → passed to castxml"]
style C2 fill:#d4edda,stroke:#28a745
style C3 fill:#d4edda,stroke:#28a745
Reviews (1): Last reviewed commit: "BUG: Allow '.' and '+' in -march/-mtune ..." | Re-trigger Greptile
…twareConsortium#6133) Backport of the main-branch fix to release-5.4 for inclusion in 5.4.7. The aggressive optimization flag stripping in generate_castxml_commandline_flags() must remove -march=/-mtune= arguments before feeding the compiler line to castxml, because castxml's bundled clang preprocessor does not accept all backend target features. The previous regex character class [a-zA-Z0-9\-]* stopped at the first non-alphanumeric, non-hyphen character, so extended target descriptors silently lost their tail: -march=armv8.2-a+fp16+rcpc+dotprod+crypto ^^^^^^^^^ <-- only this much matched ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- this remained verbatim The leftover fragment ".2-a+fp16+rcpc+dotprod+crypto" was then passed to clang as a positional argument, producing: clang++: error: no such file or directory: '.2-a+fp16+rcpc+dotprod+crypto' Reported on Arch Linux aarch64 against ITK 5.4.6. The same class of breakage applies to extended x86 names like -march=znver3 or -march=skylake-avx512. Extend the character class to [A-Za-z0-9._+\-]* so the entire token is matched and stripped.
dd09e8f to
a6522f6
Compare
f265b15
into
InsightSoftwareConsortium:release-5.4
Backport of the main-branch fix for #6133 to
release-5.4, slated for inclusion in 5.4.7. One-line regex tweak inWrapping/macro_files/itk_auto_load_submodules.cmake.On Arch Linux aarch64 with
CXXFLAGS="-march=armv8.2-a+fp16+rcpc+dotprod+crypto", the strip regex-march=[a-zA-Z0-9\-]*matched only thearmv8prefix and left.2-a+fp16+rcpc+dotprod+cryptodangling — clang then read it as a positional file and failed:Widen the class to
[A-Za-z0-9._+\-]*so the entire-march=/-mtune=token is consumed.Why a separate backport PR (rather than auto-cherry-pick)
release-5.4's copy of the file uses the older single-line CMake formatting (pre-gersemi), so the line-level diff differs from main even though the change is semantically identical. The fix on main lands separately onmainagainst the gersemi-formatted file.Verification
Same minimal CMake regex repro as the main-branch PR confirms the buggy class drops the dangling tail and the fixed class consumes it cleanly. No build/test changes; this is a configure-time string tweak with no API/ABI impact.
Cross-reference: