-
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
WASI: Cannot open paths with nightly >= 2021-03-11 when linked with LLD 11.1 #85840
Comments
I was wrong, actually it does not work at all on
and
whereas on |
hi @abbec thanks for filing a report. Do you imply that even a snippet like this returns that error?
Can you attach a small but fully actionable and reproducible snippet (along with the command to compile)? There might be more to investigate and that would be useful. Thanks! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Which command and rustc flags do you use to compile the sources? Also, do you get an actual error stack? If yes, can you expand that error with |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Yeah, it does work with LLVM 12 but not with LLVM 11.1. REPRO CASE:use std::fs;
fn repro() {
let s = fs::read("/absolute/path.txt").unwrap();
println!("{:#?}", s);
}
fn main() {
repro();
} Run this$ rustup toolchain install nightly-2021-03-11
$ rustup default nightly-2021-03-11
$ rustup target add wasm32-wasi
$ export CARGO_TARGET_WASM32_WASI_LINKER=/path/to/llvm-11/bin/lld
$ cargo build --target wasm32-wasi
$ echo "YES" > path.txt
$ wasmtime run --mapdir=absolute::. target/wasm32-wasi/debug/rust-repro.wasm
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "failed to find a pre-opened file descriptor through which \"/absolute/path.txt\" could be opened" }', src/main.rs:4:44 The same thing works fine with $ rustup toolchain install nightly-2021-03-10
$ rustup default nightly-2021-03-10
$ rustup target add wasm32-wasi
$ export CARGO_TARGET_WASM32_WASI_LINKER=/path/to/llvm-11/bin/lld
$ cargo build --target wasm32-wasi
$ echo "YES" > path.txt
$ wasmtime run --mapdir=absolute::. target/wasm32-wasi/debug/rust-repro.wasm
[
89,
69,
83,
10,
] |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @h-michael @HallerPatrick @hdhoang @hellow554 @henryboisdequin @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @steffahn @Stupremee @tamuhey @turboladen @woshilapin @yerke |
Hey Cleanup Crew ICE-breakers! This bug has been identified as a good cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @h-michael @HallerPatrick @hdhoang @hellow554 @henryboisdequin @imtsuki @JamesPatrickGill @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @shekohex @sinato @smmalis37 @steffahn @Stupremee @tamuhey @turboladen @woshilapin @yerke |
This seems to have been introduced in 1.52.0 nightly given the affected version. Relabeling as a stable-to-stable regression. |
@abbec could you describe a bit why you're linking with a non-Rust LLD, and specifically an older-than-LLVM-12 LLD? Given your range of nightlies for the regression this seems most likely due to #82924 which I could imagine relies on features and/or bug fixes in LLVM 12 to work. In general the wasm targets right now are intended to work best with the LLD that Rust ships itself, and otherwise if you're looking to interop with C/C++ code it's recommended to say pretty up-to-date because there's still a good deal of feature development and bug fixes happening. |
Yeah to be fair, this issue popped up in passing and I am now using LLVM 12 which works fine. Reason for using an external linker is a custom libc and other C libraries. |
Ah ok, if that's the case I'd recommend closing this because the wasm target and toolchain are undergoing enough changes that not a lot of effort is put into making all versions of objects work with past and future toolchains. This will naturally evolve over time as wasm stabilizes, but at this time I think the guarantee of Rust is that if you want to intermix Rust & C on wasm you need to have matching LLVM versions. |
ok, closing this as per Alex's suggestion. @abbec please feel free to action this issue again in case something relevant happens again. Thanks again for your time on this issue! |
I have code opening a path like
std::fs::read("/absolute/path.txt")
in WASI. All the surrounding code stays the same but when I upgrade nightly from2021-03-10
to2021-03-11
it does not work anymore.Version details:
Looking at the history, the only thing I can see that looks WASI-related is this but I have no idea here and any help would be appreciated!
EDIT: This description turned out to be somewhat incorrect, see below for a good repro case.
The text was updated successfully, but these errors were encountered: