llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.65k stars 11.84k forks source link

[ARM] clang/LLVM silently switches to the soft-float ABI if an FPU-less CPU is specified for a hard-float target #110383

Open chrisnc opened 3 weeks ago

chrisnc commented 3 weeks ago

In GCC, this is treated as an error, because the chosen CPU cannot implement the ABI that has been requested.

https://godbolt.org/z/89YGKW79P

RalfJung commented 3 weeks ago

X86 has a similar issue, where -x87 on a typical hard-float target will silently switch to the soft-float ABI. IMO it'd be better to error there, too, so that an explicit +soft-float is required to use the soft-float ABI -- that avoids nasty surprises where code doesn't use the ABI it is expected to use.

llvmbot commented 3 weeks ago

@llvm/issue-subscribers-clang-driver

Author: Chris Copeland (chrisnc)

In GCC, this is treated as an error, because the chosen CPU cannot implement the ABI that has been requested. https://godbolt.org/z/89YGKW79P
llvmbot commented 2 weeks ago

@llvm/issue-subscribers-backend-arm

Author: Chris Copeland (chrisnc)

In GCC, this is treated as an error, because the chosen CPU cannot implement the ABI that has been requested. https://godbolt.org/z/89YGKW79P
RalfJung commented 2 weeks ago

Yeah, that makes sense. Ideally it would be an error in llvm as well, in a way that the logic does not live in clang but can be reused by other frontends.

RalfJung commented 2 weeks ago

A similar issue exists with target features: if I pass -fpregs to createTargetMachine, it will silently change the ABI. I would expect an error saying that the registers are missing for this ABI. If I pass +soft-float,-fpregs, then everything is fine as I explicitly asked for the ABI change.

chrisnc commented 2 weeks ago

@RalfJung I believe the PR I have linked to this issue https://github.com/llvm/llvm-project/pull/111334 will address that case as well (for Arm at least). If the hard-float ABI is used but the fpregs feature isn't present, it errors out. I'll confirm this later.

RalfJung commented 2 weeks ago

That would be great :)