Skip to content

Commit c6a18e9

Browse files
committed
libcxx: fix building for wasm32-wasi by disabling exceptions
I accidentally regressed this in the LLVM 20 upgrade. Closes #24437.
1 parent 5696bbb commit c6a18e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/libs/libcxx.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ pub fn buildLibCxx(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
211211
try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
212212
try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
213213

214+
if (target.os.tag == .wasi) {
215+
try cflags.append("-fno-exceptions");
216+
}
217+
214218
try cflags.append("-fvisibility=hidden");
215219
try cflags.append("-fvisibility-inlines-hidden");
216220

@@ -388,6 +392,9 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
388392
for (libcxxabi_files) |cxxabi_src| {
389393
if (!comp.config.any_non_single_threaded and std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp"))
390394
continue;
395+
if (target.os.tag == .wasi and
396+
(std.mem.eql(u8, cxxabi_src, "src/cxa_exception.cpp") or std.mem.eql(u8, cxxabi_src, "src/cxa_personality.cpp")))
397+
continue;
391398

392399
var cflags = std.ArrayList([]const u8).init(arena);
393400

@@ -403,6 +410,10 @@ pub fn buildLibCxxAbi(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
403410
try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
404411
}
405412

413+
if (target.os.tag == .wasi) {
414+
try cflags.append("-fno-exceptions");
415+
}
416+
406417
try cflags.append("-fvisibility=hidden");
407418
try cflags.append("-fvisibility-inlines-hidden");
408419

0 commit comments

Comments
 (0)