How to tell linker to use minimum ISA?

Jeffrey Walton noloader@gmail.com
Wed Oct 16 20:51:00 GMT 2019


On Wed, Oct 16, 2019 at 4:31 PM Ramana Radhakrishnan
<ramana.gcc@googlemail.com> wrote:
>
> On Wed, Oct 16, 2019 at 8:54 PM Jeffrey Walton <noloader@gmail.com> wrote:
> >
> > I have object files from different ISAs. The higher ISAs are guarded
> > at runtime though getauxval.
> >
> > Compile is OK. For example:
> >
> >     a.o  # -march=armv7a
> >     b_simd.o  # -march=armv7a -mfpu=vfpv3-d16 -mfpu=neon
>
> What is your compiler / toolchain configured as ? $PREFIX-gcc will
> give you the answer.

$ arm-linux-androideabi-ld --version
GNU gold (GNU Binutils 2.27.0.20170315) 1.12
Copyright (C) 2016 Free Software Foundation, Inc.

And:

$ armv7a-linux-androideabi23-clang++ --version
Android (5058415 based on r339409) clang version 8.0.2
(https://android.googlesource.com/toolchain/clang
40173bab62ec746213857d083c0e8b0abb568790)
(https://android.googlesource.com/toolchain/llvm
7a6618d69e7e8111e1d49dc9e7813767c5ca756a) (based on LLVM 8.0.2svn)
Target: armv7a-unknown-linux-android23

> > On Android link is failing when using only -march=armv7a with:
> >
> >     .../arm-linux-androideabi/bin/ld: error: aria_simd.o uses VFP
> > register arguments, output does not
>
> Is aria_simd.o compiled with -mfloat-abi=hard ?

Oh, this could be the problem. I had a typo that added hard floats to
non-NEON source files. It came from reusing a makefile used for Debian
ARM. Debian ARM uses hard floats.

> > To fix it I need to add -march=armv7a -mfpu=vfpv3-d16 -mfpu=neon to LDFLAGS.
>
> That seems very odd.
>
> > I'm concerned the linker may want to perform optimizations, especially
> > now that LTO is becoming more popular. That could cause a lot of
> > problems, especially if the linker uses the wrong ISA.
> >
> > How do I tell the linker to use the minimum ISA, and not the ISA I am using?
>
> Firstly it's not because of the ISA levels you are getting the error,
> it's because you are mixing calling conventions. At object file levels
> you cannot mix object files compiled for one pcs against object files
> compiled for a different pcs. i.e. floating point values are sent in
> FP registers in one object file because it was compiled with the VFP
> PCS in mind while the other one expects this in integer registers
> because it was compiled for the base PCS .

Thanks Ramana.

Cancel the request.

Jeff



More information about the Binutils mailing list