Stream: t-compiler

Topic: musl toolchain and proc macros


Laurențiu Nicola (May 08 2020 at 07:06, on Zulip):

It seems to me that dlopen does not quite work on musl. But there is a musl Rust toolchain -- does anyone know how it's working?

bjorn3 (May 08 2020 at 08:34, on Zulip):

It seems that you need to disable crt-static (link musl dynamically) to get it working: https://github.com/rust-lang/rust/issues/31322

mati865 (May 09 2020 at 14:37, on Zulip):

Starting with 1.44 beta you shouldn't need anything special to make it work: https://github.com/rust-lang/rust/issues/40174

matklad (May 09 2020 at 14:56, on Zulip):

But, with -crt-static, the rust-analyzer itself would require musl to be present on the user's machine, right?

Like, it seems like it's fundamentally impossible to statically link libc, but be able to dlopen dynamic libraries, because the main executable and the loaded library need to use the same (dynamically loaded) libc?

mati865 (May 09 2020 at 17:02, on Zulip):

But, with -crt-static, the rust-analyzer itself would require musl to be present on the user's machine, right?

Correct. https://github.com/rust-lang/rust/pull/69519 gets around that by setting -crt-static only for proc_macros (which are only used during compilation). This only takes effect on musl based systems, on glibc systems proc_macros are build for ${arch}-unknown-linux-gnu target.

Like, it seems like it's fundamentally impossible to statically link libc, but be able to dlopen dynamic libraries, because the main executable and the loaded library need to use the same (dynamically loaded) libc?

Yes, AFAIK.

Josh Triplett (May 09 2020 at 20:38, on Zulip):

It's more or less safe to do so, as long as you don't resolve any network names or user names or similar; a statically linked glibc still dynamically loads NSS modules.

Vadim Petrochenkov (May 10 2020 at 01:04, on Zulip):

I'm going to revert https://github.com/rust-lang/rust/pull/69519 though and do it in a slightly more general and more conservative way.

Vadim Petrochenkov (May 10 2020 at 01:07, on Zulip):

Just need to finish some reading - https://gist.github.com/petrochenkov/1a2e52b01a71d49d908756e194d3c3d9. This is a truly wonderful story.

Vadim Petrochenkov (May 10 2020 at 01:12, on Zulip):

The sooner the better, https://github.com/rust-lang/rust/pull/69519 is harmful for future-compatibility (besides just being hacky).

Vadim Petrochenkov (May 10 2020 at 15:09, on Zulip):

Vadim Petrochenkov said:

https://github.com/rust-lang/rust/pull/69519 is harmful for future-compatibility

Strike that, #69519 only allows proc macro crates if crt-static = true comes from target defaults, but not from explicitly passed options.
Phew.

Last update: May 29 2020 at 17:05UTC