arch/or1k: fix uClibc issues with fenv enabled
PATCH 1/1 arch/or1k: fix uClibc issues with fenv enabled
OpenRISC architecture can be either soft-float or hard-float, so add the ability to the user to configure it.
GNU libc has hard-float support since 03 May 2024, see here:
https://sourceware.org/pipermail/glibc-cvs/2024q2/085211.html
There fenv functions f.e. were added to glibc.
uClibc-ng has added fenv functions in commit 8a77b4785acd143d76ccc08142abb39c0100de3d on 27 April 2025.
musl does not have any or1k architecture specific fenv support.
Tested with all 6 combinations of C libraries and float configurations.
For uClibc-ng fenv support was enabled by commit 4c5039b80ebbe42db35af189afcff7fb7d5cace6 in Buildroot for any hard-float toolchain, so we now need to pass -mhard-float to gcc compiler to get the predefined preprocessor macro __or1k_hard_float__, which exposes _FPU_FPCSR_RM_MASK.
Fixes:
- https://autobuild.buildroot.org/results/a60737adf3fdd26e8d0ae3310bef5c48716889dc
--- arch/Config.in.or1k | 9 +++++++++ package/Makefile.in | 8 ++++++++ 2 files changed, 17 insertions(+)
arch/Config.in.or1k +9 -0
@@ -1,3 +1,12 @@ +config BR2_OR1K_SOFT_FLOAT + bool "Use soft-float" + select BR2_SOFT_FLOAT + help + If your target CPU does not have a Floating Point Unit (FPU) + or a kernel FPU emulator, but you still wish to support + floating point functions, then everything will need to be + compiled with soft floating point support (-msoft-float). + config BR2_ARCH default "or1k"
package/Makefile.in +8 -0
@@ -106,6 +106,14 @@ TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc endif endif +# use hard-float option globally for OpenRISC, when not +# soft-float choosen by the user. +ifeq ($(BR2_or1k),y) +ifneq ($(BR2_OR1K_SOFT_FLOAT),y) +TARGET_ABI += -mhard-float +endif +endif + # Use longcalls option for Xtensa globally. # The 'longcalls' option allows calls across a greater range of addresses, # and is required for some packages. While this option can degrade both
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Waldemar,
Quoted 7 lines · Waldemar Brodkorb
OpenRISC architecture can be either soft-float or hard-float, so add the ability to the user to configure it.
GNU libc has hard-float support since 03 May 2024, see here:
https://sourceware.org/pipermail/glibc-cvs/2024q2/085211.html
There fenv functions f.e. were added to glibc.
Quoted 6 lines
uClibc-ng has added fenv functions in commit
8a77b4785acd143d76ccc08142abb39c0100de3don 27 April 2025.musl does not have any or1k architecture specific fenv support.
Tested with all 6 combinations of C libraries and float configurations.
Are you sure? I don't see how your patch solves the soft-float configuration.
arch/Config.in.or1k line 3
Quoted 8 lines
arch/Config.in.or1k +3
-0@@ -1,3 +1,12 @@ +config BR2_OR1K_SOFT_FLOAT + bool "Use soft-float" + select BR2_SOFT_FLOAT
This should be "default y", to preserve existing behavior.
Quoted 14 lines
arch/Config.in.or1k +6
-0+ help + If your target CPU does not have a Floating Point Unit (FPU) + or a kernel FPU emulator, but you still wish to support + floating point functions, then everything will need to be + compiled with soft floating point support (-msoft-float). + config BR2_ARCH default "or1k"package/Makefile.in +0
-0
package/Makefile.in TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc · line 115
Quoted 10 lines
package/Makefile.in +7
-0@@ -106,6 +106,14 @@ TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc endif endif +# use hard-float option globally for OpenRISC, when not +# soft-float choosen by the user. +ifeq ($(BR2_or1k),y) +ifneq ($(BR2_OR1K_SOFT_FLOAT),y) +TARGET_ABI += -mhard-float +endif +endif
This needs somehow to go in the toolchain wrapper, so instead of your change, you would need something like this:
package/gcc/gcc.mk +4 -0
@@ -212,6 +212,10 @@ ifeq ($(BR2_SOFT_FLOAT),y) ifeq ($(BR2_arm)$(BR2_armeb)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),y) HOST_GCC_COMMON_CONF_OPTS += --with-float=soft endif +else +ifeq ($(BR2_or1k),y) +HOST_GCC_COMMON_CONF_OPTS += --with-float=hard +endif endif # Determine arch/tune/abi/cpu options
toolchain/toolchain-external/pkg-toolchain-external.mk +3 -0
@@ -243,6 +243,9 @@ TOOLCHAIN_EXTERNAL_CFLAGS += $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) ifeq ($(BR2_SOFT_FLOAT),y) TOOLCHAIN_EXTERNAL_CFLAGS += -msoft-float TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_SOFTFLOAT=1 +else ifeq ($(BR2_or1k),y) +TOOLCHAIN_EXTERNAL_CFLAGS += -mhard-float +TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += -DBR_HARDFLOAT=1 endif TOOLCHAIN_EXTERNAL_TOOLCHAIN_WRAPPER_ARGS += \
toolchain/toolchain-wrapper.c +3 -0
@@ -61,6 +61,9 @@ static char *predef_args[] = {#ifdef BR_SOFTFLOAT "-msoft-float",#endif /* BR_SOFTFLOAT */ +#ifdef BR_HARDFLOAT + "-mhard-float", +#endif /* BR_HARDFLOAT */ #ifdef BR_SIMD "-msimd=" BR_SIMD,#endif
But more importantly, I don't see how your patch fixes the soft float situation. My understanding is that soft-float is the default on OR1K. Your patch doesn't change *anything* in soft-float configuration, it only passes -mhard-float in hard float configurations, and makes hard float the default.
How can your patch fix anything with BR2_OR1K_SOFT_FLOAT enabled?
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello,
Quoted 7 lines · Thomas Petazzoni
But more importantly, I don't see how your patch fixes the soft float situation. My understanding is that soft-float is the default on OR1K. Your patch doesn't change *anything* in soft-float configuration, it only passes -mhard-float in hard float configurations, and makes hard float the default.
How can your patch fix anything with
BR2_OR1K_SOFT_FLOATenabled?
Sorry for my mistake, but re-reading, I know understand:BR2_OR1K_SOFT_FLOAT selects BR2_SOFT_FLOAT, and based on that uClibc uses or doesn't use hard-float fenv stuff. That makes sense.
Still the patch seems incorrect to me, and should modify gcc.mk and the toolchain external stuff instead.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas,
Thomas Petazzoni wrote,
Quoted 10 lines
Hello,
Quoted 6 lines · Thomas Petazzoni
But more importantly, I don't see how your patch fixes the soft float situation. My understanding is that soft-float is the default on OR1K. Your patch doesn't change *anything* in soft-float configuration, it only passes -mhard-float in hard float configurations, and makes hard float the default.
Quoted 8 lines
Quoted 1 line
How can your patch fix anything with
BR2_OR1K_SOFT_FLOATenabled?Sorry for my mistake, but re-reading, I know understand:
BR2_OR1K_SOFT_FLOATselectsBR2_SOFT_FLOAT, and based on that uClibc uses or doesn't use hard-float fenv stuff. That makes sense.Still the patch seems incorrect to me, and should modify gcc.mk and the toolchain external stuff instead.
As I stated in my other mail --with-float is not available for gcc on or1k. How should I proceed? How does the toolchain-wrapper recognizes the user wants a hard-float toolchain?
For the external toolchains I understand it, but not for the internal BR toolchains.
best regards
Waldemar
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Thomas,
Thomas Petazzoni wrote,
Quoted 64 lines
Hello Waldemar,
Quoted 7 lines · Waldemar Brodkorb
OpenRISC architecture can be either soft-float or hard-float, so add the ability to the user to configure it.
GNU libc has hard-float support since 03 May 2024, see here:
https://sourceware.org/pipermail/glibc-cvs/2024q2/085211.html
There fenv functions f.e. were added to glibc.Quoted 6 lines
uClibc-ng has added fenv functions in commit
8a77b4785acd143d76ccc08142abb39c0100de3don 27 April 2025.musl does not have any or1k architecture specific fenv support.
Tested with all 6 combinations of C libraries and float configurations.
Are you sure? I don't see how your patch solves the soft-float configuration.
arch/Config.in.or1k line 3
Quoted 8 lines
arch/Config.in.or1k +3
-0@@ -1,3 +1,12 @@ +config BR2_OR1K_SOFT_FLOAT + bool "Use soft-float" + select BR2_SOFT_FLOATThis should be "default y", to preserve existing behavior.
Quoted 14 lines
arch/Config.in.or1k +6
-0+ help + If your target CPU does not have a Floating Point Unit (FPU) + or a kernel FPU emulator, but you still wish to support + floating point functions, then everything will need to be + compiled with soft floating point support (-msoft-float). + config BR2_ARCH default "or1k"package/Makefile.in +0
-0package/Makefile.in TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc · line 115
Quoted 10 lines
package/Makefile.in +7
-0@@ -106,6 +106,14 @@ TARGET_ABI += -mabi=spe -mfloat-gprs=double -Wa,-me500mc endif endif +# use hard-float option globally for OpenRISC, when not +# soft-float choosen by the user. +ifeq ($(BR2_or1k),y) +ifneq ($(BR2_OR1K_SOFT_FLOAT),y) +TARGET_ABI += -mhard-float +endif +endifThis needs somehow to go in the toolchain wrapper, so instead of your change, you would need something like this:
package/gcc/gcc.mk +0
-0
package/gcc/gcc.mk ifeq ($(BR2_SOFT_FLOAT),y) · line 219
Quoted 8 lines
package/gcc/gcc.mk +4
-0@@ -212,6 +212,10 @@ ifeq ($(BR2_SOFT_FLOAT),y) ifeq ($(BR2_arm)$(BR2_armeb)$(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el)$(BR2_powerpc)$(BR2_sparc),y) HOST_GCC_COMMON_CONF_OPTS += --with-float=soft endif +else +ifeq ($(BR2_or1k),y) +HOST_GCC_COMMON_CONF_OPTS += --with-float=hard +endif endif
The or1k gcc configuration has no --with-float. Only passing -mhard-float as CFLAGS is possible.
best regards
Waldemar
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot