Remove nonexistent clocks on WASI#4880
Conversation
These were added way back when in rust-lang#2499 and while they may have existed in a historical version of wasi-libc they most certainly do not exist in the current wasi-libc. Any usage of them is already-breaking, so this deletes these items.
|
This is something I'd ideally like to backport to the 0.2 version as well, although naturally it's a strictly-speaking breaking change. Technically historical changes like ca20d7d were also breaking in a minor fashion too, but this in theory could have higher impact because it's a more C-like constant rather than something libc-specific. Basically I don't know what the fallout of this would be. Extrapolating the highest risk is a crate that uses these constants in platform-specific code, including WASI, but the code is dead at runtime so no one noticed that it wouldn't work if it were executed. I'm not sure how prevalent such a situation is, however. |
tgross35
left a comment
There was a problem hiding this comment.
Thanks! I think this is fine to backport if you're okay with it: my philosophy has basically been that for anything in boat of "technically breaking but anybody using this is already broken without knowing it", it's more useful to poke users to fix the broken code than it is to spend effort keeping things half-working. At least on T<=2 platforms and more niche API. From your description, I think that applies here.
|
Sounds good to me! And yeah I'm comfortable backporting this myself, and feel free to redirect any confusion to me if you happen to see it |
These were added way back when in rust-lang#2499 and while they may have existed in a historical version of wasi-libc they most certainly do not exist in the current wasi-libc. Any usage of them is already-breaking, so this deletes these items. (backport <rust-lang#4880>) (cherry picked from commit e883afc)
These were added way back when in rust-lang#2499 and while they may have existed in a historical version of wasi-libc they most certainly do not exist in the current wasi-libc. Any usage of them is already-breaking, so this deletes these items. (backport <rust-lang#4880>) (cherry picked from commit e883afc)
…ed, r=Mark-Simulacrum
rustc: Stop passing `--allow-undefined` on wasm targets
This commit updates how the linker is invoked on WebAssembly targets (all of them) to avoid passing the `--allow-undefined` flag to the linker. Historically, if I remember this correctly, when `wasm-ld` was first integrated this was practically required because at the time it was otherwise impossible to import a function from the host into a wasm binary. Or, at least, I'm pretty sure that was why this was added.
At the time, as the documentation around this option indicates, it was known that this was going to be a hazard. This doesn't match behavior on native, for example, and can easily paper over what should be a linker error with some sort of other obscure runtime error. An example is that this program currently compiles and links, it just prints null:
unsafe extern "C" {
static nonexistent: u8;
}
fn main() {
println!("{:?}", &raw const nonexistent);
}
This can easily lead to mistakes like rust-lang/libc#4880 and defer what should be a compile-time link error to weird or unusual behavior at link time. Additionally, in the intervening time since `wasm-ld` was first introduced here, lots has changed and notably this program works as expected:
#[link(wasm_import_module = "host")]
unsafe extern "C" {
fn foo();
}
fn main() {
unsafe {
foo();
}
}
This continues to compile without error and the final wasm binary indeed has an imported function from the host. This program:
unsafe extern "C" {
fn foo();
}
fn main() {
unsafe {
foo();
}
}
this currently compiles successfully and emits an import from the `env` module. After this change, however, this will fail to compile with a link error stating that the `foo` symbol is not defined.
Rollup merge of #149868 - alexcrichton:wasm-no-allow-undefined, r=Mark-Simulacrum rustc: Stop passing `--allow-undefined` on wasm targets This commit updates how the linker is invoked on WebAssembly targets (all of them) to avoid passing the `--allow-undefined` flag to the linker. Historically, if I remember this correctly, when `wasm-ld` was first integrated this was practically required because at the time it was otherwise impossible to import a function from the host into a wasm binary. Or, at least, I'm pretty sure that was why this was added. At the time, as the documentation around this option indicates, it was known that this was going to be a hazard. This doesn't match behavior on native, for example, and can easily paper over what should be a linker error with some sort of other obscure runtime error. An example is that this program currently compiles and links, it just prints null: unsafe extern "C" { static nonexistent: u8; } fn main() { println!("{:?}", &raw const nonexistent); } This can easily lead to mistakes like rust-lang/libc#4880 and defer what should be a compile-time link error to weird or unusual behavior at link time. Additionally, in the intervening time since `wasm-ld` was first introduced here, lots has changed and notably this program works as expected: #[link(wasm_import_module = "host")] unsafe extern "C" { fn foo(); } fn main() { unsafe { foo(); } } This continues to compile without error and the final wasm binary indeed has an imported function from the host. This program: unsafe extern "C" { fn foo(); } fn main() { unsafe { foo(); } } this currently compiles successfully and emits an import from the `env` module. After this change, however, this will fail to compile with a link error stating that the `foo` symbol is not defined.
…k-Simulacrum
rustc: Stop passing `--allow-undefined` on wasm targets
This commit updates how the linker is invoked on WebAssembly targets (all of them) to avoid passing the `--allow-undefined` flag to the linker. Historically, if I remember this correctly, when `wasm-ld` was first integrated this was practically required because at the time it was otherwise impossible to import a function from the host into a wasm binary. Or, at least, I'm pretty sure that was why this was added.
At the time, as the documentation around this option indicates, it was known that this was going to be a hazard. This doesn't match behavior on native, for example, and can easily paper over what should be a linker error with some sort of other obscure runtime error. An example is that this program currently compiles and links, it just prints null:
unsafe extern "C" {
static nonexistent: u8;
}
fn main() {
println!("{:?}", &raw const nonexistent);
}
This can easily lead to mistakes like rust-lang/libc#4880 and defer what should be a compile-time link error to weird or unusual behavior at link time. Additionally, in the intervening time since `wasm-ld` was first introduced here, lots has changed and notably this program works as expected:
#[link(wasm_import_module = "host")]
unsafe extern "C" {
fn foo();
}
fn main() {
unsafe {
foo();
}
}
This continues to compile without error and the final wasm binary indeed has an imported function from the host. This program:
unsafe extern "C" {
fn foo();
}
fn main() {
unsafe {
foo();
}
}
this currently compiles successfully and emits an import from the `env` module. After this change, however, this will fail to compile with a link error stating that the `foo` symbol is not defined.
These were added way back when in #2499 and while they may have existed in a historical version of wasi-libc they most certainly do not exist in the current wasi-libc. Any usage of them is already-breaking, so this deletes these items.