Build with configure --disable-float fails on newlib/libc/machine/riscv/setjmp.S

685 views
Skip to first unread message

Tommy Murphy

unread,
Oct 31, 2016, 11:59:52 AM10/31/16
to RISC-V SW Dev
Hi there 

I pulled the latest sources from https://github.com/riscv/riscv-gnu-toolchain.
I'm building on CentOS 6.8 32 bit.
About a week ago I pulled the sources configured as follows:

./configure --prefix=`pwd`/toolchain --enable-multilib

and the tools built fine (once I manually applied the patch mentioned here which has since been committed):


Today I configured as follows (because as far as I can see --enable-float is the default):

./configure --prefix=`pwd`/toolchain --enable-multilib --disable-float

but when I build I get this error:

/home/user/Downloads/riscv/sifive/riscv-gnu-toolchain/src/newlib-gcc/newlib/libc/machine/riscv/setjmp.S:22:4: error: #error unsupported FLEN
 #  error unsupported FLEN
    ^~~~~
make[10]: *** [lib_a-setjmp.o] Error 1

Any ideas?
Is it due to this recent change?


It's failing on the #error here in newlib/newlib/libc/machine/riscv/setjmp.S.

#ifndef __riscv_float_abi_soft
/* For ABI uniformity, reserve 8 bytes for floats, even if double-precision
   floating-point is not supported in hardware.  */
# define SZFREG 8
# ifdef __riscv_float_abi_single
#  define FREG_L flw
#  define FREG_S fsw
# elif defined(__riscv_float_abi_double)
#  define FREG_L fld
#  define FREG_S fsd
# else
#  error unsupported FLEN
# endif
#endif


Thanks.
Regards
Tommy

Tommy Murphy

unread,
Oct 31, 2016, 12:21:29 PM10/31/16
to RISC-V SW Dev
This is the current log for setjmp.S:

git log setjmp.S

commit a1e7a925c16f8ff34c5a6d794bfe9b9d5660268f
Author: Andrew Waterman <wate...@cs.berkeley.edu>
Date:   Tue Oct 25 02:06:08 2016 -0700

    Overhaul floating-point command-line arguments
    
    - -march controls which instructions may be emitted, and does not
    affect ABI.
    - -mno-float is equivalent to passing neither F for D to -march;
    -msingle-float is equivalent to passing F but not D to -march;
    and -mdouble-float is equivalent to passing F and D to -march.
    - -mfloat-abi controls which calling convention is used: "soft" means
    no args passed in registers; "single" means only single-precision
    values are passed in regisers; "double" means single- and
    double-precision values are passed in registers.
    - -mfloat-abi defaults to "soft" if the D extension is not present,
    or "double" if it is.
    - GCC will issue an error if -mfloat-abi requires an extension not
    provided by -march, but vice-versa is OK.
    
    Closes #187 (I hope).
    
    @kito-cheng can you test this and let me know what I need to fix?

commit 40ee1d877bfc62e0607bf1a99b57d22ddc59cd22
Author: Andrew Waterman <wate...@cs.berkeley.edu>
Date:   Tue Oct 25 01:48:25 2016 -0700

    Don't save/restore fcsr in setjmp/longjmp (breaks ABI)

etc....

If I revert to the previous commit of setjmp.S the build works OK:

git checkout 40ee1d877bfc62e0607bf1a99b57d22ddc59cd22 setjmp.S 

So the latest commit seems to have broken the build in this specific configuration/context?

Tommy Murphy

unread,
Oct 31, 2016, 1:22:42 PM10/31/16
to RISC-V SW Dev
Another update...

While reverting to the previous version of src/newlib-gcc/newlib/libc/machine/riscv/setjmp.S allows me to build the tools (with --disable-float remember) when I try to build my own programs (with -msoft-float passed when assembling/compiling/linking) I get this at link time:

gcc/bin/../lib/gcc/riscv64-unknown-elf/6.1.0/../../../../riscv64-unknown-elf/lib/32/soft-float/libc.a(lib_a-memset.o): can't link hard-float modules with soft-float modules

I don't understand why given that nothing should be using hard float support?

Andrew Waterman

unread,
Oct 31, 2016, 2:15:58 PM10/31/16
to Tommy Murphy, RISC-V SW Dev
I'm looking into it.

It's generally best to file this sort of thing as an issue on the
github project, so that it can be formally tracked.
> --
> 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/598c01d4-eb4f-4ac8-a7be-1facee48344a%40groups.riscv.org.

Tommy Murphy

unread,
Oct 31, 2016, 2:32:07 PM10/31/16
to RISC-V SW Dev, tommy_...@hotmail.com
Thanks Andrew.
I'll log an issue on the github project.
Apologies - I wasn't aware that that was the best way to flag such issues.

Tommy Murphy

unread,
Oct 31, 2016, 3:48:08 PM10/31/16
to RISC-V SW Dev, tommy_...@hotmail.com

Michael Clark

unread,
Nov 1, 2016, 8:24:31 AM11/1/16
to Tommy Murphy, RISC-V SW Dev
It's also a good idea to discuss on the list.

It's already mentioned in the issue but I wanted to clearly distinguish "-mfloat-abi=soft" from "floating point emulation". -mfloat-abi=soft does not imply floating point emulation.

On ARM -mfloat-abi=soft means emit library calls with integer registers instead of float instructions and float register. The library functions may in fact use hard float (the purpose of -mfloat-abi=softfp).

-mfloat-abi=soft is for faster float emulation when no FPU is present. illegal instruction faults are more expensive than function calls, but this is at the expense of slower float on hardware with an  FPU due to the additional function call overhead. The library routines themselves are typically hard float.

-mfloat-abi=soft would presumably ignore -march FD flags assuming it has the same meaning as ARM, which is to emit library calls.

The soft float support libs a). soft float lib with hard float; would need to be compiled with -mfloat-abi=softfp (see below) and IMAFD, or b). floating point  emulation which doesn't care as it is receiving floats in integer registers and is using only integer code.

Here's the matrix:

  -mfloat-abi=hard, FPU not present: trap and emulate
  -mfloat-abi=hard, FPU present: normal execution
  -mfloat-abi=soft, FPU not present: call floating point emulation library
  -mfloat-abi=soft, FPU present: call hard float wrapper functions.

The rationale is that procedure calls are faster than faulting at the expense of a slow down when FPU is present, for universal binaries targeting IMA and IMAFD.

-mfloat-abi=softfp is the ARM option that changes calling convention to use integer registers but still omits hard float. Actually this option makes sense for the support library as it needs the integer ABI but to emit hard float instructions. This is slightly different to what is currently mentioned on the issue (which doesn't mention -mfloat-abi=softfp).

"
-mfloat-abi=name
Specifies which floating-point ABI to use. Permissible values are: ‘soft’, ‘softfp’ and ‘hard’.

Specifying ‘soft’ causes GCC to generate output containing library calls for floating-point operations. ‘softfp’ allows the generation of code using hardware floating-point instructions, but still uses the soft-float calling conventions. ‘hard’ allows generation of floating-point instructions and uses FPU-specific calling conventions.

The default depends on the specific target configuration. Note that the hard-float and soft-float ABIs are not link-compatible; you must compile your entire program with the same ABI, and link with a compatible set of libraries. 


Sent from my iPhone
--
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/.
Reply all
Reply to author
Forward
0 new messages