resolve-march-native icon indicating copy to clipboard operation
resolve-march-native copied to clipboard

-mcpu should be used instead of -march in clang on aarch64

Open ghost opened this issue 8 months ago • 2 comments

resolve-march-native 6.0.1
Python 3.13.3
clang version 19.1.7+libcxx
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/aarch64-unknown-linux-musl-clang.cfg
gentoo-raspberrypi ~ # resolve-march-native --clang --vertical --debug
# clang -E -march=native -### -
Flags extracted: -cc1 -triple aarch64-unknown-linux-musl -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v8.2a -target-feature +crc -target-feature +fp-armv8 -target-feature +lse -target-feature +neon -target-feature +ras -target-feature +rdm -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/root -fcoverage-compilation-dir=/root -resource-dir /usr/lib/llvm/19/bin/../../../../lib/clang/19 -include /usr/include/gentoo/fortify.h -include /usr/include/gentoo/maybe-stddefs.h -internal-isystem /usr/local/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /usr/lib/llvm/19/bin/../../../../lib/clang/19/include -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -target-feature +outline-atomics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c
# clang -E -march=generic -### -
Traceback (most recent call last):
  File "/usr/lib/python3.13/site-packages/resolve_march_native/__main__.py", line 74, in _inner_main
    native_unrolled_flag_set = ClangEngine(options.clang, options.debug).run(options)
  File "/usr/lib/python3.13/site-packages/resolve_march_native/_clang/engine.py", line 63, in run
    march_explicit_flag_set = self._get_march_explicit_flag_set(arch)
  File "/usr/lib/python3.13/site-packages/resolve_march_native/_clang/engine.py", line 44, in _get_march_explicit_flag_set
    return self._get_flag_set([f"-march={arch}"])
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/resolve_march_native/_clang/engine.py", line 33, in _get_flag_set
    p.check_returncode()
    ~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib/python3.13/subprocess.py", line 508, in check_returncode
    raise CalledProcessError(self.returncode, self.args, self.stdout,
                             self.stderr)
subprocess.CalledProcessError: Command '['clang', '-E', '-march=generic', '-###', '-']' returned non-zero exit status 1.
ERROR: Command '['clang', '-E', '-march=generic', '-###', '-']' returned non-zero exit status 1.
gentoo-raspberrypi ~ # clang -E -march=generic -### -
clang version 19.1.7+libcxx
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/aarch64-unknown-linux-musl-clang.cfg
clang: error: unsupported argument 'generic' to option '-march='
 (in-process)
 "/usr/lib/llvm/19/bin/clang-19" "-cc1" "-triple" "aarch64-unknown-linux-musl" "-E" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "-" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "generic" "-target-abi" "aapcs" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/root" "-fcoverage-compilation-dir=/root" "-resource-dir" "/usr/lib/llvm/19/bin/../../../../lib/clang/19" "-include" "/usr/include/gentoo/fortify.h" "-include" "/usr/include/gentoo/maybe-stddefs.h" "-internal-isystem" "/usr/local/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-internal-isystem" "/usr/lib/llvm/19/bin/../../../../lib/clang/19/include" "-ferror-limit" "19" "-fmessage-length=88" "-stack-protector" "2" "-fstack-clash-protection" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-target-feature" "+outline-atomics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "-" "-x" "c" "-"
gentoo-raspberrypi ~ # clang -E -mtune=generic -### -
clang version 19.1.7+libcxx
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/aarch64-unknown-linux-musl-clang.cfg
 (in-process)
 "/usr/lib/llvm/19/bin/clang-19" "-cc1" "-triple" "aarch64-unknown-linux-musl" "-E" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "-" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "generic" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-abi" "aapcs" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/root" "-fcoverage-compilation-dir=/root" "-resource-dir" "/usr/lib/llvm/19/bin/../../../../lib/clang/19" "-include" "/usr/include/gentoo/fortify.h" "-include" "/usr/include/gentoo/maybe-stddefs.h" "-internal-isystem" "/usr/local/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-internal-isystem" "/usr/lib/llvm/19/bin/../../../../lib/clang/19/include" "-ferror-limit" "19" "-fmessage-length=88" "-stack-protector" "2" "-fstack-clash-protection" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-target-feature" "+outline-atomics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "-" "-x" "c" "-"
gentoo-raspberrypi ~ # clang -E -mcpu=generic -### -
clang version 19.1.7+libcxx
Target: aarch64-unknown-linux-musl
Thread model: posix
InstalledDir: /usr/lib/llvm/19/bin
Configuration file: /etc/clang/aarch64-unknown-linux-musl-clang.cfg
 (in-process)
 "/usr/lib/llvm/19/bin/clang-19" "-cc1" "-triple" "aarch64-unknown-linux-musl" "-E" "-disable-free" "-clear-ast-before-backend" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "-" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-mframe-pointer=non-leaf" "-ffp-contract=on" "-fno-rounding-math" "-mconstructor-aliases" "-funwind-tables=2" "-target-cpu" "generic" "-target-feature" "+v8a" "-target-feature" "+ete" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+trbe" "-target-abi" "aapcs" "-debugger-tuning=gdb" "-fdebug-compilation-dir=/root" "-fcoverage-compilation-dir=/root" "-resource-dir" "/usr/lib/llvm/19/bin/../../../../lib/clang/19" "-include" "/usr/include/gentoo/fortify.h" "-include" "/usr/include/gentoo/maybe-stddefs.h" "-internal-isystem" "/usr/local/include" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-internal-isystem" "/usr/lib/llvm/19/bin/../../../../lib/clang/19/include" "-ferror-limit" "19" "-fmessage-length=88" "-stack-protector" "2" "-fstack-clash-protection" "-fno-signed-char" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf" "-fcolor-diagnostics" "-target-feature" "+outline-atomics" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "-" "-x" "c" "-"

https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html

-mcpu=cpu-type ¶

A deprecated synonym for -mtune. 

https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html

-mcpu=name ¶

Specify the name of the target processor, 
optionally suffixed by one or more feature 
modifiers. This option has the form 
-mcpu=cpu{+[no]feature}*, where the 
permissible values for cpu are the same as 
those available for -mtune. The permissible 
values for feature are documented in the 
sub-section on -march and -mcpu Feature 
Modifiers. Where conflicting feature modifiers 
are specified, the right-most feature is used. 

GCC uses name to determine what kind of 
instructions it can emit when generating 
assembly code (as if by -march) and to 
determine the target processor for which to 
tune for performance (as if by -mtune). Where 
this option is used in conjunction with -march 
or -mtune, those options take precedence over 
the appropriate part of this option. 

-mcpu=neoverse-512tvb is special in that it 
does not refer to a specific core, but instead 
refers to all Neoverse cores that (a) implement 
SVE and (b) have a total vector bandwidth of 
512 bits a cycle. Unless overridden by -march, 
-mcpu=neoverse-512tvb generates code that 
can run on a Neoverse V1 core, since Neoverse 
V1 is the first Neoverse core with these 
properties. Unless overridden by -mtune, 
-mcpu=neoverse-512tvb tunes code in the 
same way as for -mtune=neoverse-512tvb. 

https://community.arm.com/arm-community-blogs/b/tools-software-ides-blog/posts/compiler-flags-across-architectures-march-mtune-and-mcpu

Compared to x86_64, the compiler on aarch64 seems to behave quite differently. x86_64 prefers -march/-mtune, while aarch64 prefers -mcpu.

ghost avatar May 06 '25 05:05 ghost