Skip to content

Commit e913417

Browse files
committed
Auto merge of #148591 - cuviper:beta-next, r=cuviper
[beta] backports - Enable file locking support in illumos #148322 - Fix `wasm_import_module` attribute cross-crate #148363 r? cuviper
2 parents 0a41160 + f9466e2 commit e913417

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

compiler/rustc_symbol_mangling/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ fn compute_symbol_name<'tcx>(
228228
// However, we don't have the wasm import module map there yet.
229229
tcx.is_foreign_item(def_id)
230230
&& tcx.sess.target.is_like_wasm
231-
&& tcx.wasm_import_module_map(LOCAL_CRATE).contains_key(&def_id.into())
231+
&& tcx.wasm_import_module_map(def_id.krate).contains_key(&def_id.into())
232232
};
233233

234234
if !wasm_import_module_exception_force_mangling {

library/std/src/fs/tests.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use rand::RngCore;
55
target_os = "freebsd",
66
target_os = "linux",
77
target_os = "netbsd",
8+
target_os = "illumos",
89
target_vendor = "apple",
910
))]
1011
use crate::assert_matches::assert_matches;
@@ -14,6 +15,7 @@ use crate::char::MAX_LEN_UTF8;
1415
target_os = "freebsd",
1516
target_os = "linux",
1617
target_os = "netbsd",
18+
target_os = "illumos",
1719
target_vendor = "apple",
1820
))]
1921
use crate::fs::TryLockError;
@@ -227,6 +229,7 @@ fn file_test_io_seek_and_write() {
227229
target_os = "linux",
228230
target_os = "netbsd",
229231
target_os = "solaris",
232+
target_os = "illumos",
230233
target_vendor = "apple",
231234
))]
232235
fn file_lock_multiple_shared() {
@@ -251,6 +254,7 @@ fn file_lock_multiple_shared() {
251254
target_os = "linux",
252255
target_os = "netbsd",
253256
target_os = "solaris",
257+
target_os = "illumos",
254258
target_vendor = "apple",
255259
))]
256260
fn file_lock_blocking() {
@@ -276,6 +280,7 @@ fn file_lock_blocking() {
276280
target_os = "linux",
277281
target_os = "netbsd",
278282
target_os = "solaris",
283+
target_os = "illumos",
279284
target_vendor = "apple",
280285
))]
281286
fn file_lock_drop() {
@@ -298,6 +303,7 @@ fn file_lock_drop() {
298303
target_os = "linux",
299304
target_os = "netbsd",
300305
target_os = "solaris",
306+
target_os = "illumos",
301307
target_vendor = "apple",
302308
))]
303309
fn file_lock_dup() {

library/std/src/sys/fs/unix.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,7 @@ impl File {
12921292
target_os = "netbsd",
12931293
target_os = "openbsd",
12941294
target_os = "cygwin",
1295+
target_os = "illumos",
12951296
target_vendor = "apple",
12961297
))]
12971298
pub fn lock(&self) -> io::Result<()> {
@@ -1316,6 +1317,7 @@ impl File {
13161317
target_os = "openbsd",
13171318
target_os = "cygwin",
13181319
target_os = "solaris",
1320+
target_os = "illumos",
13191321
target_vendor = "apple",
13201322
)))]
13211323
pub fn lock(&self) -> io::Result<()> {
@@ -1329,6 +1331,7 @@ impl File {
13291331
target_os = "netbsd",
13301332
target_os = "openbsd",
13311333
target_os = "cygwin",
1334+
target_os = "illumos",
13321335
target_vendor = "apple",
13331336
))]
13341337
pub fn lock_shared(&self) -> io::Result<()> {
@@ -1353,6 +1356,7 @@ impl File {
13531356
target_os = "openbsd",
13541357
target_os = "cygwin",
13551358
target_os = "solaris",
1359+
target_os = "illumos",
13561360
target_vendor = "apple",
13571361
)))]
13581362
pub fn lock_shared(&self) -> io::Result<()> {
@@ -1366,6 +1370,7 @@ impl File {
13661370
target_os = "netbsd",
13671371
target_os = "openbsd",
13681372
target_os = "cygwin",
1373+
target_os = "illumos",
13691374
target_vendor = "apple",
13701375
))]
13711376
pub fn try_lock(&self) -> Result<(), TryLockError> {
@@ -1406,6 +1411,7 @@ impl File {
14061411
target_os = "openbsd",
14071412
target_os = "cygwin",
14081413
target_os = "solaris",
1414+
target_os = "illumos",
14091415
target_vendor = "apple",
14101416
)))]
14111417
pub fn try_lock(&self) -> Result<(), TryLockError> {
@@ -1422,6 +1428,7 @@ impl File {
14221428
target_os = "netbsd",
14231429
target_os = "openbsd",
14241430
target_os = "cygwin",
1431+
target_os = "illumos",
14251432
target_vendor = "apple",
14261433
))]
14271434
pub fn try_lock_shared(&self) -> Result<(), TryLockError> {
@@ -1462,6 +1469,7 @@ impl File {
14621469
target_os = "openbsd",
14631470
target_os = "cygwin",
14641471
target_os = "solaris",
1472+
target_os = "illumos",
14651473
target_vendor = "apple",
14661474
)))]
14671475
pub fn try_lock_shared(&self) -> Result<(), TryLockError> {
@@ -1478,6 +1486,7 @@ impl File {
14781486
target_os = "netbsd",
14791487
target_os = "openbsd",
14801488
target_os = "cygwin",
1489+
target_os = "illumos",
14811490
target_vendor = "apple",
14821491
))]
14831492
pub fn unlock(&self) -> io::Result<()> {
@@ -1502,6 +1511,7 @@ impl File {
15021511
target_os = "openbsd",
15031512
target_os = "cygwin",
15041513
target_os = "solaris",
1514+
target_os = "illumos",
15051515
target_vendor = "apple",
15061516
)))]
15071517
pub fn unlock(&self) -> io::Result<()> {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![no_std]
2+
3+
#[link(wasm_import_module = "test")]
4+
unsafe extern "C" {
5+
#[link_name = "close"]
6+
pub fn close(x: u32) -> u32;
7+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ only-wasm32
2+
//@ aux-build:link-name-in-foreign-crate.rs
3+
//@ compile-flags: --crate-type cdylib
4+
//@ build-pass
5+
//@ no-prefer-dynamic
6+
7+
extern crate link_name_in_foreign_crate;
8+
9+
// This test that the definition of a function named `close`, which collides
10+
// with the `close` function in libc in theory, is handled correctly in
11+
// cross-crate situations. The `link_name_in_foreign_crate` dependency declares
12+
// `close` from a non-`env` wasm import module and then this crate attempts to
13+
// use the symbol. This should properly ensure that the wasm module name is
14+
// tagged as `test` and the `close` symbol, to LLD, is mangled, to avoid
15+
// colliding with the `close` symbol in libc itself.
16+
17+
#[unsafe(no_mangle)]
18+
pub extern "C" fn foo() {
19+
unsafe {
20+
link_name_in_foreign_crate::close(1);
21+
}
22+
}

0 commit comments

Comments
 (0)