Skip to content

Commit

Permalink
Disable Ctrl-C handling on WASM
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bjorn3 authored and oligamiq committed Sep 23, 2024
1 parent 8a9fb1f commit d67fd0c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 39 deletions.
2 changes: 1 addition & 1 deletion comment.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Hello World!

use LLVM
Install example:
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
WASI_SDK_PATH=`pwd`/wasi-sdk-22.0 WASI_SYSROOT=`pwd`/wasi-sdk-22.0/share/wasi-sysroot ./x.py install

If you just want to run it, https://github.com/oligamiq/rust_wasm/tree/main/rustc_llvm
```
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_driver_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ edition = "2021"

[dependencies]
# tidy-alphabetical-start
ctrlc = "3.4.4"
rustc_ast = { path = "../rustc_ast" }
rustc_ast_lowering = { path = "../rustc_ast_lowering" }
rustc_ast_passes = { path = "../rustc_ast_passes" }
Expand Down Expand Up @@ -66,6 +65,9 @@ features = [
"Win32_System_Diagnostics_Debug",
]

[target.'cfg(not(target_family = "wasm"))'.dependencies]
ctrlc = "3.4.4"

[features]
# tidy-alphabetical-start
llvm = ['rustc_interface/llvm']
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_driver_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ pub fn init_logger(early_dcx: &EarlyDiagCtxt, cfg: rustc_log::LoggerConfig) {
/// Install our usual `ctrlc` handler, which sets [`rustc_const_eval::CTRL_C_RECEIVED`].
/// Making this handler optional lets tools can install a different handler, if they wish.
pub fn install_ctrlc_handler() {
#[cfg(not(target_family = "wasm"))]
ctrlc::set_handler(move || {
// Indicate that we have been signaled to stop. If we were already signaled, exit
// immediately. In our interpreter loop we try to consult this value often, but if for
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub fn target() -> Target {

options.add_pre_link_args(
LinkerFlavor::WasmLld(Cc::No),
&["--import-memory", "--export-memory", "--shared-memory"],
&["--import-memory", "--export-memory", "--shared-memory", "-Wl,--max-memory=1073741824", "-lwasi-emulated-mman"],
);
options.add_pre_link_args(
LinkerFlavor::WasmLld(Cc::Yes),
Expand All @@ -25,6 +25,8 @@ pub fn target() -> Target {
"-Wl,--import-memory",
"-Wl,--export-memory,",
"-Wl,--shared-memory",
"-Wl,--max-memory=1073741824",
"-lwasi-emulated-mman",
],
);

Expand Down
3 changes: 1 addition & 2 deletions config.llvm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ sysconfdir = "etc"

[target.'wasm32-wasip1-threads']
wasi-root = "wasi-sdk-22.0/share/wasi-sysroot"
# linker = "wasi-sdk-22.0/bin/wasm-ld"
linker = "./wrapper_linker_clang.sh"
# codegen-backends = ["cranelift"]
linker = "wasi-sdk-22.0/bin/clang"
codegen-backends = ["llvm"]

[target.'x86_64-unknown-linux-gnu']
Expand Down
34 changes: 0 additions & 34 deletions wrapper_linker_clang.sh

This file was deleted.

0 comments on commit d67fd0c

Please sign in to comment.