public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Configuring newlib for cross-compilation with clang
@ 2020-11-03 11:08 Vlad Ivanov
  2020-11-03 14:01 ` Vlad Ivanov
  0 siblings, 1 reply; 2+ messages in thread
From: Vlad Ivanov @ 2020-11-03 11:08 UTC (permalink / raw)
  To: newlib

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Configuring newlib for cross-compilation with clang
  2020-11-03 11:08 Configuring newlib for cross-compilation with clang Vlad Ivanov
@ 2020-11-03 14:01 ` Vlad Ivanov
  0 siblings, 0 replies; 2+ messages in thread
From: Vlad Ivanov @ 2020-11-03 14:01 UTC (permalink / raw)
  To: newlib

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-03 14:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 11:08 Configuring newlib for cross-compilation with clang Vlad Ivanov
2020-11-03 14:01 ` Vlad Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).