Page MenuHomePhabricator

[Driver] Incorporate -mfloat-abi in the computed triple on ARM
ClosedPublic

Authored by john.brawn on Oct 16 2020, 11:14 AM.

Details

Summary

LLVM assumes that when it creates a call to a C library function it can use the C calling convention. On ARM the effective calling convention is determined from the target triple, however using -mfloat-abi=hard on ARM means that calls to (and definitions of) C library functions use the arm_aapcs_vfpcc calling convention which can result in a mismatch.

Fix this by incorporating -mfloat-abi into the target triple, similar to how -mbig-endian and -march/-mcpu are. This only works for EABI targets and not Android or iOS, but there the float abi is fixed so instead give an error.

Fixes PR45524.

Diff Detail

Event Timeline

john.brawn created this revision.Oct 16 2020, 11:14 AM
efriedma added inline comments.Oct 16 2020, 2:07 PM
clang/lib/Driver/ToolChain.cpp
807

Do we want to error in the "default" case? Not that anyone is likely to use -mfloat-abi on those targets, but I'd prefer not to silently miscompile.

john.brawn edited the summary of this revision. (Show Details)

Adjusted to give an error when the specified float abi is incompatible with the default. Was a bit trickier than I expected as it required extracting out the logic to determine the default into a separate function (we could instead emit the error in arm::getARMFloatABI but then it would be emitted several times as the function is called from several places).

This revision is now accepted and ready to land.Oct 20 2020, 1:56 PM