-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix incorrect LLVM Linkage enum #36200
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (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. |
@bors: r+ 5897dcc8bba54ebd382a0fbf7afa20ea7b790963 Thanks! |
5897dcc
to
4ce90a2
Compare
4ce90a2 - Fixed tidy |
@bors: r+ |
📌 Commit 4ce90a2 has been approved by |
…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
This failed as part of the rollup:
|
But |
To quote the llvm source file case GlobalValue::ExternalWeakLinkage:
llvm_unreachable("Should never emit this");
} So it's probably just that one linkage type which needs to be removed from the test. |
|
||
extern "C" unsigned LLVMRustGetLinkage(LLVMValueRef V) { | ||
switch (LLVMGetLinkage(V)) { | ||
case LLVMExternalLinkage: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use an enum (see LLVMRustDiagnosticKind
).
@TimNN AppendingLinkage is part of the same case and should also be removed, I guess. |
4ce90a2
to
cd6cad1
Compare
Updated to address issues. |
@@ -49,6 +49,10 @@ pub enum CallConv { | |||
|
|||
/// LLVMLinkage | |||
/// | |||
/// This does not attempt to mirror the similar enum in LLVM, as this is fragile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: comment should be just /// LLVMRustLinkage
- see e.g. LLVMRustAsmDialect
. While you're at it, maybe also convert the other non-LLVMRust enums before they bite us?
cd6cad1
to
71c9d11
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. 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. Fixes rust-lang#33992
71c9d11
to
b9a8c1a
Compare
Nits addressed, tests fixed, tidy passed, travis works! 🍀 |
@bors r+ |
📌 Commit b9a8c1a has been approved by |
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
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
andLLVMRustSetLinkage
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:
The test does not exercise theAppending linkage is not 'emittable' anyway.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.Fixes #33992
r? @alexcrichton