f0rmiga / gcc-toolchain

A fully-hermetic Bazel GCC toolchain for Linux.
Apache License 2.0
103 stars 24 forks source link

Why build sysroot from source code #140

Open SWYZZWH opened 1 year ago

SWYZZWH commented 1 year ago

I'm just wondering if there are any concerns about building all packages from source code when constructing the sysroot. It would be significantly faster to directly use apt-get for the required packages and then extract them from /lib and /usr/lib directories. In terms of reproducibility, we can specify the versions of these packages during the apt-get process. To support different architectures, we can use QEMU as an emulator.

Riatre commented 1 year ago

First, this is more like a discussion instead of an issue.

From README.md:

When it comes to building portable ELF binaries, the libc plays an important role. The linker will try to link against new symbols, and since the GNU libc has symbol versioning, linking against a newer glibc will prevent that program from running on a system using an older glibc. To solve this, we ship glibc 2.26 with the sysroots, which should be old enough by now to make all programs compiled with this toolchain portable.

We need a specific version of glibc in the sysroot, which may or may not match the one shipped by your (or any) distro.

f0rmiga commented 1 year ago

Thanks @Riatre for the answer. To add one more bit that's not in the README, I found that libgfortran.a from the Ubuntu distro (IIRC) is unusable. Even though it's provided, I remember facing issues during linking.

Having everything built from source gives more freedom to overcome this kind of issue more quickly. I'm always happy to discuss any concerns people may have when building from source, but so far, I only got good feedback from it.

@SWYZZWH Anything specific that comes to your mind that's concerning?