musl-cross-make
musl-cross-make copied to clipboard
How to cross-build a NATIVE compiler?
I need to cross-build a NATIVE compiler for mipsel setting:
TARGET = mipsel-linux-musl
NATIVE = Yes
results in error (compiler not found.
I am now copmiling using just TARGET = mipsel-linux-musl
, but that should produce a cross-compiler running on my host machine, right?
Should I use that to build the native?
Can someone point me to relevant docs, please?
Compilation ended without errors, but make install
raise error:
...
/usr/bin/install -c -m 644 macro_list /lib/gcc/mipsel-linux-musl/6.4.0/install-tools/macro_list
/usr/bin/install -c -m 644 fixinc_list /lib/gcc/mipsel-linux-musl/6.4.0/install-tools/fixinc_list
set -e; for ml in `cat fixinc_list`; do \
multi_dir=`echo ${ml} | sed -e 's/^[^;]*;//'`; \
/bin/bash ../../src_gcc/gcc/../mkinstalldirs /lib/gcc/mipsel-linux-musl/6.4.0/install-tools/include${multi_dir}; \
/usr/bin/install -c -m 644 include-fixed${multidir}/limits.h /lib/gcc/mipsel-linux-musl/6.4.0/install-tools/include${multi_dir}/limits.h; \
done
/usr/bin/install: cannot stat 'include-fixed/limits.h': No such file or directory
make[2]: *** [Makefile:3639: install-mkheaders] Error 1
make[2]: Leaving directory '/home/mcon/vocore/prove/musl/musl-cross-make/build/local/mipsel-linux-musl/obj_gcc/gcc'
make[1]: *** [Makefile:4191: install-gcc] Error 2
make[1]: Leaving directory '/home/mcon/vocore/prove/musl/musl-cross-make/build/local/mipsel-linux-musl/obj_gcc'
make: *** [Makefile:2279: install] Error 2
Any suggestion?
results in error (compiler not found.
this is the most relevant point in your report, yet the least detailed.
I am now copmiling using just TARGET = mipsel-linux-musl, but that should produce a cross-compiler running on my host machine, right?
correct
I'd like to build the same kinda "native" compiler too, for android. If compiling gcc with the "configure" script, I need to provide the option
--build=x86_64-linux-gnu --host=aarch64-linux-android --target=aarch64-linux-android
~~but I have no idea how to let this build system pass these arguments to "configure".~~
~~Any advice would be appreciated.~~
EDIT:
I've found out one way to do it.
In my case, I've copied config.mak.dist to config.mak, added TARGET = aarch64-linux-musl
and HOST = aarch64-linux-musl
to it, uncommented COMMON_CONFIG += CC= ... CXX= ...
, and changed them to the cross-compilers I've built earlier. Finally saved the file and issued the "make" command to build it like usual, and it eventually produced the native compiler.
Maybe you can try like this, but have all "aarch64-linux-musl" replaced with "mipsel-linux-musl". It should work too.
So, if I understand and want a native x86_64 compiler, you firstly build a cross compiler with TARGET = x86_64-linux-musl
, then build a native compiler with: TARGET = x86_64-linux-musl
, NATIVE = Yes
and make PATH=$PWD/output/bin:/usr/bin
.
But the compiler that I get use a relative sysroot.
I tried GCC_CONFIG += --with-build-sysroot=/
when compiling the native one, in vain.
Minimal system on qemu:
x86_64-linux-musl-gcc -print-sysroot: ../
x86_64-linux-musl-gcc -print-prog-name=cc1: ../libexec/gcc/x86_64-linux-musl/6.4.0/cc1
Because of this, I cannot compile if I am two level above root.
How do I specify an absolute path (/
)?
@concatime
What is your build machine's architecture? If it's x86_64, compiling with TARGET = x86_64-linux-musl
will produce the native compiler you needed directly, there's no need to use qemu.
I want to make a musl-based light distro. So for that, I need a compiler for this distro.
Building directly like you said will generate a compiler linked with my host libraries (/usr/lib/libm.so.6
, /usr/lib/libc.so.6
, etc.), which is not what I want.
You can build again with CC/CXX pointed at the toolchain you have just got after the first pass.
(Well... How did my message jump to the upside? ;p)
I think that I resolved the issue.
I installed with make install
, which generated output-x86_64-linux-musl/
.
Then I compiled statically dash and copied it into output-x86_64-linux-musl/bin/
as sh
.
Then I chrooted into that folder with sudo chroot output-x86_64-linux-musl/ /bin/sh
.
Inside, when I executed bin/x86_64-linux-musl-gcc -print-prog-name=cc1
, the result was bin/../libexec/gcc/x86_64-linux-musl/6.4.0/cc1
, which is not an absolute path!
To resolve this, I had to mount /proc
with busybox mount -t proc none /proc
(which I compiled and copied).
After that, the result from bin/x86_64-linux-musl-gcc -print-prog-name=cc1
was /libexec/gcc/x86_64-linux-musl/6.4.0/cc1
, which is what I was expecting from the beginning.
Can someone explains me this behaviour?
(lol, why my older message is after yours??) EDIT: WTF, now my older message is below..