From a6522f62449a279c1a67cf1d56103999426de277 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Tue, 28 Apr 2026 07:50:20 -0500 Subject: [PATCH] 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. --- Wrapping/macro_files/itk_auto_load_submodules.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Wrapping/macro_files/itk_auto_load_submodules.cmake b/Wrapping/macro_files/itk_auto_load_submodules.cmake index a5f0afea87e..0bb618fad11 100644 --- a/Wrapping/macro_files/itk_auto_load_submodules.cmake +++ b/Wrapping/macro_files/itk_auto_load_submodules.cmake @@ -25,8 +25,10 @@ function(generate_castxml_commandline_flags) set(_castxml_cc_flags "${_castxml_cc_flags} ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}") endif() - # Aggressive optimization flags cause cast_xml to give invalid error conditions - set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[a-zA-Z0-9\-]*;-mtune=[a-zA-Z0-9\-]*;-mfma") + # Aggressive optimization flags cause cast_xml to give invalid error conditions. + # The -march=/-mtune= class must accept '.','+','_' to strip extended targets + # like armv8.2-a+fp16 or znver3 as one token (issue #6133). + set(INVALID_OPTIMIZATION_FLAGS "-fopenmp;-march=[A-Za-z0-9._+\-]*;-mtune=[A-Za-z0-9._+\-]*;-mfma") foreach(rmmatch ${INVALID_OPTIMIZATION_FLAGS}) string( REGEX