Clang cross-compiling to Cortex-M4 (ARM)

Goran Mekić meka at tilda.center
Sun Sep 30 12:20:35 UTC 2018


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-current/attachments/20180930/6a3b6275/attachment.sig>


More information about the freebsd-current mailing list