heroku / libcnb.rs

A framework for writing Cloud Native Buildpacks in Rust
BSD 3-Clause "New" or "Revised" License
34 stars 6 forks source link

Cross-compilation assistance: Some architecture/target combinations use the GNU GCC binary instead of the MUSL one #724

Open edmorley opened 10 months ago

edmorley commented 10 months ago

In #577 support was added for Linux aarch64, however, the GCC binary name used was aarch64-linux-gnu-gcc rather than the MUSL variant (in this case aarch64-linux-musl-gcc) used by all of the other target/host combinations: https://github.com/heroku/libcnb.rs/blob/4ec39b6fdf171f4f241f2d1fb3c3443b3cec53e6/libcnb-package/src/cross_compile.rs#L64

I believe this is an unintentional bug. (If instead there is a reason for it, it needs to have a comment added.)

edmorley commented 10 months ago

Checking an ARM64 Ubuntu 22.04 image with musl-tools installed, I see that aarch64-linux-musl-gcc does exist, and that it does differ from aarch64-linux-gnu-gcc - which confirms my belief that we should be using the former instead.

The gnu variant is simply a symlink to standard GCC:

root@5d2e9841af3b:/# ls -al /usr/bin/aarch64-linux-gnu-gcc
lrwxrwxrwx 1 root root 6 Aug  5  2021 /usr/bin/aarch64-linux-gnu-gcc -> gcc-11

Whereas the musl variant is this wrapper script:

root@5d2e9841af3b:/# cat /usr/bin/aarch64-linux-musl-gcc
#!/bin/sh
exec "${REALGCC:-aarch64-linux-gnu-gcc}" "$@" -specs "/usr/lib/aarch64-linux-musl/musl-gcc.specs"