Skip to content

Commit 0583894

Browse files
committed
[Swift+WASM] [IRGen] disable debugger tuning and atomics on WebAssembly
LLVM doesn't support LLDB debugger tuning for WebAssembly (since lldb tuning generates a DWARF5 accel table even when DWARF5 is disabled, and WebAssembly doesn't support DWARF5). In addition, support for atomics is currently very limited. Set LLVM target options to avoid generating DWARF5 debug data and lower atomics to regular load/stores when building for WebAssembly. This shouldn't affect existing platforms.
1 parent 86e4467 commit 0583894

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/IRGen/IRGen.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ swift::getIRTargetOptions(IRGenOptions &Opts, ASTContext &Ctx) {
156156

157157
auto *Clang = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
158158
clang::TargetOptions &ClangOpts = Clang->getTargetInfo().getTargetOpts();
159+
160+
// WebAssembly doesn't support atomics or DWARF5 yet.
161+
// (LLVM debugger tuning generates a DWARF5 accel table even when DWARF5 is disabled)
162+
if (Clang->getTargetInfo().getTriple().isOSBinFormatWasm()) {
163+
TargetOpts.DebuggerTuning = llvm::DebuggerKind::Default;
164+
TargetOpts.ThreadModel = llvm::ThreadModel::Single;
165+
}
166+
159167
return std::make_tuple(TargetOpts, ClangOpts.CPU, ClangOpts.Features, ClangOpts.Triple);
160168
}
161169

0 commit comments

Comments
 (0)