firasuke / mussel

The shortest and fastest script to build working cross compilers targeting musl libc
ISC License
88 stars 12 forks source link

Feature/Discus request regarding canadian-cross compiling the toolchain #27

Open BlackDex opened 6 months ago

BlackDex commented 6 months ago

Hello there,

Because discussions is not enabled for this repo, I place it here, as it's not an issue.

I wonder if someone every tried to do a canadian-cross compile with this? What my main goal is.

This way it would be possible to build cross-compilers for all the provided targets but then are able to run on a arm64/aarch64 host/architecture.

Else something like QEMU needs to be used to emulate the aarch64 architecture, which is probably not going to provide the best performance.

Someone an idea, or tried this before either using mussel or something else? And if so, does someone have any pointers?

Thanks in advance!

btw. I already tried to install the aarch64-linux-gnu-g** cross compilers, use that as GCC/G++ and added the correct --host and --build arguments to the configure commands.

ghost commented 5 months ago

I'm a bit confused here. So you're trying to build on x86_64-linux-gnu, for armv6-linux-musleabihf? or are you trying to build on aarch64-linux-gnu?

BlackDex commented 5 months ago

The host which is building the binary is x86_64 The build target, so for which arch the final binary will be is armv6 And the target host is aarch64.

So in the end we would have a musl gcc compiler which runs on aarch64 and compiles to armv6 but all was build first on a x86_64.

ghost commented 5 months ago

So in the end we would have a musl gcc compiler which runs on aarch64 and compiles to armv6 but all was build first on a x86_64.

Thanks for clarifying. The script doesn't currently self-host, but what you could probably do is 1) Build a toolchain targetting aarch64-linux-musl as usual. 2) Using that toolchain, build whatever libraries are needed to build GCC (eg. zlib, libzstd, libatomic) for aarch64-linux-musl. 3) After the first-pass toolchain has access to the required libraries, edit the ./configure invocations for GCC & binutils and add --build=aarch64-linux-musl. After that, build a toolchain targetting armv6-linux-musleabihf.

In step 3, you'll need to run mussel.sh on compatible hardware since once the new armv6-linux-musleabihf compiler won't run on x86_64, but on aarch64. So, to answer your question, you'd either need access to an armv8 host or qemu-aarch64 to emulate it, at least as far as I know. Hope this helps.

firasuke commented 4 months ago

Because discussions is not enabled for this repo, I place it here, as it's not an issue.

I have enabled discussions for this repo, feel free to use it.