-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Build librustc_llvm
as a dylib, and install it as part of the private rustc crates.
#50404
Conversation
r? @aturon (rust_highfive has picked a reviewer for you, use r? to override) |
7c58713
to
246e041
Compare
We currently intentionally don't do this to cut down on the complexity of codegen backends and the number of files we're shipping, can you elaborate on why we might want to do this? |
☔ The latest upstream changes (presumably #50200) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage @DiamondLovesYou! It's been a while since we heard from you, will you have time to work on this again soon? |
@alexcrichton The intent is to allow a runtime library to be able to use |
Hm I'm not sure I really fully understand that use case? Changing our distribution strategy is a pretty major change for us, so if the other option is to refactor code here to make it more amenable to what you'd like to do I think we'd much prefer to go down a route like that. |
…te rustc crates. I had to remove `librustc_llvm`'s dependence on the `libc` crate as a part of this. This seems reasonable as the global changes required were quite minimal. Fix an FFI bug: `Bool` is signed.
246e041
to
8359491
Compare
Well, what's confusing? Maybe I'm not describing things as well as I could/should. The metadata is the normal Rust crate metadata, which a modified This installs a new dylib into an existing folder which is already shipped, which already contains rustc private crates. This shouldn't be a big change to your distribution strategy. Additionally, LLVM is not small, I'd rather not have to duplicate it in my libraries. |
@alexcrichton I looked into whether I could just have I'm open to suggestions. |
@DiamondLovesYou are you loading different codegen backends on the fly? Sorry I still don't understand what you're doing and what would necessitate a change such as this. For example why does todays' construction not work? What's the error message? This is not a simple change because it's another quite large library for the dynamic loader to deal with at runtime. This means we need to actually ship this dynamic library (as you've found with the changes to the bootstrap system) and make sure it ends up in the right location and doesn't conflict with anything else. For example are we sure that the Emscripten LLVM doesn't conflict with the LLVM 6 LLVM? Additionally our runtime already took a pretty big hit just moving to a I don't think a change like this is impossible but I would personally prefer to understand in more detail what it's going to be used for, why it should be in rustc itself and affect the official distribution, and also information like the performance impact of the change |
Ping from triage @DiamondLovesYou! The reviewer asked a question, will you have time to reply soon? |
@pierzchalski Yes, will answer Soon(TM). |
Looks like "pie" is not a discriminating prefix, cc @pietroalbini |
@pierzchalski Oh indeed! And I didn't check it like I should have. My bad. |
I'm just using a single codegen backend (the main LLVM one), but I am loading it on the fly. I have not tried using, eg, Anyway, consider this: when the LLVM codegen backend is loaded: existing, defined, symbols already present in the exe will override symbols loaded from the codegen backend object. To quote
That's a problem if the LLVM versions aren't the same. And we know they're not: Rust uses it's own fork! In summary, I haven't encountered any error because I specifically sought to find a solution that avoids this can of worms. Note this next quote is split:
The same is true of the codegen backend. First, the tax of searching is trivial: A good question would be, "then why does chrome statically link, if not because it's faster?" Well because it is faster, but only when done en-mass. In chrome’s case, because they link everything together, the linker is allowed to assign relocation entries statically. In our case, the fact that the codegen backend module is dynamically linked means that optimization doesn't apply, even though LLVM is linked statically within the codegen backend. In other words, the codegen backend would need to be statically linked all the way up the tree for there to be any benefit. As a sanity check, I’ve ran builds of both this PR and the commit it’s currently based on. I ran the builds for both 4 times. There was no significant difference between them. Dynamically linking averaged 33:45, while statically linking averaged 33:35. Or less than ½ of a percent.
I can say from my own experience, due to a nasty hack I use to get cargo to recompile things after I’ve rebuilt part of the Rust toolchain (particularly Regarding shipping: I’m not sure what, specifically, your concern is. The changes to that part of the build just ensure that the
I’ve run the tests with the Emscripten backend enabled, including generating dist packages. Emscripten's |
Note that this conflicts with the "merge |
☔ The latest upstream changes (presumably #50698) made this pull request unmergeable. Please resolve the merge conflicts. |
Ping from triage, @DiamondLovesYou, @alexcrichton, @eddyb: What is the status of this? Is this blocked by / made impossible by #45274? |
Sorry I was away on vacation and hadn't responded yet, but I'm back now! @DiamondLovesYou I think I still don't fully understand why this change is necessary which is another source of my hesitation to land a PR like this. The OP has no information about why we would do a change like this. A later explanation sounds like you both want to not use the rustc LLVM and also use two LLVM instances at the same time? It then later sounds like you don't want to duplicate LLVM so you only want one LLVM, but the rustc LLVM? Sorry I'm still lost in understanding what the purpose here is. I would personally love to continue to reduce the dynamic libraries associated with rustc as they're already way too much. If |
@alexcrichton No worries! This can be closed, actually. The issue with involuntary loading multiple LLVM dynlib versions is still technically present (and I see that LLVM was just upgraded to the unreleased 7.0 version...), but it won't affect me now that I've discovered this wonderful crate. I'm disinclined to pursue. |
Ok! |
I had to remove
librustc_llvm
's dependence on thelibc
crate as a part ofthis. This seems reasonable as the global changes required were quite minimal.
Fix an FFI bug:
Bool
is signed.