-
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
Support Option and similar enums as type of static variable with linkage attribute #104799
Conversation
r? @fee1-dead (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred in diagnostic error codes Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo
cc @davidtwco, @compiler-errors, @JohnTitor, @estebank, @TaKO8Ki |
This comment has been minimized.
This comment has been minimized.
Please fix the CI errors |
This comment has been minimized.
This comment has been minimized.
// Declare a symbol `foo` with the desired linkage. | ||
let global1 = cx.declare_global_with_linkage(&sym, llty2, base::global_linkage_to_gcc(linkage)); | ||
let global1 = cx.declare_global_with_linkage(&sym, cx.type_i8(), base::global_linkage_to_gcc(linkage)); |
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.
I don't think this is right.
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.
This might need to do something else with GCC, but I don't have a setup for testing the GCC backend.
I asked around on Zulip and I was told that developers do not need to keep the GCC backend working; their changes just needs to pass CI.
r? @tmiasko (I am not familiar with this area of the code) |
☔ The latest upstream changes (presumably #97485) made this pull request unmergeable. Please resolve the merge conflicts. |
Thanks, looks good. r=me after rebasing. |
This ensures that the error is printed even for unused variables, as well as unifying the handling between the LLVM and GCC backends. This also fixes unusual behavior around exported Rust-defined variables with linkage attributes. With the previous behavior, it appears to be impossible to define such a variable such that it can actually be imported and used by another crate. This is because on the importing side, the variable is required to be a pointer, but on the exporting side, the type checker rejects static variables of pointer type because they do not implement `Sync`. Even if it were possible to import such a type, it appears that code generation on the importing side would add an unexpected additional level of pointer indirection, which would break type safety. This highlighted that the semantics of linkage on Rust-defined variables is different to linkage on foreign items. As such, we now model the difference with two different codegen attributes: linkage for Rust-defined variables, and import_linkage for foreign items. This change gives semantics to the test src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was previously expected to fail to compile. Therefore, convert it into a test that is expected to successfully compile. The update to the GCC backend is speculative and untested.
…age attribute. Compiler MCP: rust-lang/compiler-team#565
@bors r+ |
⌛ Testing commit b4278b0 with merge 7d28a6aab16bd0c31e10f7aaf7bcfa9aa2f1d8af... |
💔 Test failed - checks-actions |
@bors retry (cancelled without logs) |
☀️ Test successful - checks-actions |
Finished benchmarking commit (91b8f34): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
|
…with linkage attribute" cc rust-lang/rust#104799
Support Option and similar enums as type of static variable with linkage attribute Compiler MCP: rust-lang/compiler-team#565
Compiler MCP:
rust-lang/compiler-team#565