Skip to content

Commit a6522f6

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 a6522f6

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Wrapping/macro_files/itk_auto_load_submodules.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ 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= class must accept '.','+','_' to strip extended targets
30+
# like armv8.2-a+fp16 or znver3 as one token (issue #6133).
31+
set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[A-Za-z0-9._+\-]*;-mtune=[A-Za-z0-9._+\-]*;-mfma")
3032
foreach(rmmatch ${INVALID_OPTIMIZATION_FLAGS})
3133
string(
3234
REGEX

0 commit comments

Comments
 (0)