This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Compiling libgcc not optimized

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,

Parents
  • One doesn't need to build the entire toolchain - for e.g. binutils can remain as they are. The diff changes gcc and libgcc.a, so these two components need rebuilding.

    but the compiler is still using the names of the optimized routines.

    The arm-none-eabi-gcc needs to be changed if it is expected to not use the names of the optimized routines. This step is accomplished by the change in the arm.c file. The rest of the changes are all inside libgcc.

    I would like to build the not-optimized libgcc version and deploy it with a pre-built toolchain

    If the arm-none-eabi-gcc isn't changed, it will emit the names of the optimized routines.

    Assuming that we are okay with using the optimized labels for unoptimized code, you can try to build libgcc.a with the same diff posted last, but ignoring the changes to sfp-machine.h and arm.c files. This ensures that arm-none-eabi-gcc remains untouched, and that libgcc.a complies with the labels that arm-none-eabi-gcc emits by default. Then, you don't have to build anything other than libgcc.a.

    The result might look like so:

    00008000 <_start>:
        8000:	b580      	push	{r7, lr}
        8002:	b086      	sub	sp, #24
        8004:	af00      	add	r7, sp, #0
    ...
        8022:	f000 f813 	bl	804c <__aeabi_dadd>
    ...
        8036:	f000 fb25 	bl	8684 <__aeabi_ddiv>
    ...
    
    
    
    0000804c <__aeabi_dadd>:
        804c:	e92d 43f0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, lr}
        8050:	4696      	mov	lr, r2
        8052:	461a      	mov	r2, r3
        8054:	f3c1 0613 	ubfx	r6, r1, #0, #20
    ...
    
    00008684 <__aeabi_ddiv>:
        8684:	e92d 4ff0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
        8688:	460c      	mov	r4, r1
        868a:	4605      	mov	r5, r0
        868c:	f3c4 560a 	ubfx	r6, r4, #20, #11
    ...

    Labels of the optimized routines, with actual unoptimized code underneath.

Reply
  • One doesn't need to build the entire toolchain - for e.g. binutils can remain as they are. The diff changes gcc and libgcc.a, so these two components need rebuilding.

    but the compiler is still using the names of the optimized routines.

    The arm-none-eabi-gcc needs to be changed if it is expected to not use the names of the optimized routines. This step is accomplished by the change in the arm.c file. The rest of the changes are all inside libgcc.

    I would like to build the not-optimized libgcc version and deploy it with a pre-built toolchain

    If the arm-none-eabi-gcc isn't changed, it will emit the names of the optimized routines.

    Assuming that we are okay with using the optimized labels for unoptimized code, you can try to build libgcc.a with the same diff posted last, but ignoring the changes to sfp-machine.h and arm.c files. This ensures that arm-none-eabi-gcc remains untouched, and that libgcc.a complies with the labels that arm-none-eabi-gcc emits by default. Then, you don't have to build anything other than libgcc.a.

    The result might look like so:

    00008000 <_start>:
        8000:	b580      	push	{r7, lr}
        8002:	b086      	sub	sp, #24
        8004:	af00      	add	r7, sp, #0
    ...
        8022:	f000 f813 	bl	804c <__aeabi_dadd>
    ...
        8036:	f000 fb25 	bl	8684 <__aeabi_ddiv>
    ...
    
    
    
    0000804c <__aeabi_dadd>:
        804c:	e92d 43f0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, lr}
        8050:	4696      	mov	lr, r2
        8052:	461a      	mov	r2, r3
        8054:	f3c1 0613 	ubfx	r6, r1, #0, #20
    ...
    
    00008684 <__aeabi_ddiv>:
        8684:	e92d 4ff0 	stmdb	sp!, {r4, r5, r6, r7, r8, r9, sl, fp, lr}
        8688:	460c      	mov	r4, r1
        868a:	4605      	mov	r5, r0
        868c:	f3c4 560a 	ubfx	r6, r4, #20, #11
    ...

    Labels of the optimized routines, with actual unoptimized code underneath.

Children