-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
[WIP] Fix incorrect LLVM Linkage enum #33994
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Aatch (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Ah the test looks like it may fail for two reasons:
|
Thanks for the PR though! The fix looks fine to me :) |
Since this enum has changed it will break compatibility with any older versions of LLVM right? Should we also change the configure script to reject older LLVM versions? |
Oh I was assuming that we just never had the right definition. If this changed in LLVM over time, though, then we should define our own enum with our own discriminants and then translate in C++ to the LLVM symbolic names. |
@alexcrichton Good points. I'll update the PR once I actually get the tests to run locally... |
Turns out the build failures I was having were due to this change. I was basing the enum values off of the github master branch of the llvm repo and that is very different from the submodule included in the rust distribution. After double-triple-checking that the enum values line up between my local rust and the local rust's llvm, I get the following error about 100 times:
I can't find anywhere in the stdlib or compiler that AppendingLinkage is used, so this is very puzzling to me. It seems this change is not as simple as I had thought. |
3611953
to
f04c77f
Compare
The `Linkage` enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the #[linkage=""] attribute to break. Fixes rust-lang#33992
f04c77f
to
3e0f018
Compare
Oh that may just be a case that's OK to elide, appending linkage I think is a pretty special LLVM-ism |
@alexcrichton I'll try that. You mentioned translating the rust enum to the LLVM enum in C++, would that code go in librustllvm? |
@mattico yeah, I was thinking something like: // src/librustc_llvm/lib.rs
pub enum RustLinkage {
External,
// ...
} void SetLinkage(LLVMValue V, unsigned RustLinkage) {
switch (RustLinkage) {
case 0:
SetLLVMLinkage(v, LLVMExternalLinkage);
break;
// ...
}
} (or something like that) |
Closing due to inactivity, but feel free to reopen with comments addressed! |
…chton Fix incorrect LLVM Linkage enum Followup of rust-lang#33994 to actually work. The `Linkage` enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the `#[linkage=""]` attribute to break. This adds the functions `LLVMRustGetLinkage` and `LLVMRustSetLinkage` which convert between the Rust Linkage enum and the LLVM one, which should stop this from breaking every time LLVM changes it. Possible remaining concerns: 1. There could be a codegen test to make sure that the attributes are applied correctly (I don't know how to do this). 2. The test does not exercise the `appending` linkage. I can't figure out how to make a global static raw pointer to an array. This might not even be possible? If not we should probably remove appending linkage as its unusable in rust. 3. The test only runs on Linux. Fixes rust-lang#33992 r? @alexcrichton
Fix incorrect LLVM Linkage enum Followup of #33994 to actually work. The `Linkage` enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the `#[linkage=""]` attribute to break. This adds the functions `LLVMRustGetLinkage` and `LLVMRustSetLinkage` which convert between the Rust Linkage enum and the LLVM one, which should stop this from breaking every time LLVM changes it. Possible remaining concerns: 1. There could be a codegen test to make sure that the attributes are applied correctly (I don't know how to do this). 2. ~~The test does not exercise the `appending` linkage. I can't figure out how to make a global static raw pointer to an array. This might not even be possible? If not we should probably remove appending linkage as its unusable in rust.~~ Appending linkage is not 'emittable' anyway. 3. The test only runs on Linux. Fixes #33992 r? @alexcrichton
The
Linkage
enum in librustc_llvm got out of sync with the version in LLVM and it caused two variants of the#[linkage=""]
attribute to break.Fixes #33992