[WebAssembly] Make EH depend on multivalue and reference-types (#91299)
This PR turns on multivalue and reference-types features when exception-handling feature is turned on, and errors out when disabling of those dependent features is explicitly requested. I think doing this would be safe anyway regardless of whether or when we end up turning on reference-types by default. We currently don't yet have a experimental flag for the Clang and LLVM for the new experimental EH yet. But I think it should be fine to turn those features on even if the LLVM does not yet generate the new EH instructions, for the same reason we tried to turn them on by default and the browsers that support EH also support multivalue and reference-types anyway.
This commit is contained in:
@@ -347,6 +347,23 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
|
||||
// Backend needs -wasm-enable-eh to enable Wasm EH
|
||||
CC1Args.push_back("-mllvm");
|
||||
CC1Args.push_back("-wasm-enable-eh");
|
||||
|
||||
// New Wasm EH spec (adopted in Oct 2023) requires multivalue and
|
||||
// reference-types.
|
||||
if (DriverArgs.hasFlag(options::OPT_mno_multivalue,
|
||||
options::OPT_mmultivalue, false)) {
|
||||
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
||||
<< "-fwasm-exceptions" << "-mno-multivalue";
|
||||
}
|
||||
if (DriverArgs.hasFlag(options::OPT_mno_reference_types,
|
||||
options::OPT_mreference_types, false)) {
|
||||
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
||||
<< "-fwasm-exceptions" << "-mno-reference-types";
|
||||
}
|
||||
CC1Args.push_back("-target-feature");
|
||||
CC1Args.push_back("+multivalue");
|
||||
CC1Args.push_back("-target-feature");
|
||||
CC1Args.push_back("+reference-types");
|
||||
}
|
||||
|
||||
for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
|
||||
@@ -408,6 +425,23 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
|
||||
CC1Args.push_back("+exception-handling");
|
||||
// Backend needs '-exception-model=wasm' to use Wasm EH instructions
|
||||
CC1Args.push_back("-exception-model=wasm");
|
||||
|
||||
// New Wasm EH spec (adopted in Oct 2023) requires multivalue and
|
||||
// reference-types.
|
||||
if (DriverArgs.hasFlag(options::OPT_mno_multivalue,
|
||||
options::OPT_mmultivalue, false)) {
|
||||
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
||||
<< "-mllvm -wasm-enable-sjlj" << "-mno-multivalue";
|
||||
}
|
||||
if (DriverArgs.hasFlag(options::OPT_mno_reference_types,
|
||||
options::OPT_mreference_types, false)) {
|
||||
getDriver().Diag(diag::err_drv_argument_not_allowed_with)
|
||||
<< "-mllvm -wasm-enable-sjlj" << "-mno-reference-types";
|
||||
}
|
||||
CC1Args.push_back("-target-feature");
|
||||
CC1Args.push_back("+multivalue");
|
||||
CC1Args.push_back("-target-feature");
|
||||
CC1Args.push_back("+reference-types");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,11 +120,12 @@
|
||||
// RUN: | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
|
||||
// EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
||||
|
||||
// '-fwasm-exceptions' sets +exception-handling and '-mllvm -wasm-enable-eh'
|
||||
// '-fwasm-exceptions' sets +exception-handling, -multivalue, -reference-types
|
||||
// and '-mllvm -wasm-enable-eh'
|
||||
// RUN: %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -fwasm-exceptions 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS %s
|
||||
// WASM_EXCEPTIONS: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh"
|
||||
// WASM_EXCEPTIONS: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh" "-target-feature" "+multivalue" "-target-feature" "+reference-types"
|
||||
|
||||
// '-fwasm-exceptions' not allowed with '-mno-exception-handling'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
@@ -132,19 +133,32 @@
|
||||
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
|
||||
// WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
|
||||
|
||||
// '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
||||
// '-fwasm-exceptions' not allowed with
|
||||
// '-mllvm -enable-emscripten-cxx-exceptions'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -fwasm-exceptions \
|
||||
// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s
|
||||
// WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
|
||||
|
||||
// '-mllvm -wasm-enable-sjlj' sets +exception-handling and
|
||||
// '-exception-model=wasm'
|
||||
// '-fwasm-exceptions' not allowed with '-mno-multivalue'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-multivalue 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_MULTIVALUE %s
|
||||
// WASM_EXCEPTIONS_NO_MULTIVALUE: invalid argument '-fwasm-exceptions' not allowed with '-mno-multivalue'
|
||||
|
||||
// '-fwasm-exceptions' not allowed with '-mno-reference-types'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -fwasm-exceptions -mno-reference-types 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_REFERENCE_TYPES %s
|
||||
// WASM_EXCEPTIONS_NO_REFERENCE_TYPES: invalid argument '-fwasm-exceptions' not allowed with '-mno-reference-types'
|
||||
|
||||
// '-mllvm -wasm-enable-sjlj' sets +exception-handling, +multivalue,
|
||||
// +reference-types and '-exception-model=wasm'
|
||||
// RUN: %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_SJLJ %s
|
||||
// WASM_SJLJ: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm"
|
||||
// WASM_SJLJ: "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm" "-target-feature" "+multivalue" "-target-feature" "+reference-types"
|
||||
|
||||
// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
@@ -168,6 +182,19 @@
|
||||
// RUN: | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_SJLJ %s
|
||||
// WASM_SJLJ_EMSCRIPTEN_SJLJ: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
|
||||
|
||||
// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-multivalue'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj -mno-multivalue 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_MULTIVALUE %s
|
||||
// WASM_SJLJ_NO_MULTIVALUE: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-multivalue'
|
||||
|
||||
// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-reference-types'
|
||||
// RUN: not %clang -### --target=wasm32-unknown-unknown \
|
||||
// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
|
||||
// RUN: -mno-reference-types 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=WASM_SJLJ_NO_REFERENCE_TYPES %s
|
||||
// WASM_SJLJ_NO_REFERENCE_TYPES: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-reference-types'
|
||||
|
||||
// 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"
|
||||
|
||||
Reference in New Issue
Block a user