juliaup icon indicating copy to clipboard operation
juliaup copied to clipboard

Link crt statically on Linux

Open davidanthoff opened this issue 3 years ago • 5 comments
trafficstars

davidanthoff avatar Aug 06 '22 23:08 davidanthoff

Note that regardless of what platform we build these on, we should be testing them on x86-linux-gnu, because we need to make sure that our binaries work on systems that have glibc on the system (and do not have musl on the system).

It's fine to test on x86_64-linux-musl, as long as we also test on x86_64-linux-gnu.

DilumAluthge avatar Aug 07 '22 02:08 DilumAluthge

Right now I'm under the impression that we can either link glibc or musl statically. If that holds for all the platforms, which one should we chose? glibc somehow seems the safer option to me, or not?

davidanthoff avatar Aug 07 '22 02:08 davidanthoff

The original suggestion for all of this from @SaadiSave had the following additional arguments:

-Clto=fat -Cembed-bitcode=yes

@SaadiSave should we use those? It is not clear to me what they do :)

The other open question is: are we ok to just statically link glibc here? Would there be any benefit in using musl instead? @DilumAluthge any thoughts on that?

davidanthoff avatar Aug 07 '22 03:08 davidanthoff

I'm far from an expert here, but it was my understand that glibc cannot be linked statically without breaking some things.

DilumAluthge avatar Aug 07 '22 04:08 DilumAluthge

The original suggestion for all of this from @SaadiSave had the following additional arguments:

-Clto=fat -Cembed-bitcode=yes

@SaadiSave should we use those? It is not clear to me what they do :)

@davidanthoff

lto is link-time-optimization embed-bitcode is required for lto to work

LTO not really required, that's just what I use when building locally. But it might provide a speed boost because the compiler will be able to inline more and eliminate more dead code and unused branches. Upto you whether you want to use it. It also doesn't work best with dynamically linked targets, which is what the other targets for juliaup are. But with x86_64-unknown-linux-musl, I'd recommend enabling it.

The other open question is: are we ok to just statically link glibc here? Would there be any benefit in using musl instead? @DilumAluthge any thoughts on that?

My original suggestion had the target x86_64-unknown-linux-**musl**. Static linking doesn't work well with glibc, while musl is designed for static linking. You should do it for all linux targets where it's working, e.g. aarch64 or i686.

SaadiSave avatar Aug 07 '22 04:08 SaadiSave

Hopefully this fixes https://github.com/JuliaLang/juliaup/issues/321.

cossio avatar Oct 15 '22 21:10 cossio

Merged a different version of this on main.

davidanthoff avatar Nov 25 '22 22:11 davidanthoff