Building newlib without -mhard-float

Jeff Johnston jjohnstn@redhat.com
Wed Sep 5 19:43:00 GMT 2007


Rick Mann wrote:
> 
> On Sep 5, 2007, at 8:43 AM, Jeff Johnston wrote:
> 
>> These are in the gcc lib: libgcc.a  You need to add a -lgcc at the end 
>> of your compile/link.  If the compiler was built multilib, you will 
>> need to specify the options you used to build newlib with (e.g. 
>> -march=x -mcpu=y) as the compiler will match up a multilib libgcc.a 
>> with those options.  If you are using ld directly, you will have to 
>> point to the appropriate subdirectory to find the right libgcc.a.
> 
> I already link against libgcc.a. However, it seems to lack a great many 
> symbols. I've included the output from nm -g at the end of this message. 
> I also included a much longer list of link errors.
> 
> I configured GCC with:
> 
> $ arm-elf-gcc -v
> Using built-in specs.
> Target: arm-elf
> Configured with: ../configure --prefix=/usr/local/arm2 --target=arm-elf 
> --with-cpu=xscale --with-float=soft --disable-multilib 
> --disable-interwork --enable-languages=c,c++ --disable-nls --enable-c99 
> --with-newlib --enable-long-long
> Thread model: single
> gcc version 4.2.1
> 
> And I built newlib with:
> 
> $ ../configure --prefix=/usr/local/arm2 --target=arm-elf 
> --disable-newlib-supplied-syscalls --enable-newlib-io-long-long 
> --enable-newlib-multithreading --enable-newlib-io-pos-args 
> --enable--newlib-io-long-double --disable-multilib --with-float=soft 
> --with-cpu=xscale
> $ TARGET_CFLAGS="-mcpu=xscale -msoft-float" make
> 
> I notice that libgcc2.c conditionally compiles __udivdi3() with a flag 
> "L_udivdi3", but I don't know if that's getting set, or what controls 
> it. Any syggestions?
> 

My suggestion would be to back off this idea and simply build gcc and 
newlib without tinkering (disabling multilib and using TARGET_CFLAGS is 
tinkering).  This should give you all the possible arm-elf permutations 
and the various libraries will be in sync (i.e. newlib generated code 
won't reference any function that isn't found in libc/libm, libgloss, or 
libgcc).  Then, try and find one set of options that works for your 
target platform (e.g. arm-elf-gcc -g -mcpu=xscale -msoft-float test.c). 
  If none of the permutations work, then it means you need to add one to 
gcc's list so that you get a libgcc and newlib/libgloss that are in sync 
and use the options you want.  Adding a multilib is straightforward and 
has been done before.

With regards to enabling newlib long long or long double support.  This 
shouldn't be done if the compiler doesn't support the types in all 
permutations.  If specific permutations do support the types, then we 
can work from there and enable them on the fly.  Newlib does not support 
--with-float or --with-cpu.

-- Jeff J.

> Thanks so much!
> 
> 
> Symbols missing from libgcc.a (trimmed to narrow):
> 
> ----------------------------------------------------------
> $ arm-elf-gcc -Wl,-Map,mapfile.txt -mcpu=xscale -ffreestanding -nostdlib 
> -std=c99 -Xlinker --script=link.lds -o h.elf obj/start.o obj/Util.o 
> obj/glue.o obj/lcd.o obj/main.o -lgcc -lc -lm
> vfprintf.c:877: undefined reference to `__ltdf2'
> vfprintf.c:1226: undefined reference to `__eqdf2'
> vfprintf.c:1256: undefined reference to `__nedf2'
> vfprintf.c:1135: undefined reference to `__umoddi3'
> vfprintf.c:1136: undefined reference to `__udivdi3'
> vfprintf.c:1382: undefined reference to `__eqdf2'
> vfprintf.c:1378: undefined reference to `__nedf2'
> b/dtoa.c:60: undefined reference to `__udivsi3'
> dtoa.c:282: undefined reference to `__nedf2'
> dtoa.c:347: undefined reference to `__floatunsidf'
> dtoa.c:356: undefined reference to `__subdf3'
> dtoa.c:356: undefined reference to `__muldf3'
> dtoa.c:356: undefined reference to `__adddf3'
> dtoa.c:356: undefined reference to `__floatsidf'
> dtoa.c:356: undefined reference to `__muldf3'
> dtoa.c:356: undefined reference to `__adddf3'
> dtoa.c:358: undefined reference to `__fixdfsi'
> dtoa.c:359: undefined reference to `__ltdf2'
> dtoa.c:364: undefined reference to `__ltdf2'
> dtoa.c:457: undefined reference to `__muldf3'
> dtoa.c:459: undefined reference to `__divdf3'
> dtoa.c:471: undefined reference to `__ltdf2'
> dtoa.c:477: undefined reference to `__muldf3'
> dtoa.c:480: undefined reference to `__floatsidf'
> dtoa.c:480: undefined reference to `__muldf3'
> dtoa.c:480: undefined reference to `__adddf3'
> dtoa.c:480: undefined reference to `__floatsidf'
> dtoa.c:480: undefined reference to `__muldf3'
> dtoa.c:480: undefined reference to `__adddf3'
> dtoa.c:485: undefined reference to `__subdf3'
> dtoa.c:486: undefined reference to `__gtdf2'
> dtoa.c:488: undefined reference to `__ltdf2'
> dtoa.c:556: undefined reference to `__muldf3'
> dtoa.c:556: undefined reference to `__gedf2'
> dtoa.c:450: undefined reference to `__divdf3'
> dtoa.c:498: undefined reference to `__divdf3'
> dtoa.c:498: undefined reference to `__subdf3'
> dtoa.c:501: undefined reference to `__fixdfsi'
> dtoa.c:502: undefined reference to `__floatsidf'
> dtoa.c:502: undefined reference to `__subdf3'
> dtoa.c:504: undefined reference to `__gtdf2'
> dtoa.c:506: undefined reference to `__subdf3'
> dtoa.c:506: undefined reference to `__gtdf2'
> dtoa.c:506: undefined reference to `__subdf3'
> dtoa.c:506: undefined reference to `__ltdf2'
> dtoa.c:510: undefined reference to `__muldf3'
> dtoa.c:511: undefined reference to `__muldf3'
> dtoa.c:501: undefined reference to `__fixdfsi'
> dtoa.c:502: undefined reference to `__floatsidf'
> dtoa.c:502: undefined reference to `__subdf3'
> dtoa.c:504: undefined reference to `__ltdf2'
> dtoa.c:590: undefined reference to `__muldf3'
> dtoa.c:590: undefined reference to `__nedf2'
> dtoa.c:562: undefined reference to `__divdf3'
> dtoa.c:562: undefined reference to `__fixdfsi'
> dtoa.c:563: undefined reference to `__floatsidf'
> dtoa.c:563: undefined reference to `__muldf3'
> dtoa.c:563: undefined reference to `__subdf3'
> dtoa.c:575: undefined reference to `__adddf3'
> dtoa.c:576: undefined reference to `__ltdf2'
> dtoa.c:576: undefined reference to `__eqdf2'
> dtoa.c:359: undefined reference to `__floatsidf'
> dtoa.c:359: undefined reference to `__nedf2'
> dtoa.c:518: undefined reference to `__muldf3'
> dtoa.c:521: undefined reference to `__fixdfsi'
> dtoa.c:522: undefined reference to `__floatsidf'
> dtoa.c:522: undefined reference to `__subdf3'
> dtoa.c:519: undefined reference to `__muldf3'
> dtoa.c:521: undefined reference to `__fixdfsi'
> dtoa.c:522: undefined reference to `__floatsidf'
> dtoa.c:522: undefined reference to `__subdf3'
> dtoa.c:526: undefined reference to `__adddf3'
> dtoa.c:526: undefined reference to `__gtdf2'
> dtoa.c:528: undefined reference to `__subdf3'
> dtoa.c:528: undefined reference to `__ltdf2'
> dtoa.c:463: undefined reference to `__muldf3'
> dtoa.c:468: undefined reference to `__muldf3'
> 
> --------------------------------------------------------------
> $ arm-elf-nm -g /usr/local/arm2/lib/gcc/arm-elf/4.2.1/libgcc.a
> 
> _udivsi3.o:
> 00000000 T __aeabi_uidiv
> 000001f0 T __aeabi_uidivmod
>          U __div0
> 00000000 T __udivsi3
> 
> _divsi3.o:
> 00000000 T __aeabi_idiv
> 00000220 T __aeabi_idivmod
>          U __div0
> 00000000 T __divsi3
> 
> _umodsi3.o:
>          U __div0
> 00000000 T __umodsi3
> 
> _modsi3.o:
>          U __div0
> 00000000 T __modsi3
> 
> _dvmd_tls.o:
> 00000000 T __aeabi_idiv0
> 00000000 T __aeabi_ldiv0
> 00000000 T __div0
> 
> _bb_init_func.o:
> 
> _call_via_rX.o:
> 0000002c T _call_via_fp
> 00000030 T _call_via_ip
> 00000038 T _call_via_lr
> 00000000 T _call_via_r0
> 00000004 T _call_via_r1
> 00000008 T _call_via_r2
> 0000000c T _call_via_r3
> 00000010 T _call_via_r4
> 00000014 T _call_via_r5
> 00000018 T _call_via_r6
> 0000001c T _call_via_r7
> 00000020 T _call_via_r8
> 00000024 T _call_via_r9
> 00000028 T _call_via_sl
> 00000034 T _call_via_sp
> 
> _interwork_call_via_rX.o:
> 000002b0 T .Lchange_fp
> 000002ec T .Lchange_ip
> 00000364 T .Lchange_lr
> 0000001c T .Lchange_r0
> 00000058 T .Lchange_r1
> 00000094 T .Lchange_r2
> 000000d0 T .Lchange_r3
> 0000010c T .Lchange_r4
> 00000148 T .Lchange_r5
> 00000184 T .Lchange_r6
> 000001c0 T .Lchange_r7
> 000001fc T .Lchange_r8
> 00000238 T .Lchange_r9
> 00000274 T .Lchange_sl
> 00000328 T .Lchange_sp
> 00000004 T _arm_return
> 00000010 T _arm_return_r11
> 00000008 T _arm_return_r7
> 000002ac T _interwork_call_via_fp
> 000002e8 T _interwork_call_via_ip
> 00000360 T _interwork_call_via_lr
> 00000018 T _interwork_call_via_r0
> 00000054 T _interwork_call_via_r1
> 00000090 T _interwork_call_via_r2
> 000000cc T _interwork_call_via_r3
> 00000108 T _interwork_call_via_r4
> 00000144 T _interwork_call_via_r5
> 00000180 T _interwork_call_via_r6
> 000001bc T _interwork_call_via_r7
> 000001f8 T _interwork_call_via_r8
> 00000234 T _interwork_call_via_r9
> 00000270 T _interwork_call_via_sl
> 00000324 T _interwork_call_via_sp
> 000002d4 T _interwork_r11_call_via_fp
> 00000310 T _interwork_r11_call_via_ip
> 00000040 T _interwork_r11_call_via_r0
> 0000007c T _interwork_r11_call_via_r1
> 000000b8 T _interwork_r11_call_via_r2
> 000000f4 T _interwork_r11_call_via_r3
> 00000130 T _interwork_r11_call_via_r4
> 0000016c T _interwork_r11_call_via_r5
> 000001a8 T _interwork_r11_call_via_r6
> 000001e4 T _interwork_r11_call_via_r7
> 00000220 T _interwork_r11_call_via_r8
> 0000025c T _interwork_r11_call_via_r9
> 00000298 T _interwork_r11_call_via_sl
> 0000034c T _interwork_r11_call_via_sp
> 000002c0 T _interwork_r7_call_via_fp
> 000002fc T _interwork_r7_call_via_ip
> 0000002c T _interwork_r7_call_via_r0
> 00000068 T _interwork_r7_call_via_r1
> 000000a4 T _interwork_r7_call_via_r2
> 000000e0 T _interwork_r7_call_via_r3
> 0000011c T _interwork_r7_call_via_r4
> 00000158 T _interwork_r7_call_via_r5
> 00000194 T _interwork_r7_call_via_r6
> 000001d0 T _interwork_r7_call_via_r7
> 0000020c T _interwork_r7_call_via_r8
> 00000248 T _interwork_r7_call_via_r9
> 00000284 T _interwork_r7_call_via_sl
> 00000338 T _interwork_r7_call_via_sp
> 
> _lshrdi3.o:
> 00000000 T __aeabi_llsr
> 00000000 T __lshrdi3
> 
> _ashrdi3.o:
> 00000000 T __aeabi_lasr
> 00000000 T __ashrdi3
> 
> _ashldi3.o:
> 00000000 T __aeabi_llsl
> 00000000 T __ashldi3
> 
> _negdf2.o:
> 00000000 T __aeabi_dneg
> 00000000 T __negdf2
> 
> _addsubdf3.o:
> 0000000c T __adddf3
> 0000000c T __aeabi_dadd
> 00000000 T __aeabi_drsub
> 00000008 T __aeabi_dsub
> 0000030c T __aeabi_f2d
> 000002e0 T __aeabi_i2d
> 00000360 T __aeabi_l2d
> 000002b8 T __aeabi_ui2d
> 0000034c T __aeabi_ul2d
> 0000030c T __extendsfdf2
> 00000360 T __floatdidf
> 000002e0 T __floatsidf
> 0000034c T __floatundidf
> 000002b8 T __floatunsidf
> 00000008 T __subdf3
> 
> _muldivdf3.o:
> 0000026c T __aeabi_ddiv
> 00000000 T __aeabi_dmul
> 0000026c T __divdf3
> 00000000 T __muldf3
> 
> _cmpdf2.o:
> 000000b0 T __aeabi_cdcmpeq
> 000000b0 T __aeabi_cdcmple
> 00000094 T __aeabi_cdrcmple
> 000000c4 T __aeabi_dcmpeq
> 00000100 T __aeabi_dcmpge
> 00000114 T __aeabi_dcmpgt
> 000000ec T __aeabi_dcmple
> 000000d8 T __aeabi_dcmplt
> 00000010 T __cmpdf2
> 00000010 T __eqdf2
> 00000000 T __gedf2
> 00000000 T __gtdf2
> 00000008 T __ledf2
> 00000008 T __ltdf2
> 00000010 T __nedf2
> 
> _unorddf2.o:
> 00000000 T __aeabi_dcmpun
> 00000000 T __unorddf2
> 
> _fixdfsi.o:
> 00000000 T __aeabi_d2iz
> 00000000 T __fixdfsi
> 
> _fixunsdfsi.o:
> 00000000 T __aeabi_d2uiz
> 00000000 T __fixunsdfsi
> 
> _truncdfsf2.o:
> 00000000 T __aeabi_d2f
> 00000000 T __truncdfsf2
> 
> _negsf2.o:
> 00000000 T __aeabi_fneg
> 00000000 T __negsf2
> 
> _addsubsf3.o:
> 0000000c T __addsf3
> 0000000c T __aeabi_fadd
> 00000000 T __aeabi_frsub
> 00000008 T __aeabi_fsub
> 000001a4 T __aeabi_i2f
> 000001d4 T __aeabi_l2f
> 0000019c T __aeabi_ui2f
> 000001c4 T __aeabi_ul2f
> 000001d4 T __floatdisf
> 000001a4 T __floatsisf
> 000001c4 T __floatundisf
> 0000019c T __floatunsisf
> 00000008 T __subsf3
> 
> _muldivsf3.o:
> 00000198 T __aeabi_fdiv
> 00000000 T __aeabi_fmul
> 00000198 T __divsf3
> 00000000 T __mulsf3
> 
> _cmpsf2.o:
> 00000080 T __aeabi_cfcmpeq
> 00000080 T __aeabi_cfcmple
> 00000070 T __aeabi_cfrcmple
> 00000094 T __aeabi_fcmpeq
> 000000d0 T __aeabi_fcmpge
> 000000e4 T __aeabi_fcmpgt
> 000000bc T __aeabi_fcmple
> 000000a8 T __aeabi_fcmplt
> 00000010 T __cmpsf2
> 00000010 T __eqsf2
> 00000000 T __gesf2
> 00000000 T __gtsf2
> 00000008 T __lesf2
> 00000008 T __ltsf2
> 00000010 T __nesf2
> 
> _unordsf2.o:
> 00000000 T __aeabi_fcmpun
> 00000000 T __unordsf2
> 
> _fixsfsi.o:
> 00000000 T __aeabi_f2iz
> 00000000 T __fixsfsi
> 
> _fixunssfsi.o:
> 00000000 T __aeabi_f2uiz
> 00000000 T __fixunssfsi
> 
> _floatdidf.o:
> 
> _floatdisf.o:
> 
> _floatundidf.o:
> 
> _floatundisf.o:
> 
> _muldi3.o:
> 00000000 T __muldi3
> 
> _negdi2.o:
> 00000000 T __negdi2
> 
> _cmpdi2.o:
> 00000000 T __cmpdi2
> 
> _ucmpdi2.o:
> 00000000 T __ucmpdi2
> 
> _clear_cache.o:
> 00000000 T __clear_cache
> 
> _enable_execute_stack.o:
> 00000000 T __enable_execute_stack
> 
> _trampoline.o:
> 
> __main.o:
> 
> _absvsi2.o:
> 00000000 T __absvsi2
> 
> _absvdi2.o:
> 00000000 T __absvdi2
> 
> _addvsi3.o:
> 00000000 T __addvsi3
>          U abort
> 
> _addvdi3.o:
> 00000000 T __addvdi3
>          U abort
> 
> _subvsi3.o:
> 00000000 T __subvsi3
>          U abort
> 
> _subvdi3.o:
> 00000000 T __subvdi3
>          U abort
> 
> _mulvsi3.o:
> 00000000 T __mulvsi3
>          U abort
> 
> _mulvdi3.o:
> 00000000 T __mulvdi3
>          U abort
> 
> _negvsi2.o:
> 00000000 T __negvsi2
>          U abort
> 
> _negvdi2.o:
> 00000000 T __negvdi2
>          U abort
> 
> _ctors.o:
> 
> _ffssi2.o:
>          U __clz_tab
> 00000000 T __ffssi2
> 
> _ffsdi2.o:
>          U __clz_tab
> 00000000 T __ffsdi2
> 
> _clz.o:
> 00000000 R __clz_tab
> 
> _clzsi2.o:
>          U __clz_tab
> 00000000 T __clzsi2
> 
> _clzdi2.o:
>          U __clz_tab
> 00000000 T __clzdi2
> 
> _ctzsi2.o:
>          U __clz_tab
> 00000000 T __ctzsi2
> 
> _ctzdi2.o:
>          U __clz_tab
> 00000000 T __ctzdi2
> 
> _popcount_tab.o:
> 00000000 R __popcount_tab
> 
> _popcountsi2.o:
>          U __popcount_tab
> 00000000 T __popcountsi2
> 
> _popcountdi2.o:
>          U __popcount_tab
> 00000000 T __popcountdi2
> 
> _paritysi2.o:
> 00000000 T __paritysi2
> 
> _paritydi2.o:
> 00000000 T __paritydi2
> 
> _powisf2.o:
>          U __divsf3
>          U __mulsf3
> 00000000 T __powisf2
> 
> _powidf2.o:
>          U __divdf3
>          U __muldf3
> 00000000 T __powidf2
> 
> _powixf2.o:
> 
> _powitf2.o:
> 
> _mulsc3.o:
>          U __addsf3
> 00000000 T __mulsc3
>          U __mulsf3
>          U __nesf2
>          U __subsf3
> 
> _muldc3.o:
>          U __adddf3
> 00000000 T __muldc3
>          U __muldf3
>          U __nedf2
>          U __subdf3
> 
> _mulxc3.o:
> 
> _multc3.o:
> 
> _divsc3.o:
>          U __addsf3
> 00000000 T __divsc3
>          U __divsf3
>          U __eqsf2
>          U __ltsf2
>          U __mulsf3
>          U __nesf2
>          U __subsf3
> 
> _divdc3.o:
>          U __adddf3
> 00000000 T __divdc3
>          U __divdf3
>          U __eqdf2
>          U __ltdf2
>          U __muldf3
>          U __nedf2
>          U __subdf3
> 
> _divxc3.o:
> 
> _divtc3.o:
> 
> _fixunsxfsi.o:
> 
> _fixsfdi.o:
> 00000000 T __fixsfdi
>          U __fixunssfdi
>          U __ltsf2
> 
> _fixunssfdi.o:
>          U __adddf3
>          U __extendsfdf2
>          U __fixunsdfsi
> 00000000 T __fixunssfdi
>          U __floatunsidf
>          U __muldf3
> 
> _fixdfdi.o:
> 00000000 T __fixdfdi
>          U __fixunsdfdi
>          U __ltdf2
> 
> _fixunsdfdi.o:
>          U __adddf3
> 00000000 T __fixunsdfdi
>          U __fixunsdfsi
>          U __floatunsidf
>          U __muldf3
> 
> _fixxfdi.o:
> 
> _fixunsxfdi.o:
> 
> _floatdixf.o:
> 
> _floatundixf.o:
> 
> _fixtfdi.o:
> 
> _fixunstfdi.o:
> 
> _floatditf.o:
> 
> _floatunditf.o:
> 
> _eprintf.o:
> 
> __gcc_bcmp.o:
> 00000000 T __gcc_bcmp
> 
> _divdi3.o:
>          U __clz_tab
> 00000000 T __divdi3
>          U __udivsi3
>          U __umodsi3
> 
> _moddi3.o:
>          U __clz_tab
> 00000000 T __moddi3
>          U __udivsi3
>          U __umodsi3
> 
> _udivdi3.o:
>          U __clz_tab
> 00000000 T __udivdi3
>          U __udivsi3
>          U __umodsi3
> 
> _umoddi3.o:
>          U __clz_tab
>          U __udivsi3
> 00000000 T __umoddi3
>          U __umodsi3
> 
> _udiv_w_sdiv.o:
> 00000000 T __udiv_w_sdiv
> 
> _udivmoddi4.o:
>          U __clz_tab
> 00000000 T __udivmoddi4
>          U __udivsi3
>          U __umodsi3
> 
> unwind-dw2.o:
> 
> unwind-dw2-fde.o:
> 00001280 T _Unwind_Find_FDE
> 000014cc T __deregister_frame
> 000014c8 T __deregister_frame_info
> 000013e8 T __deregister_frame_info_bases
> 00000f40 T __register_frame
> 00000118 T __register_frame_info
> 000000b0 T __register_frame_info_bases
> 00000178 T __register_frame_info_table
> 00000124 T __register_frame_info_table_bases
> 00000f20 T __register_frame_table
>          U abort
>          U free
>          U malloc
>          U strlen
> 
> unwind-sjlj.o:
> 00000228 T _Unwind_Backtrace
> 00000208 T _Unwind_DeleteException
> 000000bc T _Unwind_FindEnclosingFunction
> 00000050 T _Unwind_GetCFA
> 000000c4 T _Unwind_GetDataRelBase
> 00000040 T _Unwind_GetGR
> 00000070 T _Unwind_GetIP
> 00000080 T _Unwind_GetIPInfo
> 000000a8 T _Unwind_GetLanguageSpecificData
> 000000b4 T _Unwind_GetRegionStart
> 000000cc T _Unwind_GetTextRelBase
> 00000060 T _Unwind_SetGR
> 00000098 T _Unwind_SetIP
> 000003d0 T _Unwind_SjLj_ForcedUnwind
> 0000042c T _Unwind_SjLj_RaiseException
> 00000000 T _Unwind_SjLj_Register
> 00000370 T _Unwind_SjLj_Resume
> 00000504 T _Unwind_SjLj_Resume_or_Rethrow
> 00000038 T _Unwind_SjLj_Unregister
>          U abort
> 
> gthr-gnat.o:
> 00000000 T __gnat_default_lock
> 00000004 T __gnat_default_unlock
> 00000008 T __gnat_install_locks
> 00000024 T __gthread_active_p
> 0000002c T __gthread_mutex_lock
> 00000048 T __gthread_mutex_unlock
> 
> unwind-c.o:
>          U _Unwind_GetDataRelBase
>          U _Unwind_GetIPInfo
>          U _Unwind_GetLanguageSpecificData
>          U _Unwind_GetRegionStart
>          U _Unwind_GetTextRelBase
>          U _Unwind_SetGR
>          U _Unwind_SetIP
> 0000032c T __gcc_personality_sj0
>          U abort
> 
> 



More information about the Newlib mailing list