Skip to content

Commit 1b7609c

Browse files
committed
Disable main_needs_argc_argv for Wasm
1 parent 1a70f8d commit 1b7609c

5 files changed

Lines changed: 8 additions & 12 deletions

File tree

compiler/rustc_target/src/spec/base/wasm.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ pub(crate) fn options() -> TargetOptions {
118118
// with unwinding.
119119
llvm_args: cvs!["-wasm-use-legacy-eh=false"],
120120

121+
// WASI's `sys::args::init` function ignores its arguments; instead,
122+
// `args::args()` makes the WASI API calls itself.
123+
//
124+
// Other Wasm targets make no use of `std::env` entirely.
125+
// Emscripten enables it explicitly.
126+
main_needs_argc_argv: false,
127+
121128
..Default::default()
122129
}
123130
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub(crate) fn target() -> Target {
2828
crt_static_respected: true,
2929
crt_static_default: true,
3030
crt_static_allows_dylibs: true,
31+
main_needs_argc_argv: true,
3132
panic_strategy: PanicStrategy::Unwind,
3233
no_default_libraries: false,
3334
families: cvs!["unix", "wasm"],

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ pub(crate) fn target() -> Target {
4141
// without a main function.
4242
options.crt_static_allows_dylibs = true;
4343

44-
// WASI's `sys::args::init` function ignores its arguments; instead,
45-
// `args::args()` makes the WASI API calls itself.
46-
options.main_needs_argc_argv = false;
47-
4844
// And, WASI mangles the name of "main" to distinguish between different
4945
// signatures.
5046
options.entry_name = "__main_void".into();

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ pub(crate) fn target() -> Target {
5252
// without a main function.
5353
options.crt_static_allows_dylibs = true;
5454

55-
// WASI's `sys::args::init` function ignores its arguments; instead,
56-
// `args::args()` makes the WASI API calls itself.
57-
options.main_needs_argc_argv = false;
58-
5955
// And, WASI mangles the name of "main" to distinguish between different
6056
// signatures.
6157
options.entry_name = "__main_void".into();

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ pub(crate) fn target() -> Target {
4646
// without a main function.
4747
options.crt_static_allows_dylibs = true;
4848

49-
// WASI's `sys::args::init` function ignores its arguments; instead,
50-
// `args::args()` makes the WASI API calls itself.
51-
options.main_needs_argc_argv = false;
52-
5349
// And, WASI mangles the name of "main" to distinguish between different
5450
// signatures.
5551
options.entry_name = "__main_void".into();

0 commit comments

Comments
 (0)