Good moorning,
I am trying to compile libgcc for arm-none-eabi target from scratch, since I need to compare Floating Point SW emulation on an ARM Cortex-M4 and Risc-V based processors. The problem is that by default GCC includes the optimized version of FP SW emulation functions which is ieee754-sf.S.
Does anyone knows how to exclude ieee754-sf.S in the libgcc compilation process? In particular how to configure GCC?
Thanks,
IANAE, but below is a hack one can try. No warranty of any kind.
The asm sources for the optimized routines are collected inside the LIB1ASMFUNCS make variable.
gccsrc/libgcc/Makefile.in has
libgcc-objects += $(lib1asmfuncs-o) ... ... libgcc-s-objects += $(lib1asmfuncs-s-o)
Comment the two lines to avoid including the optimized routines.
The inclusion of softftp routines is controlled by gccsrc/libgcc/config/arm/t-softfp:
softfp_wrap_start := '\#if !__ARM_ARCH_ISA_ARM && __ARM_ARCH_ISA_THUMB == 1' softfp_wrap_end := '\#endif'
Change it to:
softfp_wrap_start := '\#if 1' softfp_wrap_end := '\#endif'
Build.
Or, one may rely on utilizing -nostdlib on unmodified builds to prevent linking with -lgcc. You may also want to consult gcc dev's mailing lists.
Hi @a.surati, thanks for the answer. I tried your advice but unfortunately the result was negative. Using the new generated libgcc.a, from your solution, and compiling the source code of my application GCC gives the error: "undefined reference to __aeabi_fadd". It seems there are no more the optimized SP routines in libgcc.a, but the compiler is still using the names of the optimized routines. Instead of using __aeabi_fadd it should use addsf3, which the standard name.
Okay. Those steps replaced the optimized code with the unoptimized one, afaics within the libgcc.a built.
Additionally, libgcc.a and gcc compiler redefine __addsf3 to __aeabi_fadd. Such redefinitions are applied to other functions too.
For the sake of testing a single function __addsf3, these additional changes (on top of earlier ones) were made:
gccsrc/gcc/config/arm/arm.c has:... set_optab_libfunc (add_optab, SFmode, "__aeabi_fadd"); ...Comment that line.gccsrc/libgcc/config/arm/sfp-machine.h has at the end of the file:#ifdef __ARM_EABI__ ... #endifChange the #ifdef to #ifdef 0.I only tested that gcc -c emitted __addsf3, and that libgcc.a had addsf3.0 with __addsf3 function inside it.
... set_optab_libfunc (add_optab, SFmode, "__aeabi_fadd"); ...
#ifdef __ARM_EABI__ ... #endif
Edit: I had mistakenly built the a-profile toolchain, hence the mix of thumb and arm instructions for armv7e-m. The toolchain (built with the diff below) did work for compiling a small test program for armv7-a, as verified by running a statically built binary with qemu-arm.
The diff remains as before, and is given below. I will attempt to build an arm-none-eabi with libgcc.a to see if the diff needs any changes.
diff -ru org/gcc-10.2.0/gcc/config/arm/arm.c gcc-10.2.0/gcc/config/arm/arm.c --- org/gcc-10.2.0/gcc/config/arm/arm.c 2020-07-23 12:05:17.344384552 +0530 +++ gcc-10.2.0/gcc/config/arm/arm.c 2020-11-26 12:50:11.121893412 +0530 @@ -2531,6 +2531,7 @@ /* For Linux, we have access to kernel support for atomic operations. */ if (arm_abi == ARM_ABI_AAPCS_LINUX) init_sync_libfuncs (MAX_SYNC_LIBFUNC_SIZE); + return; /* There are no special library functions unless we are using the ARM BPABI. */ diff -ru org/gcc-10.2.0/libgcc/config/arm/sfp-machine.h gcc-10.2.0/libgcc/config/arm/sfp-machine.h --- org/gcc-10.2.0/libgcc/config/arm/sfp-machine.h 2020-07-23 12:05:18.752400064 +0530 +++ gcc-10.2.0/libgcc/config/arm/sfp-machine.h 2020-11-26 13:31:10.565636471 +0530 @@ -67,7 +67,7 @@ # define _strong_alias(name, aliasname) \ extern __typeof (name) aliasname __attribute__ ((alias (#name))); -#ifdef __ARM_EABI__ +#if 0 /* Rename functions to their EABI names. */ /* The comparison functions need wrappers for EABI semantics, so leave them unmolested. */ diff -ru org/gcc-10.2.0/libgcc/config/arm/t-arm gcc-10.2.0/libgcc/config/arm/t-arm --- org/gcc-10.2.0/libgcc/config/arm/t-arm 2020-07-23 12:05:18.752400064 +0530 +++ gcc-10.2.0/libgcc/config/arm/t-arm 2020-11-26 12:18:01.909926794 +0530 @@ -1,6 +1,7 @@ LIB1ASMSRC = arm/lib1funcs.S LIB1ASMFUNCS = _thumb1_case_sqi _thumb1_case_uqi _thumb1_case_shi \ _thumb1_case_uhi _thumb1_case_si _speculation_barrier +LIB2ADD += $(srcdir)/udivmodsi4.c $(srcdir)/udivmod.c $(srcdir)/divmod.c HAVE_CMSE:=$(findstring __ARM_FEATURE_CMSE,$(shell $(gcc_compile_bare) -dM -E - </dev/null)) HAVE_V81M:=$(findstring armv8.1-m.main,$(gcc_compile_bare)) diff -ru org/gcc-10.2.0/libgcc/config/arm/t-softfp gcc-10.2.0/libgcc/config/arm/t-softfp --- org/gcc-10.2.0/libgcc/config/arm/t-softfp 2020-07-23 12:05:18.752400064 +0530 +++ gcc-10.2.0/libgcc/config/arm/t-softfp 2020-11-26 13:28:39.584201073 +0530 @@ -1,2 +1,3 @@ -softfp_wrap_start := '\#if !__ARM_ARCH_ISA_ARM && __ARM_ARCH_ISA_THUMB == 1' +softfp_wrap_start := '\#if 1' softfp_wrap_end := '\#endif' +softfp_exclude_libgcc2 := n diff -ru org/gcc-10.2.0/libgcc/Makefile.in gcc-10.2.0/libgcc/Makefile.in --- org/gcc-10.2.0/libgcc/Makefile.in 2020-07-23 12:05:18.748400018 +0530 +++ gcc-10.2.0/libgcc/Makefile.in 2020-11-26 13:30:50.989201425 +0530 @@ -484,14 +484,14 @@ $(gcc_compile) -DL$* -xassembler-with-cpp -c $< -include $*.vis $(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext) $(gen-hide-list) -libgcc-objects += $(lib1asmfuncs-o) +#libgcc-objects += $(lib1asmfuncs-o) lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS)) $(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC) $(gcc_s_compile) -DL$* -xassembler-with-cpp -c $< ifeq ($(enable_shared),yes) -libgcc-s-objects += $(lib1asmfuncs-s-o) +#libgcc-s-objects += $(lib1asmfuncs-s-o) endif diff -ru org/gcc-10.2.0/libsanitizer/asan/asan_linux.cpp gcc-10.2.0/libsanitizer/asan/asan_linux.cpp --- org/gcc-10.2.0/libsanitizer/asan/asan_linux.cpp 2020-07-23 12:05:19.124404163 +0530 +++ gcc-10.2.0/libsanitizer/asan/asan_linux.cpp 2020-11-26 07:06:35.712906746 +0530 @@ -199,7 +199,9 @@ Die(); } } - +#ifndef PATH_MAX +#define PATH_MAX 1024 +#endif void AsanCheckIncompatibleRT() { if (ASAN_DYNAMIC) { if (__asan_rt_version == ASAN_RT_VERSION_UNDEFINED) {
View all questions in Cortex-M / M-Profile forum