Skip to content

Commit d67fd0c

Browse files
bjorn3oligamiq
authored andcommitted
Disable Ctrl-C handling on WASM
WASM fundamentally doesn't support signals. If WASI ever gets support for notifying the guest process of a Ctrl-C that happened, this would have to be done through the guest process polling for the signal, which will require thread support in WASI too to be compatible with the api provided by the ctrlc crate. remove linker wrapper script
1 parent 8a9fb1f commit d67fd0c

File tree

6 files changed

+9
-39
lines changed

6 files changed

+9
-39
lines changed

comment.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Hello World!
1919

2020
use LLVM
2121
Install example:
22-
WASI_SDK_PATH=`pwd`/wasi-sdk-22.0 WASI_SYSROOT=`pwd`/wasi-sdk-22.0/share/wasi-sysroot WASI_CLANG_WRAPPER_LINKER="`pwd`/wrapper_linker_clang++.sh" ./x.py install
22+
WASI_SDK_PATH=`pwd`/wasi-sdk-22.0 WASI_SYSROOT=`pwd`/wasi-sdk-22.0/share/wasi-sysroot ./x.py install
2323

2424
If you just want to run it, https://github.com/oligamiq/rust_wasm/tree/main/rustc_llvm
2525
```

compiler/rustc_driver_impl/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ edition = "2021"
55

66
[dependencies]
77
# tidy-alphabetical-start
8-
ctrlc = "3.4.4"
98
rustc_ast = { path = "../rustc_ast" }
109
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
1110
rustc_ast_passes = { path = "../rustc_ast_passes" }
@@ -66,6 +65,9 @@ features = [
6665
"Win32_System_Diagnostics_Debug",
6766
]
6867

68+
[target.'cfg(not(target_family = "wasm"))'.dependencies]
69+
ctrlc = "3.4.4"
70+
6971
[features]
7072
# tidy-alphabetical-start
7173
llvm = ['rustc_interface/llvm']

compiler/rustc_driver_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,7 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
15001500
/// Install our usual `ctrlc` handler, which sets [`rustc_const_eval::CTRL_C_RECEIVED`].
15011501
/// Making this handler optional lets tools can install a different handler, if they wish.
15021502
pub fn install_ctrlc_handler() {
1503+
#[cfg(not(target_family = "wasm"))]
15031504
ctrlc::set_handler(move || {
15041505
// Indicate that we have been signaled to stop. If we were already signaled, exit
15051506
// immediately. In our interpreter loop we try to consult this value often, but if for

compiler/rustc_target/src/spec/targets/wasm32_wasip1_threads.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn target() -> Target {
1616

1717
options.add_pre_link_args(
1818
LinkerFlavor::WasmLld(Cc::No),
19-
&["--import-memory", "--export-memory", "--shared-memory"],
19+
&["--import-memory", "--export-memory", "--shared-memory", "-Wl,--max-memory=1073741824", "-lwasi-emulated-mman"],
2020
);
2121
options.add_pre_link_args(
2222
LinkerFlavor::WasmLld(Cc::Yes),
@@ -25,6 +25,8 @@ pub fn target() -> Target {
2525
"-Wl,--import-memory",
2626
"-Wl,--export-memory,",
2727
"-Wl,--shared-memory",
28+
"-Wl,--max-memory=1073741824",
29+
"-lwasi-emulated-mman",
2830
],
2931
);
3032

config.llvm.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ sysconfdir = "etc"
3232

3333
[target.'wasm32-wasip1-threads']
3434
wasi-root = "wasi-sdk-22.0/share/wasi-sysroot"
35-
# linker = "wasi-sdk-22.0/bin/wasm-ld"
36-
linker = "./wrapper_linker_clang.sh"
3735
# codegen-backends = ["cranelift"]
36+
linker = "wasi-sdk-22.0/bin/clang"
3837
codegen-backends = ["llvm"]
3938

4039
[target.'x86_64-unknown-linux-gnu']

wrapper_linker_clang.sh

-34
This file was deleted.

0 commit comments

Comments
 (0)