-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable zlib in LLVM on Haiku #75655
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
Wow, okay, at this point I'm leaning towards disabling zlib entirely until we can provide a workaround, this is just too many platforms which are broken when enabling it. Given that the original use case is other compilers generating compressed artifacts, I'm inclined to say that we should just revert the original enable. @jethrogb - do you think that's reasonable? Do we know if those compilers generating compressed artifacts can be made to not do so? I'm also nominating for T-compiler, to see what thoughts on this are with a larger set of people (though maybe we'll find some solution by Thursday anyway). |
For
The problems with zlib seem to mostly (only?) affect tier 2 and lower platforms. The problem also seems limited to however rustbuild includes LLVM/zlib in the link, because clearly zlib should “just work” on most platforms. I think we should take a tiered approach here with the goal to support zlib as much as possible. In particular, I don't think tier 1 platforms should have reduced functionality because tier 2/3 platforms don't have their rustbuild configured correctly. Proposal: Tier 1: Keep zlib and guarantee that it will link correctly on tier 1 platforms. |
AFAICT doing something like https://github.com/rust-lang/rust/pull/75625/files#diff-b0767d8366aa7e0a83a847d53032dfd4R200 should fix that. I'll try with netbsd. |
So I am aware Haiku very much is a tier 3 platform. Like most platforms (if not all except windows), we do ship libz as a default. Patching linking to libz in src/librustc_llvm/build.rs like @mati865 links to sounds fine to me. For Haiku it is indeed a runtime issue, and a link command will probably fix that. I will write a fresh patch and build that overnight to see whether that will resolve the issue. |
Like @mati865 suggested, I altered the diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs
index 21b8080714c..d8a2d302168 100644
--- a/src/librustc_llvm/build.rs
+++ b/src/librustc_llvm/build.rs
@@ -189,6 +189,10 @@ fn main() {
if !is_crossed {
cmd.arg("--system-libs");
+ } else if target.contains("haiku") {
+ // LLVM is built with LLVM_ENABLE_ZLIB as on, which means it should
+ // link to libz.so on Haiku.
+ println!("cargo:rustc-link-lib=z");
}
cmd.args(&components); I am wondering whether:
|
|
This was discussed during the last compiler meeting, removing the nomination. |
The specific outcome from the meeting can be summarized like so:
|
Good that we can fix it, but it is unclear to me whether the preference is to fix this by turning off More fundamentally, I wonder to what extend the problem appears because Haiku is always cross-compiled. And whether this is an issue for all cross-compiled rustc instances. |
I don't think this is necessary, spuriously linking should be fine for now -- and realistically we shouldn't need to turn it off ever I think?
I don't think it will. AFAIK, the zlib support in LLVM isn't used by Rust itself, just the LLD we ship -- so even if we are compiling with an LLVM that doesn't support zlib that'll likely just mean that the built rust-lld is less featureful but shouldn't affect Rust itself. Presumably distros that ship non-zlib supporting LLVM also ship gcc and clang that don't produce zlib-needing binaries for linking, or at least if not, can be convinced to alter one or the other. I would be happy to r+ the patch you suggested, presuming you've tested it. |
Are you sure about this? Because I encountered the issue not during build, but during runtime (running
I think Haiku does not explicitly use compressed sections in elf libraries (I doubt our toolchain supports it), so we should be good. The patch was manually tested and resolved the issue of not being able to run |
Ah, right. Yes, that makes sense. In that case we probably don't want to link it in by default, since presumably it isn't going to be available everywhere, though doing it on particular platforms where it is reasonable to expect it might not be too bad. I'm not sure what platforms would qualify though. Just to clarify, you think the PR in its current state is sufficient for Haiku? I'm happy to r+ it if so. |
I will update this patch once PR #75713 lands. |
☔ The latest upstream changes (presumably #75713) made this pull request unmergeable. Please resolve the merge conflicts. |
PR rust-lang#72696 enabled the option LLVM_ENABLE_ZLIB for the LLVM builds. On Haiku, zlib is linked as a shared library. When cross-compiling LLVM, rustbuild should be instructed to explicitly linking to libz.
a555195
to
0f6bcb7
Compare
Updated patch that uses the same code path as netbsd. |
@Mark-Simulacrum This change is ready for review. |
@bors r+ |
📌 Commit 0f6bcb7 has been approved by |
☀️ Test successful - checks-actions, checks-azure |
On native builds `llvm-config` picks up `zlib` and this gets pased into the rust build tools, but on cross builds `llvm-config` is explicitly ignored as it contains information for the host system and cannot be trusted to be accurate for the target system. Both DragonFly and Solaris contain `zlib` in the base system, so this is both a safe assumption and required for a successful cross build unless `zlib` support is disabled in LLVM. This is more or less in the same vein as rust-lang#75713 and rust-lang#75655.
…-libz, r=cuviper rustc_llvm: Link to `zlib` on dragonfly and solaris On native builds `llvm-config` picks up `zlib` and this gets pased into the rust build tools, but on cross builds `llvm-config` is explicitly ignored as it contains information for the host system and cannot be trusted to be accurate for the target system. Both DragonFly and Solaris contain `zlib` in the base system, so this is both a safe assumption and required for a successful cross build unless `zlib` support is disabled in LLVM. This is more or less in the same vein as rust-lang#75713 and rust-lang#75655.
…-libz, r=cuviper rustc_llvm: Link to `zlib` on dragonfly and solaris On native builds `llvm-config` picks up `zlib` and this gets pased into the rust build tools, but on cross builds `llvm-config` is explicitly ignored as it contains information for the host system and cannot be trusted to be accurate for the target system. Both DragonFly and Solaris contain `zlib` in the base system, so this is both a safe assumption and required for a successful cross build unless `zlib` support is disabled in LLVM. This is more or less in the same vein as rust-lang#75713 and rust-lang#75655.
…-libz, r=cuviper rustc_llvm: Link to `zlib` on dragonfly and solaris On native builds `llvm-config` picks up `zlib` and this gets pased into the rust build tools, but on cross builds `llvm-config` is explicitly ignored as it contains information for the host system and cannot be trusted to be accurate for the target system. Both DragonFly and Solaris contain `zlib` in the base system, so this is both a safe assumption and required for a successful cross build unless `zlib` support is disabled in LLVM. This is more or less in the same vein as rust-lang#75713 and rust-lang#75655.
PR #72696 enabled the option LLVM_ENABLE_ZLIB for the LLVM builds. Like NetBSD and aarch64-apple-darwin (see PR #75500), the LLVM build system not explicitly linking to libz on these platforms cause issues. For Haiku, this meant the runtime loader complaining about undefined symbols..