[llvm-dev] Compiling for baremetal ARMv4 on Ubuntu Linux

Peter Smith via llvm-dev
Tue, 04 Dec 2018 14:54:03 -0000

Hello,

Just a few quick observations.
- It looks like you may have downloaded the linux arm toolchain. For bare
metal you probably wanted the Arm embedded toolchain,
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm
-- That toolchain will have newlib rather than glibc, I don't know whether
it will have one pre-compiled for v4 though. If not you may have to find an
older toolchain or build newlib youtself.
- The bare-metal driver in clang (arm-none-eabi) is not multilib aware and
won't put the paths to the libraries on the link line, the -L flag
-- I have found that following the samples in the gnu embedded toolchain
with gcc using the -v flag to get the paths it is using, then use these
with lld.

If you can let us know what problems you are seeing building compiler-rt
then we may be able to help. I'm not sure there is anyone building it for
arm v4 so you may be hitting new problems. I'm away at a conference today
and tomorrow but I can try later in the week.

Peter

On Tue, 4 Dec 2018 at 12:21, cscheuer via llvm-dev <llvm-dev at
lists.llvm.org>
wrote:

> I am currently trying to compile a pretty simple program to work on an
> experimental board. It contains an (FPGA-version of) an ARMv4 processor.
> So basically, I try this (on my Ubuntu 18.04.1 LTS):
> clang -v --target=arm-none-eabi -c barehello.c -o barehelloCLANG.o
> clang -v --target=arm-none-eabi -c io.c -o io.o
> clang -v --target=arm-none-eabi barehelloCLANG.o io.o -o
> helloCLANGstatic -static -fuse-ld=lld
>
> Which results in
>
> clang version 8.0.0 (https://git.llvm.org/git/clang.git/
> a152c7a4b7ba8f4cb9532ead9a38a7121db43d50)
> (https://git.llvm.org/git/llvm.git/
> 1959ce6f3e01241919968ac1911fd45660239d23)
> Target: arm-none-unknown-eabi
> Thread model: posix
> InstalledDir: /usr/local/my_clang/bin
>   "/usr/local/my_clang/bin/ld.lld" barehelloCLANG.o io.o -Bstatic
> -L/usr/local/my_clang/lib/clang/8.0.0/lib/baremetal -lc -lm
> -lclang_rt.builtins-arm.a -o helloCLANGstatic
> ld.lld: error: unable to find library -lc
> ld.lld: error: unable to find library -lm
> ld.lld: error: unable to find library -lclang_rt.builtins-arm.a
> clang-8: error: ld.lld command failed with exit code 1 (use -v to see
> invocation)
>
> on the linking part. I downloaded a sysroot from
>
>
https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads/8-2-2018-08
> and tried to include it via --sysroot=/my/path/to/it, but clang acted
> unimpressed with the same errors. So I'm missing
clang_rt.builtins-arm.a
> I guess, but that does not exist on my system.
> So next, I tried basically every version of "how to cross-compile
> llvm/clang/compiler-rt" That google came up with, but was not able to
> get a single one to actually work. Any ideas how to get this running?
> Thanks in advance!
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20181204/d03a4e59/attachment-0001.html>