Skip to content

Commit dd09e8f

Browse files
committed
BUG: Allow '.' and '+' in -march/-mtune strip regex (issue #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.
1 parent ccb17dc commit dd09e8f

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

Wrapping/macro_files/itk_auto_load_submodules.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@ function(generate_castxml_commandline_flags)
2525
set(_castxml_cc_flags "${_castxml_cc_flags} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}")
2626
endif()
2727

28-
# Aggressive optimization flags cause cast_xml to give invalid error conditions
29-
set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[a-zA-Z0-9\-]*;-mtune=[a-zA-Z0-9\-]*;-mfma")
28+
# Aggressive optimization flags cause cast_xml to give invalid error conditions.
29+
# The -march=/-mtune= character class must accept '.', '+', and '_' so that
30+
# extended ARM/x86 targets such as -march=armv8.2-a+fp16+rcpc+dotprod+crypto
31+
# or -march=znver3 are stripped as a single token. The previous class
32+
# [a-zA-Z0-9\-]* stopped at the first '.' or '+', leaving a dangling tail
33+
# (e.g. ".2-a+fp16+rcpc+dotprod+crypto") that clang then misinterpreted as
34+
# a positional file argument. See InsightSoftwareConsortium/ITK#6133.
35+
set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[A-Za-z0-9._+\-]*;-mtune=[A-Za-z0-9._+\-]*;-mfma")
3036
foreach(rmmatch ${INVALID_OPTIMIZATION_FLAGS})
3137
string(
3238
REGEX

0 commit comments

Comments
 (0)