[llvm-dev] Cross compiling for Baremetal ARM without using GCC

Leslie Zhai via llvm-dev llvm-dev at lists.llvm.org
Tue Nov 14 01:05:25 PST 2017


Hi Daniel,

It is able to simulate stm32-p103 board for running simple "Hello World" 
example 
https://github.com/xiangzhai/mini-arm-os/blob/llvm-toolchain/00-HelloWorld/Makefile 
via LLVM toolchain and qemu_stm32 https://github.com/beckus/qemu_stm32

$ make
/data/project/llvm/build/bin/clang -o hello.o -c 
--target=thumbv7em-unknown-none-eabi -mthumb -march=armv7e-m 
-mcpu=cortex-m3 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -ffreestanding -O0 
-std=c11 -Wall hello.c
/data/project/llvm/build/bin/clang -o startup.o -c 
--target=thumbv7em-unknown-none-eabi -mthumb -march=armv7e-m 
-mcpu=cortex-m3 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -ffreestanding -O0 
-std=c11 -Wall startup.c
/data/project/llvm/build/bin/ld.lld -o hello.elf --Bstatic --build-id 
--gc-sections --Map hello.map --script hello.ld hello.o startup.o
/data/project/llvm/build/bin/llvm-readobj -W hello.elf > hello.rd
/data/project/llvm/build/bin/llvm-objdump -D hello.elf > hello.lst
/data/project/llvm/build/bin/llvm-objcopy -O binary hello.elf hello.bin
/data/project/llvm/build/bin/llvm-size hello.elf
    text    data     bss     dec     hex filename
     190      14       0     204      cc hello.elf


$ make qemu
/data/project/qemu_stm32/arm-softmmu/qemu-system-arm -M stm32-p103 
-nographic -kernel hello.bin

...
LED Off
Hello World!


But which C library should I choose for big ARMmbed project? Keith 
merged avr-libc stdio bits within the newlib environment. There were 
only three functions written in assembly language, two of them were just 
stubs while the third was a simple ultoa function with a weird 
interface. With those coded up in C 
https://keithp.com/blogs/embedded-arm-libc/

And I am trying to build ufiasco for Realtek AMEBA RTL8195A board via 
LLVM toolchain, ARM Compiler 6.9 libc and LLVM's libcxx 
https://github.com/xiangzhai/ufiasco/tree/llvm-toolchain I will try 
Keith's newlib fork later :)

-- 
Regards,
Leslie Zhai - https://reviews.llvm.org/p/xiangzhai/





More information about the llvm-dev mailing list