Skip to content

Commit

Permalink
[WebAssembly] Add error checking for -wasm-use-legacy-ch (llvm#122526)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
aheejin authored Jan 11, 2025
1 parent 0cb1884 commit 58508ee
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
}
}

for (const auto *Option : {"-wasm-enable-eh", "-wasm-enable-sjlj"}) {
for (const auto *Option :
{"-wasm-enable-eh", "-wasm-enable-sjlj", "-wasm-use-legacy-eh"}) {
if (Opt.starts_with(Option)) {
BanIncompatibleOptionsForWasmEHSjLj(Option);
EnableFeaturesForWasmEHSjLj();
Expand Down
22 changes: 22 additions & 0 deletions clang/test/Driver/wasm-toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,28 @@
// RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_REFERENCE_TYPES %s
// WASM_SJLJ_NO_REFERENCE_TYPES: invalid argument '-wasm-enable-sjlj' not allowed with '-mno-reference-types'

// '-mllvm -wasm-use-legacy-eh' not allowed with
// '-mllvm -enable-emscripten-cxx-exceptions'
// RUN: not %clang -### --target=wasm32-unknown-unknown \
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_EMSCRIPTEN_EH %s
// WASM_LEGACY_EH_EMSCRIPTEN_EH: invalid argument '-wasm-use-legacy-eh' not allowed with '-enable-emscripten-cxx-exceptions'

// '-mllvm -wasm-use-legacy-eh' not allowed with '-mllvm -enable-emscripten-sjlj'
// RUN: not %clang -### --target=wasm32-unknown-unknown \
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
// RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_EMSCRIPTEN_SJLJ %s
// WASM_LEGACY_EH_EMSCRIPTEN_SJLJ: invalid argument '-wasm-use-legacy-eh' not allowed with '-enable-emscripten-sjlj'

// '-mllvm -wasm-use-legacy-eh' not allowed with '-mno-exception-handling'
// RUN: not %clang -### --target=wasm32-unknown-unknown \
// RUN: --sysroot=/foo %s -mllvm -wasm-use-legacy-eh \
// RUN: -mno-exception-handling 2>&1 \
// RUN: | FileCheck -check-prefix=WASM_LEGACY_EH_NO_EH %s
// WASM_LEGACY_EH_NO_EH: invalid argument '-wasm-use-legacy-eh' not allowed with '-mno-exception-handling'

// RUN: %clang -### %s -fsanitize=address --target=wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Expand Down

0 comments on commit 58508ee

Please sign in to comment.