Subject: Availability of cross toolchains in aports

From: "Drew DeVault" <[email-masked]>
Date: Wed, 16 Feb 2022 11:27:54 +0100

I think that we should have a greater variety of cross compiler
toolchains available in aports, providing in reach repo at least enough
cross-compilers to build Alpine for any target supported by a stable
Alpine release.

Thoughts?

---

From: Dominique Martinet <[email-masked]>
Date: Wed, 16 Feb 2022 20:11:19 +0900

> cross-compilers to build Alpine for any target supported by a stable

Thanks for starting this thread!

I'd definitely agree to this, after spending a bit of time on it myself
for work (building some local aarch64/armhf packages)
It's easy enough to rebuild the cross environment with aports's
scripts/bootstrap.sh, but that's not very practical for CI environment.

After a bit of looking I've started using the cross compilers from pmos
repos here:
http://pkgs.postmarketos.org/package/master/postmarketos/x86_64/gcc-aarch64
http://pkgs.postmarketos.org/package/master/postmarketos/x86_64/gcc-armhf

which does the job, but if there is a viable alternative within the main
repos I'd be very happy to switch to it.

Cheers,
-- 
Asmadeus | Dominique Martinet

---

From: Sören Tempel <[email-masked]>
Date: Wed, 16 Feb 2022 14:52:22 +0100

Hi,

> cross-compilers to build Alpine for any target supported by a stable

Thanks for raising this issue. I definitely agree that cross compiler
toolchains for supported architectures would be nice to have in the
repositories.

My two cents on this: In my view cross compilation becomes a lot easier
when using Clang instead of GCC (i.e. you can just pass -target instead
of maintaining separate GCC toolchains for different architectures [1]).
As such, it is already possible today to cross compile C/C++ object
files with Clang on Alpine (e.g. `clang -c -target aarch64-alpine-linux-musl`).
Linking is a different story though and furthermore aports.git does not
really support compilation with Clang at the moment. However, there
have been occasional discussions on IRC if Alpine should switch from GCC
to Clang anyhow. Maybe this yet another argument for this switch?

Greetings,
Sören

[1]: https://clang.llvm.org/docs/CrossCompilation.html#cross-compilation-issues

---

From: David Demelier <[email-masked]>
Date: Wed, 16 Feb 2022 20:11:50 +0100

> On 16 Feb 2022, at 14:52, Sören Tempel <[email-masked]> wrote:
> 
> However, there have been occasional discussions on IRC if Alpine should switch from GCC

I’m currently creating a Linux distribution similar to Alpine in spirit but it’s based on a fully LLVM environment (not even libgcc or binutils) and I can tell you that it’s a total nightmare.

Many packages use gcc extensions and do not compile fine under clang. Even though I strongly advise clang as default compiler, it still requires a non neglecting patch sets.

— 
David

---

From: David Demelier <[email-masked]>
Date: Wed, 16 Feb 2022 20:09:47 +0100

> On 16 Feb 2022, at 11:27, Drew DeVault <[email-masked]> wrote:
> 

clang is by itself a cross-compiler. basically one can setup an environment by grabbing a minirootfs and extract alpine packages itself and then using appropriate command line options you’re pretty much done:

clang --sysroot=/alpine-aarch64 -target alpine-aarch64-linux-musl -fuse-ld=lld test.c -o test

boum, test is aarch64 executable.

Nothing more, nothing less.

That said cross-compiling is still pretty much utopia. Some packages build executables that they run during the build process, having to specify a host compiler and a target compiler which many build system don’t support. Not mentioning that many software just don’t care.

I don’t think spending effort on this is any useful.

— 
David

---

From: Kaarle Ritvanen <[email-masked]>
Date: Thu, 24 Feb 2022 23:44:16 +0200 (EET)

> cross-compilers to build Alpine for any target supported by a stable 

I think this would be nice. In 2018, I actually tried to do this in a 
GCC-compatible way:

https://lists.alpinelinux.org/~alpine/devel/%3Calpine.LFD.2.21.1810191534530.26297%40kanala.kunkku.net%3E

However, doing it properly would have required massive refactoring of 
abuild. I gave up because I did not have the time.

BR,
Kaarle