mirror of
https://github.com/rust-lang/rust.git
synced 2025-12-02 17:58:30 +00:00
This commit fixes an accidental regression from 144678 where wasm targets would now accidentally use the wrong import module map for a symbol causing a symbol to skip mangling. This can result in compilation failures when symbols are used in cross-crate situations. Closes 148347
23 lines
804 B
Rust
23 lines
804 B
Rust
//@ only-wasm32
|
|
//@ aux-build:link-name-in-foreign-crate.rs
|
|
//@ compile-flags: --crate-type cdylib
|
|
//@ build-pass
|
|
//@ no-prefer-dynamic
|
|
|
|
extern crate link_name_in_foreign_crate;
|
|
|
|
// This test that the definition of a function named `close`, which collides
|
|
// with the `close` function in libc in theory, is handled correctly in
|
|
// cross-crate situations. The `link_name_in_foreign_crate` dependency declares
|
|
// `close` from a non-`env` wasm import module and then this crate attempts to
|
|
// use the symbol. This should properly ensure that the wasm module name is
|
|
// tagged as `test` and the `close` symbol, to LLD, is mangled, to avoid
|
|
// colliding with the `close` symbol in libc itself.
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn foo() {
|
|
unsafe {
|
|
link_name_in_foreign_crate::close(1);
|
|
}
|
|
}
|