Can RISC-V tools be built to support all float ABIs and emulation/hard FPU options?

680 views
Skip to first unread message

Tommy Murphy

unread,
Nov 9, 2016, 5:06:39 AM11/9/16
to RISC-V SW Dev
Hopefully not a dumb question...

Is it possible to configure the RISC-V gcc/binutils to build libs that support all -mfloat-abi=x (x = soft|single|double|quad) options and have the appropriate libs selected/linked depending on the -mfloat-abi=x flag passed at compilation/link time?
On the other hand I see it mentioned elsewhere that -mfloat-abi=x just determines the ABI/parameter passing method used and not necessarily (or actually?) whether floating point emulation or hard float support is used so maybe I'm still misunderstanding these flags?

I know that configure can take --enable-multilib but that only seems to cause 32 and 64 bit (and eventially 128 bit?) libs to be built with the appropriate libs linked based on the -march and/or (?) -m32/-m63 flags passed at compilation/link time.
Come to think of it when configure is passed --enable-float (which is the default anyway) what lib(s?) does it build - i.e. support for what -mfloat-abi=x options?
When it's passed --disable-float it seems to only build libs that support -mno-float/-float-abi=none?

Thanks a lot.

Kito Cheng

unread,
Nov 9, 2016, 9:21:55 AM11/9/16
to Tommy Murphy, RISC-V SW Dev
That's what multi-lib do as you know, but it's unmaintained for a
while[1] and I guess it's very low priority for Palmer and Andrew :P

[1] https://github.com/riscv/riscv-gnu-toolchain/issues/46
> --
> You received this message because you are subscribed to the Google Groups
> "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sw-dev+un...@groups.riscv.org.
> To post to this group, send email to sw-...@groups.riscv.org.
> Visit this group at
> https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit
> https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/6f71488f-f2ec-4b15-81a8-a9a8a2e2b39a%40groups.riscv.org.

Tommy Murphy

unread,
Nov 9, 2016, 2:50:48 PM11/9/16
to RISC-V SW Dev, tommy_...@hotmail.com
Thanks - you mean --enable-multilib should build ALL variants of libs but doesn't right now?
At the moment it just seems to build 32 and 64 bit variants of the libs.
I'm not sure if/how --enable-multilib interacts (or is supposed to interact) with --enable-float or --disable-float...
At the moment if I want tools/libs that support -mfloat-abi=soft (and floating point emulation - I think) I have to use configure --disable-float and compile/link with -mfloat-abi=soft
But those tools will not work with other -mfloat-abi=x options or use hardware FPU support as far as I know.

Regards
Tommy

Andrew Waterman

unread,
Nov 11, 2016, 2:08:29 AM11/11/16
to Kito Cheng, Tommy Murphy, RISC-V SW Dev
To be clear, we do know this is important... but we view other
outstanding issues in the toolchain as more important. We'll fix
multilibs after addressing the remaining issues on the to-do list.
(One of those items is addressing the redundancy between -march, -m32,
etc., which interacts with multilibs.)
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CA%2ByXCZAqdQCSu-6q_6AHBycdySJBan%2B6bc%3DdCteacpt4BuR%3DQQ%40mail.gmail.com.

Tommy Murphy

unread,
Nov 11, 2016, 4:19:27 AM11/11/16
to RISC-V SW Dev, kito....@gmail.com, tommy_...@hotmail.com
Hi Andrew - OK - thanks for the update on this.
Regards
Tommy

Tommy Murphy

unread,
Nov 28, 2016, 11:41:32 AM11/28/16
to RISC-V SW Dev, kito....@gmail.com, tommy_...@hotmail.com
OK - I'm still confused.
How can I build the tools so that it doesn't try to use any hardware float/FPU support and uses the -mfloat-abi=soft for the compiler and newlib?
I tried configure ... --disable-float but then if I use float logic in my code it generates an internal compiler error.
Do the tools (at https://github.com/riscv/riscv-gcc-toolchain) support this sort of configuration/build or only hardware FPU targets?

Stefan O'Rear

unread,
Nov 28, 2016, 12:14:25 PM11/28/16
to Tommy Murphy, RISC-V SW Dev, kito....@gmail.com
On Mon, Nov 28, 2016 at 8:41 AM, Tommy Murphy <tommy_...@hotmail.com> wrote:
> OK - I'm still confused.
> How can I build the tools so that it doesn't try to use any hardware
> float/FPU support and uses the -mfloat-abi=soft for the compiler and newlib?
> I tried configure ... --disable-float but then if I use float logic in my
> code it generates an internal compiler error.

Apologies if I'm repeating something you've already heard, but
-msoft-float should do what you want (soft-float ABI *and* disable use
of FPU instructions; effectively an alias for -march=rvXXima
-mfloat-abi=soft ).

-s

Tommy Murphy

unread,
Nov 28, 2016, 12:22:22 PM11/28/16
to RISC-V SW Dev, tommy_...@hotmail.com, kito....@gmail.com
Thanks a lot Stefan.
That's what I did but when I try to compile this:

float k;

k
= 10.10;

if (k <= 100.10)
{
      k
= 1.1;
}

I get this:

Building file: ../main.c
Invoking: RISC-V GCC/Newlib C Compiler
riscv64
-unknown-elf-gcc -g3 -gdwarf-2 -m32 -DUSE_PLIC -I"/home/microsemi/RISCV/Softconsole5.0.0.6/SC5.0.0.6/extras/workspace.examples/systick-blinky"
-I"/home/microsemi/RISCV/Softconsole5.0.0.6/SC5.0.0.6/extras/workspace.examples/systick-blinky/drivers/CoreGPIO"
-I"/home/microsemi/RISCV/Softconsole5.0.0.6/SC5.0.0.6/extras/workspace.examples/systick-blinky/drivers/CoreUARTapb"
-I"/home/microsemi/RISCV/Softconsole5.0.0.6/SC5.0.0.6/extras/workspace.examples/systick-blinky/hal"
-I"/home/microsemi/RISCV/Softconsole5.0.0.6/SC5.0.0.6/extras/workspace.examples/systick-blinky/riscv_hal"
-O0 -Wall -c -MMD -MP -MF"main.d" -MT"main.d" -march=RV32IM -mmuldiv -mfloat-abi=soft -o "main.o" "../main.c"
../main.c: In function 'main':
../main.c:81:1: error: unrecognizable insn:
 
}
 
^
(insn 14 13 15 2 (set (reg:SI 83)
       
(le:SI (reg:DF 72 [ _4 ])
           
(reg:DF 81))) ../main.c:55 -1
     
(nil))
../main.c:81:1: internal compiler error: in extract_insn, at recog.c:2287
0x8565dc5 _fatal_insn(char const*, rtx_def const*, char const*, int, char
const*)
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/rtl-error.c:108
0x8565e23 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/rtl-error.c:116
0x853ab1a extract_insn(rtx_insn*)
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/recog.c:2287
0x8363845 instantiate_virtual_regs_in_insn
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/function.c:1582
0x8363845 instantiate_virtual_regs
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/function.c:1950
0x8363845 execute
/home/user/Downloads/riscv/riscv-gnu-toolchain/src/newlib-gcc/gcc/function.c:1999

Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
make
: *** [main.o] Error 1
20:04:01 Build Finished (took 306ms)
Attached the sample code and detail log.


Anybody got any ideas?

Thanks a lot.

Regards
Tommy

Samuel Falvo II

unread,
Nov 28, 2016, 12:26:45 PM11/28/16
to Tommy Murphy, RISC-V SW Dev, kito....@gmail.com
On Mon, Nov 28, 2016 at 9:22 AM, Tommy Murphy <tommy_...@hotmail.com> wrote:
> I get this:
>
> Building file: ../main.c
> Invoking: RISC-V GCC/Newlib C Compiler
> riscv64-unknown-elf-gcc -g3 -gdwarf-2 -m32 -DUSE_PLIC

Regardless of any work-arounds proposed here-after, I would take the
dump's advice and report this as a critical bug at least to the RISC-V
GCC project.

--
Samuel A. Falvo II

Tommy Murphy

unread,
Nov 29, 2016, 4:54:10 AM11/29/16
to RISC-V SW Dev, tommy_...@hotmail.com, kito....@gmail.com
Hi Stefan - I forgot to mention ... the latest tools no longer support -msoft-float, just -mfloat-abi=soft etc.


On Monday, 28 November 2016 17:14:25 UTC, Stefan O'Rear wrote:

Luciano

unread,
May 11, 2017, 12:19:38 PM5/11/17
to RISC-V SW Dev, tommy_...@hotmail.com, kito....@gmail.com
Hi, how are you?

I'm having a similar issue with this same systick-blinky project.

When i'm trying to build  the project it says: riscv64-unknown-elf-gcc: error: unrecognized command line option '-mfloat-abi=soft'

Do you have any idea?

Thanks a lot

Palmer Dabbelt

unread,
May 11, 2017, 1:57:13 PM5/11/17
to lcas...@gmail.com, sw-...@groups.riscv.org, tommy_...@hotmail.com, kito....@gmail.com
The argument names are now "-mabi", "-mtune", and "-march". See my posts in
this thread

https://groups.google.com/a/groups.riscv.org/d/msg/sw-dev/8dae3T-fS8A/z2NHToMlBgAJ

for a longer explination.

Luciano

unread,
May 11, 2017, 3:05:30 PM5/11/17
to RISC-V SW Dev, lcas...@gmail.com, tommy_...@hotmail.com, kito....@gmail.com, pal...@sifive.com
Thanks for your quickly answer but I need some more information. 
When i'm trying to build  the project it says: riscv64-unknown-elf-gcc:  error: unrecognized command line option '-mfloat-abi=soft'

Thanks again

Tommy Murphy

unread,
May 11, 2017, 3:23:30 PM5/11/17
to RISC-V SW Dev
Hi there

That project is for use with SoftConsole v5.1 which we are releasing real soon now. Since v5.0 there have been changes to the RISC-V GCC tools, the command line options for different architectures/extensions/ABIs etc and to other components such as the RISC-V plugin etc.
These changes will be reflected in v5.1 and are also (prematurely!) reflected in the example project on the github.
Please bear with us until we release v5.1 and for now stick to the v5.0 example projects or derivatives of these.

Hope this helps/clarifies?

Regards
Tommy

Reply all
Reply to author
Forward
0 new messages