Skip to content

Commit 58508ee

Browse files
authored
[WebAssembly] Add error checking for -wasm-use-legacy-ch (#122526)
This adds checks for `-wasm-use-legacy-eh`. While this option is true by default in the backend, it is not supposed to be given to the Clang when Wasm EH is not used.
1 parent 0cb1884 commit 58508ee

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

clang/lib/Driver/ToolChains/WebAssembly.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
422422
}
423423
}
424424

425-
for (const auto *Option : {"-wasm-enable-eh", "-wasm-enable-sjlj"}) {
425+
for (const auto *Option :
426+
{"-wasm-enable-eh", "-wasm-enable-sjlj", "-wasm-use-legacy-eh"}) {
426427
if (Opt.starts_with(Option)) {
427428
BanIncompatibleOptionsForWasmEHSjLj(Option);
428429
EnableFeaturesForWasmEHSjLj();

clang/test/Driver/wasm-toolchain.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,28 @@
202202
// RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_REFERENCE_TYPES %s
203203
// WASM_SJLJ_NO_REFERENCE_TYPES: invalid argument '-wasm-enable-sjlj' not allowed with '-mno-reference-types'
204204

205+
// '-mllvm -wasm-use-legacy-eh' not allowed with
206+
// '-mllvm -enable-emscripten-cxx-exceptions'
207+
// RUN: not %clang -### --target=wasm32-unknown-unknown \
208+
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
209+
// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
210+
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_EMSCRIPTEN_EH %s
211+
// WASM_LEGACY_EH_EMSCRIPTEN_EH: invalid argument '-wasm-use-legacy-eh' not allowed with '-enable-emscripten-cxx-exceptions'
212+
213+
// '-mllvm -wasm-use-legacy-eh' not allowed with '-mllvm -enable-emscripten-sjlj'
214+
// RUN: not %clang -### --target=wasm32-unknown-unknown \
215+
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
216+
// RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
217+
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_EMSCRIPTEN_SJLJ %s
218+
// WASM_LEGACY_EH_EMSCRIPTEN_SJLJ: invalid argument '-wasm-use-legacy-eh' not allowed with '-enable-emscripten-sjlj'
219+
220+
// '-mllvm -wasm-use-legacy-eh' not allowed with '-mno-exception-handling'
221+
// RUN: not %clang -### --target=wasm32-unknown-unknown \
222+
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
223+
// RUN: -mno-exception-handling 2>&1 \
224+
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_NO_EH %s
225+
// WASM_LEGACY_EH_NO_EH: invalid argument '-wasm-use-legacy-eh' not allowed with '-mno-exception-handling'
226+
205227
// RUN: %clang -### %s -fsanitize=address --target=wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
206228
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
207229
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"

0 commit comments

Comments
 (0)