From: Richard Earnshaw Date: Wed, 11 Sep 2024 16:06:12 +0000 (+0100) Subject: arm: Allow -mcpu and -march options to be unset X-Git-Tag: basepoints/gcc-16~5947 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7d6c6a0d15c136a68d066c60da0f48265a2b1886;p=thirdparty%2Fgcc.git arm: Allow -mcpu and -march options to be unset The compiler will warn if the architectural specification derived from a -mcpu option is not the same as that specified by -march. This is because it was never intended that the two should be used at the same time: -mcpu= is supposed to be shorthand for -mtune= -march=arch-of(). Unfortunately, there are times when the two options passed to the compiler may come from distinct sources: one example is makefiles which accumulate options; another is the testsuite itself, when some tests require a particular architecture setting to be useful - only running the tests when the compiler/testsuite configuration exactly matched the requirements would make regression testing especially hard (we have too many permutations). So this patch allows a user to cancel any earlier setting of a particular flag and to make the compiler behave as though it was never passed. The intended usecase is (sources of options are shown in parenthesis, but that's just for grouping: (-march=armv7-a+simd) (-march=unset -mcpu=cortex-m33) The option processing logic will now simplify this to: -mcpu=cortex-m33 A useful corollary of this is that -march=armv7-a -march=unset will now cause the compiler to behave as though neither the architecture nor the CPU was ever set and to default back to the configure-time settings. gcc/ChangeLog: * config/arm/arm.h (OPTION_DEFAULT_SPECS): Allow -mcpu and -march to be unset. (ARCH_CPU_CLEANUP_SPECS): Likewise (DRIVER_SELF_SPECS): Add ARCH_CPU_CLEANUP_SPECS * doc/invoke.texi (arm: -mcpu= and -march=): Document use of 'unset'. --- diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 0cd5d733952..b092ba6ffe0 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -394,9 +394,11 @@ emission of floating point pcs attributes. */ TARGET_MODE_CHECK that also takes into account the selected CPU and architecture. */ #define OPTION_DEFAULT_SPECS \ - {"arch", "%{!march=*:%{!mcpu=*:-march=%(VALUE)}}" }, \ - {"cpu", "%{!march=*:%{!mcpu=*:-mcpu=%(VALUE)}}" }, \ - {"tune", "%{!mcpu=*:%{!mtune=*:-mtune=%(VALUE)}}" }, \ + {"arch", "%{!march=*|march=unset:"\ + "%{!mcpu=*|mcpu=unset:%