-
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
Enable link-shared for LLVM on non-Windows targets #76708
Conversation
@bors try This has a second commit which enables macOS and Windows try builders so that we can hopefully make sure that things work without waiting for a full local build. |
⌛ Trying commit 1ffb3c170e223980509ec8c8a7ec734e8c4ddf10 with merge 2d7e7d3397bb4d7fda21c806662de7a714cdc4c1... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-actions |
1ffb3c1
to
a6394d2
Compare
@bors try |
⌛ Trying commit a6394d2b8167631e8bff8946da6c2b64bdb34383 with merge 8a552637288ac264194163f7294832fbd89f7836... |
Hm I may be a bit confused. IIRC there is weirdness of how the dynamic library is named on macos compared to other platforms, but I think all both Linux and mac are dynamically linked? I thought it was just windows that was static |
We don't set link-shared on macOS, and on linux it's only implicitly set by enabling ThinLTO with LLVM. It seems like on macOS though the compiler itself isn't linked dynamically to LLVM, as otherwise current nightly wouldn't work, as it lacks any libLLVM.dylib. It seems like the libLLVM.dylib on macOS today is just for rust-lld and other LLVM tools. |
☀️ Try build successful - checks-actions, checks-azure |
I have confirmed that on latest nightly |
Hm ok, I don't really understand what's going on here then. That feels like a bug that macOS is not linked dynamically (but only rust-lld is?), we ideally want all the platforms to be consistent. IIRC the reason Windows doesn't do this is that LLVM's build system doesn't really support generating a shard library (I don't know why though). Assuming though that this bug is set aside and we try to just fix nightlies, the previous conditional check I believe is correct. The comment makes sense and it I think is what we want, I believe that the bug should probably be fixed elsewehere in the configuration step of rustbuild to ensure that rustbuild doesn't erroneously think that on Windows and macOS LLVM is dynamically linked. |
a6394d2
to
f556e83
Compare
f556e83
to
baf0b90
Compare
I don't personally have a Windows machine to test on -- I'd be interested in finding out if/how the llvm tools there work (or not) on current nightly. Judging by their size, they definitely don't include a full LLVM, but we don't ship a libLLVM dll anywhere that I can see. Presumably they work though? Maybe not? That issue aside (since we should probably fix nightlies before tackling Windows, unless there's a solution covering both)... It looks like rust-lld (and presumably all the other LLVM tools) are just broken on every target right now except x86_64-unknown-linux-gnu (and Windows, if they ever worked), because that's the only one that enables a shared LLVM in CI I think (and even then, indirectly through enabling LLVM ThinLTO). We could just try to enabling link-shared on all platforms except for Windows in CI, which presumably would fix this? I'm not sure if that's precisely the right fix. I've pushed up a commit that does so (see the commit message for some explanation as well as this comment). Interested to hear what you think! |
@bors try Thought I'd kick off a try build so we can at least see if this is just completely not going to work... |
⌛ Trying commit 3384b515966f9186cc75952d23305ccf42dd5cc1 with merge 5faa03252d364b6903d28d52397c0a22a5c91f9b... |
☀️ Try build successful - checks-actions, checks-azure |
I don't have a Windows machine either, but for my |
FWIW they're statically linked with LLVM, and they work for me at least locally.
I believe this is corret, yeah, and I think ideally we'd just generate an error in rustbuild trying to set link-shared on Windows since I don't think it works at all. In any case r=me with the tweak to CI config since I think that's what we want to do on macOS anyway |
Windows doesn't quite support dynamic linking to LLVM yet, but on other platforms we do. In rust-lang#76708, it was discovered that we dynamically link to LLVM from the LLVM tools (e.g., rust-lld), so we need the shared LLVM library to link against. That means that if we do not have a shared link to LLVM, and want LLVM tools to work, we'd be shipping two copies of LLVM on all of these platforms: one in librustc_driver and one in libLLVM. Also introduce an error into rustbuild if we do end up configured for shared linking on Windows.
3384b51
to
f001a0c
Compare
Hm, interesting. I guess they are quite a bit bigger than on linux targets, so that makes sense. I was sort of expecting ~80 MB each but I guess they're not linking to a good part of LLVM so that's why they're much smaller. Dropped the try build commits and added a panic! on windows and link-shared configured, so that should be ready to go. @bors r=alexcrichton rollup=never This is somewhat likely to bounce I suspect once or twice as we work out any bugs, and in any case is nice to be able to bisect to in case of regressions. |
📌 Commit f001a0c has been approved by |
Ah yeah the tools that bring in codegen libraries are bigger (e.g. llc, opt, lld, etc), but the binary inspection tools benefit from gc in linkers and are pretty small (they don't benefit much from dynamic linking) |
FWIW LLVM does support it in MinGW mode (and it works fine) but we cannot use it since linking to that shared libLLVM.dll would result in hangs because of old mingw-w64 version used on the CI (winpthreads bug). |
☀️ Test successful - checks-actions, checks-azure |
…crichton Don't dynamically link LLVM tools unless rustc is too This PR initially tried to support link-shared on all of our target platforms (other than Windows), but ran into a number of difficulties: * LLVM doesn't really support a shared link on macOS (llvm-config runs into problems with the version suffix) * LLVM doesn't seem to support a shared link when cross-compiling (the libLLVM.so ends up empty and symbols are not found) So, this PR has now been revised such that we don't attempt to dynamically link LLVM tools (even if that would, otherwise, be supported) on targets where LLVM is statically linked to rustc. Currently that's basically everything except for x86_64-unknown-linux-gnu (where we dynamically link to avoid rerunning ThinLTO in each stage). Follow-up to rust-lang#76708. Fixes rust-lang#76698.
Even when LLVM is not generally participating in a shared link with rustc, we
will likely still link to the shared dylib from rust-lld, so we still need to
promote it.
Hopefully fixes #76698.