Clang cross-compiling to Cortex-M4 (ARM)

From: Goran Mekić <meka_at_tilda.center>
Date: Sun, 30 Sep 2018 14:20:26 +0200
Hello,

With Clang 4.0 cross-compiling works, but any later versions (I tried
5.0, 6.0 and 7.0 from packages) fails. This is the simple test program:

#include <stdio.h>

int main() {
  return 0;
}


These are the results:

clang -fno-builtin -nostdlib -ffreestanding -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 -o test test.c
test.c:1:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
1 error generated.

clang40 -fno-builtin -nostdlib -ffreestanding -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 -o test test.c
/usr/local/bin/arm-none-eabi-ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000


System clang is 6.0.1, but it's the same with the one from packages (to
be precise, clang60 command). I suppose this is more suitable for LLVM
mailing list, but I wanted to check if there's something specific on
FreeBSD I should know about before I write there? Also, this does
compile:

clang -fno-builtin -nostdlib -ffreestanding -target arm-none-eabi -march=armv7-m -mcpu=cortex-m4 -isystem /usr/include -o test test.c
/usr/bin/ld.lld: warning: cannot find entry symbol _start; defaulting to 0x11000

Besides a course on compilers at University, I don't have much
experience in this field, so feel free to point me to proper
documentation/literature if what I just described is known.

Regards,
meka

Received on Sun Sep 30 2018 - 10:20:35 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:18 UTC