Skip to content

Commit 9719968

Browse files
committed
Prepare for 34-rc.2
* Update LLVM to 23.1.0-rc.2 * Update wasi-libc to tip * Manually add in wasm-ld fixes * Update wasm-component-ld
1 parent 3581134 commit 9719968

5 files changed

Lines changed: 969 additions & 3 deletions

File tree

cmake/wasi-sdk-toolchain.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ ExternalProject_Add(llvm-build
255255
USES_TERMINAL_CONFIGURE ON
256256
USES_TERMINAL_BUILD ON
257257
USES_TERMINAL_INSTALL ON
258+
PATCH_COMMAND
259+
${CMAKE_COMMAND} -E chdir .. bash -c
260+
"git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-206831.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-pr-206831.patch -R --check"
261+
COMMAND
262+
${CMAKE_COMMAND} -E chdir .. bash -c
263+
"git apply ${CMAKE_SOURCE_DIR}/src/llvm-prs-208263-208332-208597.patch || git apply ${CMAKE_SOURCE_DIR}/src/llvm-prs-208263-208332-208597.patch -R --check"
258264
)
259265

260266
add_custom_target(build ALL DEPENDS llvm-build)
@@ -269,7 +275,7 @@ install(DIRECTORY ${wasi_tmp_install}/bin ${wasi_tmp_install}/lib ${wasi_tmp_ins
269275
# Build logic for `wasm-component-ld` installed from Rust code.
270276
set(wasm_component_ld_root ${CMAKE_CURRENT_BINARY_DIR}/wasm-component-ld)
271277
set(wasm_component_ld ${wasm_component_ld_root}/bin/wasm-component-ld${CMAKE_EXECUTABLE_SUFFIX})
272-
set(wasm_component_ld_version 0.5.26)
278+
set(wasm_component_ld_version 0.5.27)
273279
if(RUST_TARGET)
274280
set(rust_target_flag --target=${RUST_TARGET})
275281
endif()

src/llvm-pr-206831.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
diff --git a/lld/test/wasm/cooperative-threading-gc.s b/lld/test/wasm/cooperative-threading-gc.s
2+
new file mode 100644
3+
index 0000000000000..2af2460939aad
4+
--- /dev/null
5+
+++ b/lld/test/wasm/cooperative-threading-gc.s
6+
@@ -0,0 +1,57 @@
7+
+# Verify that --gc-sections preserves functions reachable only through the
8+
+# thread-context accessors __wasm_{get,set}_tls_base. These accessors are
9+
+# invoked by synthetic init functions (e.g. __wasm_init_tls) via `call`
10+
+# instructions that carry no relocations, so the linker marks the accessors
11+
+# live explicitly. Their own relocations must still be followed during GC,
12+
+# otherwise functions they call (here modeling the cooperative-threading
13+
+# context.set builtin) are incorrectly collected and the call is mis-resolved.
14+
+
15+
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
16+
+# RUN: wasm-ld --cooperative-threading --gc-sections -o %t.wasm %t.o
17+
+# RUN: obj2yaml %t.wasm | FileCheck %s
18+
+
19+
+ .functype set_helper (i32) -> ()
20+
+ .import_module set_helper, "env"
21+
+ .import_name set_helper, "set_helper"
22+
+
23+
+.globl __wasm_get_tls_base
24+
+__wasm_get_tls_base:
25+
+ .functype __wasm_get_tls_base () -> (i32)
26+
+ i32.const 0
27+
+ end_function
28+
+
29+
+# Reachable only via the synthetic __wasm_init_tls. Its call to `set_helper`
30+
+# must keep `set_helper` live.
31+
+.globl __wasm_set_tls_base
32+
+__wasm_set_tls_base:
33+
+ .functype __wasm_set_tls_base (i32) -> ()
34+
+ local.get 0
35+
+ call set_helper
36+
+ end_function
37+
+
38+
+.globl _start
39+
+_start:
40+
+ .functype _start () -> (i32)
41+
+ call __wasm_get_tls_base
42+
+ i32.const tls1@TLSREL
43+
+ i32.add
44+
+ i32.load 0
45+
+ end_function
46+
+
47+
+.section .tdata.tls1,"",@
48+
+.globl tls1
49+
+tls1:
50+
+ .int32 1
51+
+ .size tls1, 4
52+
+
53+
+.section .custom_section.target_features,"",@
54+
+ .int8 2
55+
+ .int8 43
56+
+ .int8 11
57+
+ .ascii "bulk-memory"
58+
+ .int8 43
59+
+ .int8 7
60+
+ .ascii "atomics"
61+
+
62+
+# The imported helper called by __wasm_set_tls_base must survive GC.
63+
+# CHECK: Field: set_helper
64+
diff --git a/lld/wasm/MarkLive.cpp b/lld/wasm/MarkLive.cpp
65+
index 2b2cf19f14b30..3364be006ca24 100644
66+
--- a/lld/wasm/MarkLive.cpp
67+
+++ b/lld/wasm/MarkLive.cpp
68+
@@ -126,6 +126,20 @@ void MarkLive::run() {
69+
enqueueRetainedSegments(obj);
70+
}
71+
72+
+ // `__wasm_{get,set}_tls_base` are called from synthetic init functions (e.g.
73+
+ // `__wasm_init_tls`, `__wasm_init_memory`) via raw `call` instructions that
74+
+ // carry no relocations, so the mark phase below cannot discover the functions
75+
+ // they in turn call (e.g. the cooperative-threading
76+
+ // `context.get`/`context.set` builtins). They are already marked live, but
77+
+ // their defining chunks were never enqueued; enqueue them here so their
78+
+ // relocations are followed. This mirrors the handling of ctor functions
79+
+ // reached via `__wasm_call_ctors`.
80+
+ for (Symbol *sym : {static_cast<Symbol *>(ctx.sym.getTLSBase),
81+
+ static_cast<Symbol *>(ctx.sym.setTLSBase)})
82+
+ if (sym)
83+
+ if (InputChunk *c = sym->getChunk())
84+
+ enqueue(c);
85+
+
86+
mark();
87+
88+
// If we have any non-discarded init functions, mark `__wasm_call_ctors` as

src/llvm-project

Submodule llvm-project updated 11412 files

0 commit comments

Comments
 (0)