This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GCC with Cortex-M4 hard float link error "X uses VFP register arguments, Y does not"


On 22 August 2012 22:07, Johannes Bauer <dfnsonfsduifb@gmx.de> wrote:
> On 22.08.2012 22:24, Matthew Gretton-Dann wrote:
>
>>>> 1) How have you configured GCC? (What does gcc -v show?)
>>>
>>> Using built-in specs.
>>> COLLECT_GCC=arm-none-eabi-gcc
>>> COLLECT_LTO_WRAPPER=/home/joe/bin/arm/libexec/gcc/arm-none-eabi/4.7.1/lto-wrapper
>>> Target: arm-none-eabi
>>> Configured with: ../configure --prefix=/home/joe/bin/arm/
>>> --enable-interwork --enable-multilib --with-newlib
>>> --with-headers=/tmp/newlib-1.19.0/newlib/libc/include
>>> --target=arm-none-eabi --disable-nls --disable-shared --disable-threads
>>> --with-gnu-ld --with-gnu-as --disable-libssp --disable-libmudflap
>>> --disable-libgomp --with-dwarf2 -v --disable-werror --with-cpu=cortex-m3
>>> --with-cpu=cortex-m4 --with-tune=cortex-m3 --with-tune=cortex-m4
>>> --with-mode=thumb --enable-target-optspace --with-float=hard
>>> --with-float=soft --enable-languages=c,c++
>>> Thread model: single
>>> gcc version 4.7.1 (GCC)
>>
>> The multiple --with-cpu/--with-tune/--with-float options are
>> confusing, although probably OK as 'rightmost' should win.
>
> Ah okay, interesting. I was deliberately adding both because I work with
> both the Cortex-M3 and Cortex-M4 and wanted to build one GCC that works
> for both. Is this not possible? It wouldn't be a problem to build
> different gccs (only inconvenient), but that would be very good to know
> (if it's at all possible).

The configure option --with-cpu=, --with-fpu=, &c specify the defaults
GCC should use if no options are specified on the command line (-mcpu,
-mfpu, &c).  So you can specify different cores when building.

The issue comes with building different multilibs for the different
cores.  This is possible, but difficult to explain, and can involve
changing bits of the GCC source.  So, I will point you in the
direction of the ARM Embedded release of GCC:
https://launchpad.net/gcc-arm-embedded.  This is targetted at
M-profile cores, and provides appropriate multi-libs.  If its
appropriate you can use what they provide - there are binaries and
instructions on how to build from source available.

>> You only need one of each of --with-cpu, --with-tune, and
>> --with-float.  [As an aside --with-cpu implies --with-tune for the
>> same CPU].
>>
>> What I think you are missing is a default FPU though.  Add
>> --with-fpu=fpv4-sp-d16 to the configure line, and that should help.
>>
>> In summary I think you want the following --with-* options on your command line:
>>
>>    --with-cpu=cortex-m4 --with-fpu=fpv4-sp-d16 --with-mode=thumb
>> --with-float=soft
>
> Okay, I'm rebuilding right now. Curious though, since you specified
> "--with-float=soft" -- at the moment, softfloat is working (actually
> it's the only thing working), so what exactly does "with-float=soft" do
> in conjunction with a default FPU specification? I find the options kind
> of confusing to be honest and don't really know what they do exactly.

-mcpu/--with-cpu, -mfpu/--with-fpu, -mfloat-abi/--with-float are,
generally, orthogonal options:

 -mcpu/--with-cpu selects the integer side instruction set available.
 -mfpu/--with-fpu selects the FP/Advanced SIMD/WMMX instruction set available.
 -mfloat-abi/--with-float selects how floating-point instructions may be used.

The manual gives full details, but in summary:

 * -mfloat-abi=soft means don't use any Floating-Point instructions
anywhere, simulate them with integer side instructions.
 * -mfloat-abi=softfp means you can use FP instructions, but still use
the standard calling convention which passes float/double arguments in
integer registers.
 * -mfloat-abi=hard means you can use FP instructions, and the calling
convention changes to pass float/double arguments in S/D registers.

Thanks,

Matt

-- 
Matthew Gretton-Dann
Linaro Toolchain Working Group
matthew.gretton-dann@linaro.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]