Repository navigation
Conversation
|
cc @rust-lang/miri |
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| } else if codegen_fn_attrs.symbol_name.is_some() { | ||
| // * This can be overridden with the `#[link_name]` attribute | ||
| } else if codegen_fn_attrs.link_ordinal.is_some() { | ||
| // * `#[link_ordinal]` and `#[link_name]` are incompatible with each other |
There was a problem hiding this comment.
This is a behavior change. We no longer keep the symbol that Rust code refers to unmangled when #[link_ordinal] is used. This matches the behavior on wasm for #[wasm_import_section], but prevents overriding the symbol using a definition with an #[export_name] matching the name we have imported it as in the raw-dylib block. And it is inconsistent with non-ordinal imports through raw-dylib where we could also have used mangled names on our side.
There was a problem hiding this comment.
I think that makes sense, what's the process here? Nominate for t-lang and let them decide whether to accept this change?
There was a problem hiding this comment.
Ideally, separate refactors from behavior changes. Doing both in the same PR makes things more complicated to manage.
There was a problem hiding this comment.
It is non-trivial to keep the old behavior after this refactor. I could open a PR to change the behavior first.
There was a problem hiding this comment.
I think that would be better, yeah.
And it is inconsistent with non-ordinal imports through raw-dylib where we could also have used mangled names on our side.
It is unclear to me whether you are calling the old or new behavior inconsistent here.
There was a problem hiding this comment.
Ideally, separate refactors from behavior changes.
I think the current PR is small enough to get away with this, no need to split it up here.
However, you can probably simplify much more by lowering into the same attribute during attribute parsing instead. (that would be a more intrusive change where refactors and behavior changes should be split)
There was a problem hiding this comment.
It is unclear to me whether you are calling the old or new behavior inconsistent here.
The old behavior is consistent with non-ordinal imports on windows. The new behavior is consistent with imports on wasm, but not with non-ordinal imports on windows.
This comment has been minimized.
This comment has been minimized.
85e13aa to
d86eb41
Compare
d86eb41 to
22ac858
Compare
This comment has been minimized.
This comment has been minimized.
|
@rustbot reroll |
|
@rustbot reroll |
There was a problem hiding this comment.
My understanding here is that no_mangle is just a convenience for export_name = "<item_name>", is that correct? What is the interaction with link_name?
Although while reviewing I did notice that this is allowed:
pub trait Trait {
#[unsafe(export_name = "method")]
fn method(&self) {}
}but this emits a warning:
pub trait Trait {
#[unsafe(no_mangle)]
fn method(&self) {}
}This looks like a bug (none or both should be allowed here)
|
The exact change nominated for the lang team is #159374 (comment) Basically an item with The only uses of
Both of these refer to undocumented functions in |
Can you give an example of a piece of code that changed its meaning, and describe the old and new meaning? |
mod ffi {
#[link(name = "foo", kind = "raw-dylib")]
unsafe extern "C" {
#[unsafe(link_ordinal(7))] // Perhaps internally called MyFancyFunction when foo.dll was compiled
pub safe fn barf();
}
}
#[unsafe(no_mangle)]
extern "C" fn barf() {
println!("Override called");
}
fn main() {
ffi::barf();
}would previously cause the override to be called, but will now call ordinal export 7 of foo.dll like would have been the case without the override. |
|
Wow yeah the old behavior seems really strange there. I expected
This sounds like we are still doing the strange behavior in some other related case? |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
Oh, this also needs a reference PR, can you open one? |
|
Opened rust-lang/reference#2406 |
Lower #[no_mangle] to #[symbol_name]/#[link_name] This reduces the amount of special casing #[no_mangle] needs in the rest of the compiler. t-lang: [nomination comment](rust-lang#159374 (comment)), [example](rust-lang#159374 (comment))
Lower #[no_mangle] to #[symbol_name]/#[link_name] This reduces the amount of special casing #[no_mangle] needs in the rest of the compiler. t-lang: [nomination comment](rust-lang#159374 (comment)), [example](rust-lang#159374 (comment))
Rollup of 13 pull requests Successful merges: - #163477 (Fancy paramenv accessors that communicate the access pattern better.) - #160593 (turn ABI-controlling target features into a target modifier) - #164896 (offload: pass the linked device image to the host pass) - #165468 (Remove return type from `BuilderMethods::store`) - #159374 (Lower #[no_mangle] to #[symbol_name]/#[link_name]) - #164564 (Re-enable outline-atomics by default on more AArch64 platforms) - #164623 (add next-solver regression tests for two fixed ices) - #164678 (add next-solver regression test for recursive opaque ICE under validate-mir) - #165429 (Add tests for `-Zcrate-attr` edition and position) - #165430 ([tiny] Show context for found assoc item in E0107) - #165456 (std: Fix build for the L4Re targets) - #165463 (Add BTreeMap::allocator and BTreeSet::allocator) - #165466 (Don't "exit" using `panic` on teeos)
|
@bors try jobs=test-x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Lower #[no_mangle] to #[symbol_name]/#[link_name] try-job: test-x86_64-mingw-1
|
💔 Test for 13435e5 failed: CI. Failed job:
|
|
@bors r- |
|
This pull request was unapproved. |
This comment has been minimized.
This comment has been minimized.
This ensures the name it is referenced with from object files matches the name that it is imported as in an import library.
|
@bors try jobs=test-x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Lower #[no_mangle] to #[symbol_name]/#[link_name] try-job: test-x86_64-mingw-1
|
@rustbot ready |
View all comments
This reduces the amount of special casing #[no_mangle] needs in the rest of the compiler.
t-lang: nomination comment, example