Skip to content

Commit aee99e8

Browse files
authored
[WebAssembly] Define llvm-internal WasmEH tags in compiler-rt (llvm#160959)
The `__c_longjmp` and `__cpp_exceptions` tags are used internally by llvm to implement setjmp/longjmp and C++ exception handling respectively. These symbols were previously defined weakly in each object file but were recently converted to external references in llvm#159143. They now need to be defined somewhere in the runtime libraries. I think compiler-rt is likely the most sensible place for them.
1 parent 9f7e7f7 commit aee99e8

File tree

3 files changed

+58
-5
lines changed

3 files changed

+58
-5
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -816,14 +816,15 @@ set(s390x_SOURCES
816816
${GENERIC_TF_SOURCES}
817817
)
818818

819-
set(wasm32_SOURCES
820-
${GENERIC_TF_SOURCES}
821-
${GENERIC_SOURCES}
822-
)
823-
set(wasm64_SOURCES
819+
820+
set(wasm_SOURCES
821+
wasm/__c_longjmp.S
822+
wasm/__cpp_exceptions.S
824823
${GENERIC_TF_SOURCES}
825824
${GENERIC_SOURCES}
826825
)
826+
set(wasm32_SOURCES ${wasm_SOURCES})
827+
set(wasm64_SOURCES ${wasm_SOURCES})
827828

828829
set(ve_SOURCES
829830
ve/grow_stack.S
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- __c_longjmp.S - Implement __c_longjmp -----------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __c_longjmp which LLVM uses to implenmet setjmp/longjmp
10+
// when Wasm EH is enabled.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifdef __wasm_exception_handling__
15+
16+
#ifdef __wasm64__
17+
#define PTR i64
18+
#else
19+
#define PTR i32
20+
#endif
21+
22+
.globl __c_longjmp
23+
.tagtype __c_longjmp PTR
24+
__c_longjmp:
25+
26+
#endif // !__wasm_exception_handling__
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- __cpp_exception.S - Implement __cpp_exception ---------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file implements __cpp_exception which LLVM uses to implement exception
10+
// handling when Wasm EH is enabled.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifdef __wasm_exception_handling__
15+
16+
#ifdef __wasm64__
17+
#define PTR i64
18+
#else
19+
#define PTR i32
20+
#endif
21+
22+
.globl __cpp_exception
23+
.tagtype __cpp_exception PTR
24+
__cpp_exception:
25+
26+
#endif // !__wasm_exception_handling__

0 commit comments

Comments
 (0)