Configuring newlib for cross-compilation with clang
Vlad Ivanov
vlad@ivanov.email
Tue Nov 3 14:01:42 GMT 2020
For anyone stumbling upon this, the problem was caused by wrong options. Instead
of CC and CFLAGS, one must use CC_FOR_TARGET and CFLAGS_FOR_TARGET.
One thing I noticed is that newlib is largely gcc-centric, and while it seems it can be
built with clang for some targets, that is not the case with powerpc.
03.11.2020, 14:08, "Vlad Ivanov" <vlad@ivanov.email>:
> Hello,
>
> I'm trying to build newlib for a PowerPC embedded target to assemble a complete
> toolchain with clang. I need to use clang as a cross compiler; clang and llvm
> are the only tools available. The resulting toolchain targets bare metal
> environment.
>
> Here's the command I'm using:
>
> ../newlib-cygwin/configure \
> --prefix=/opt/newlib-powerpc/install \
> --disable-libstdcxx \
> --disable-shared \
> --enable-static \
> --disable-multilib \
> --target=powerpc-none-eabi \
> --disable-newlib-supplied-syscalls \
> --enable-newlib-nano-malloc \
> --enable-target-optspace \
> --disable-newlib-multithread \
> --disable-newlib-io-float \
> --enable-lite-exit \
> CC='/usr/bin/clang'
> CFLAGS='--target=powerpc-none-eabi'
>
> I see an error early during configuration:
>
> checking for C compiler default output file name...
> configure: error: in `/opt/newlib-powerpc/build':
> configure: error: C compiler cannot create executables
> See `config.log' for more details.
>
> Now, this error occurs because the configure script tries to compile an
> executable and it's expecting to see something like a.out. But for an
> embedded target, to link an executable, one needs a linker scripts to define
> the memory layout, since there's no OS loading the binary. So any tests
> that create executables will fail.
>
> Is it possible to tell newlib to not compile any executables? Or should I
> use something like a dummy linker script?
>
> Best Regards,
>
> Vlad
More information about the Newlib
mailing list