Better Firmware with LLVM/Clang | Interrupt

Hi Chris,

Thanks for all your support and help. I was able to get past the gcc library issue. I added -v to linker flags in the Makefile to show the link invocation command (see below)

"/usr/bin/ld.lld" /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/builtin_scanbuild_examples.o /home/rajah/workspace/interrupt/example/freertos- 
example-llvm/build/src/main.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/memory_leak_examples.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/memory_pool.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/mutex_examples.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/stub_functions.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/freertos_lock_port.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/src/startup.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/tasks.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/queue.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/list.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/timers.o /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/portable/GCC/ARM_CM4F/port.o 
/home/rajah/workspace/interrupt/example/freertos-example- 
llvm/build/freertos_kernel/portable/MemMang/heap_1.o /usr/lib/gcc/arm-none-eabi/10.1.0/thumb/v7e- 
m+fp/hard/libgcc.a -lgcc --gc-sections -Map /home/rajah/workspace/interrupt/example/freertos- 
example-llvm/build/nrf52.map -lc -lm -Bstatic -L/usr/lib/clang/10.0.0/lib/baremetal -L/usr/arm-none- 
eabi/lib/thumb/v7e-m+fp/hard -T /home/rajah/workspace/interrupt/example/freertos-example- 
llvm/nrf52.ld -o /home/rajah/workspace/interrupt/example/freertos-example-llvm/build/nrf52.elf

From the invocation, I was able to verify that libgcc.a can be found in
/usr/lib/gcc/arm-none-eabi/10.1.0/thumb/v7e-m+fp/hard/libgcc.a

However, the -L flag to the linker only list the following search directories.
-L/usr/lib/clang/10.0.0/lib/baremetal
-L/usr/arm-none-eabi/lib/thumb/v7e-m+fp/hard

The first path does not exist on my arch system and the second one exits, but does not have libgcc.a. I copied libgcc.a from /usr/lib/gcc/arm-none-eabi/10.1.0/thumb/v7e-m+fp/hard/ to /usr/arm-none-eabi/lib/thumb/v7e-m+fp/hard. I am able to generate the elf file after this. However, I am still not sure how arm-none-eabi-gcc/ld is able to find gcc library without copying. I suspect it may have something to do with how scan-build hijacks CC in the Makefile. I hope this helps others facing similar issues.

Thanks,
Rajah

System details:
Linux 5.6.15-1-MANJARO #1 SMP PREEMPT Wed May 27 20:38:56 UTC 2020 x86_64 GNU/Linux
Clang compiler details:
clang version 10.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Clang linker details:
LLD 10.0.0 (compatible with GNU linkers)
arm-none-eabi-gcc details:
arm-none-eabi-gcc (Arch Repository) 10.1.0
arm-none-eabi-ld details:
GNU ld (GNU Binutils) 2.34

1 Like