Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: switch '-mcpu=cortex-a76' conflicts with '-march=armv8-a+sve' switch #2080

Open
vmsh0 opened this issue Dec 9, 2023 · 7 comments
Open

Comments

@vmsh0
Copy link

vmsh0 commented Dec 9, 2023

  • This is crosstool-NG version 1.26.0
  • Arch Linux rolling (gcc version 13.2.1 20230801 (GCC))

build.log.gz (~35MB uncompressed)
dot_config.txt

Hey there,

Trying to compile a 64-bit toolchain for the new RPi 5 (aarch64-rpi5-linux-gnu). I'm not sure how the official one is set up, but I would be happy with anything with -mcpu=cortex-a76. Except, when I attempt to do just that, my build fails with

[...]
[INFO ]    Building for multilib 1/1: ''
[EXTRA]      Configuring C library
[EXTRA]      Building C library
[ERROR]      cc1: error: switch '-mcpu=cortex-a76' conflicts with '-march=armv8-a+sve' switch [-Werror]
[ERROR]      make[3]: *** [/home/random/x-tools/.build/aarch64-rpi5-linux-gnu/build/build-libc/multilib/sysd-rules:383: /home/random/x-tools/.build/aarch64-rpi5-linux-gnu/build/build-libc/multilib/mathvec/cosf_sve.o] Error 1
[ERROR]      make[3]: *** Waiting for unfinished jobs....
[ERROR]      make[2]: *** [Makefile:484: mathvec/others] Error 2
[ERROR]      make[1]: *** [Makefile:9: all] Error 2
[ERROR]
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Building for multilib 1/1: '''
[ERROR]  >>        called in step 'Installing C library'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@377]
[ERROR]  >>        called from: glibc_backend_once[scripts/build/libc/glibc.sh@268]
[ERROR]  >>        called from: CT_IterateMultilibs[scripts/functions@1608]
[ERROR]  >>        called from: glibc_main[scripts/build/libc/glibc.sh@26]
[ERROR]  >>        called from: do_libc_main[scripts/build/libc.sh@33]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@697]
[ERROR]  >>
[...]
[ERROR]
[ERROR]  (elapsed: 20:54.55)
[20:56] / make: *** [/usr/bin/ct-ng:261: build] Error 2

I.e. it looks like something is attempting to set -march=armv8-a+sve. Not sure how or why, as sve isn't even one of the documented extensions for ARM (although it's definitely an ARMv8 extension, and I read it's been supported in GCC for a while - so not completely sure what's going on here). This might have something to do with #963.

I have also tried to build with CT_ARCH_ARCH="armv8.2-a", with and without also specifying the CPU. When still specifying the CPU, the wrong -march flag gets set again. When not specifying the CPU however the build succeeds. (But I haven't tested it just yet.)

If this is something that's happening inside crosstool-NG, it should imho be fixed, as setting the CPU is in my view preferable - as it's a relatively high-level information encompassing architecture, extensions, etc, then leaving the compiler to expertly decide how to configure itself to emit the best possible code.

If not, could you help me understand when and how this happens, so that I can contact the relevant people?

Thank you!

@cpackham
Copy link
Contributor

cpackham commented Dec 9, 2023

The Aarch64 options are documented separately. You'll find them at https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html. +sve is listed there (as is cortex-a76)

armv8-a+sve is not something ct-ng is adding (as far as I can tell). It might be another case like #963 where gcc/glibc is doing something internally that conflicts with the options being passed for --with-cpu.

The regular aarch64-unknown-linux-gnu should be fine for the rpi5 (although I've not personally tried it). If you want to squeeze out some extra performance you can always pass -mcpu=cortex-a76 when building your application.

@cpackham
Copy link
Contributor

I think the flag is coming from https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/aarch64/fpu/Makefile#l33 I can make your config work if I unset CT_GLIBC_ENABLE_WERROR. Not sure about the resulting toolchain, I've got nothing to test it on.

@QBos07
Copy link
Contributor

QBos07 commented Dec 10, 2023

From what i've see the flag is only used by the vector math lib. Maybe disabling that fixes it?

@feugatos
Copy link

Hi,

I was just trying to build a toolchain for RPI5 and bumped into this exact same issue.
Is there any update concerning this?

Thanks.

@feugatos
Copy link

After some digging I found the cpu definition in GCC: https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.2.0/gcc/config/arm/arm-cpus.in#L1462

So I'm guessing -mcpu=cortex-a76 corresponds to -march=armv8.2-a+fp16+dotprod and -mtune=cortex-a57

@maveric2
Copy link

Same issue here - this is what i did:

  • load aarch64-rpi4-linux-gnu config
  • mod. cortex-a72 to cortex-a76
  • mod. rpi4 to rpi5
    build -> c1: error: switch '-mcpu=cortex-a76' conflicts with '-march=armv8-a+sve' switch

@maveric2
Copy link

Not sure, but is it about this patch:
crosstool-ng\packages\glibc\2.39\0001-aarch64-configure-Pass-mcpu-along-with-march-to-dete.patch
where -march=armv8.2-a+sve is set.
I guess there -march=armv8.2-a should work.

However is there a option to configure with menuconfig or within the DOTconfig file to override the -march option?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants