aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-19 14:12:13 -0400
committerGitHub <noreply@github.com>2022-04-19 14:12:13 -0400
commit9c2cbe39c2caa9137e1123fcdf2f326282cad1b5 (patch)
treeda31a6f7307bcf03a87be3c7497600667b3a7c25 /src
parent78f26b970e1c5c288e45d0edd2ab2f229e6fe924 (diff)
parentbe08d2bdbd2f64ccb9ef0f985a57a4bf89b9aebb (diff)
downloadzig-9c2cbe39c2caa9137e1123fcdf2f326282cad1b5.tar.gz
zig-9c2cbe39c2caa9137e1123fcdf2f326282cad1b5.zip
Merge pull request #11461 from Luukdegram/wasm-debug-info
Wasm: add support for debug information
Diffstat (limited to 'src')
-rw-r--r--src/arch/wasm/CodeGen.zig3
-rw-r--r--src/link/Wasm.zig2
-rw-r--r--src/stage1/codegen.cpp3
-rw-r--r--src/stage1/target.cpp2
-rw-r--r--src/target.zig3
5 files changed, 9 insertions, 4 deletions
diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig
index ab0deb9f63..e58a3a6d65 100644
--- a/src/arch/wasm/CodeGen.zig
+++ b/src/arch/wasm/CodeGen.zig
@@ -871,7 +871,8 @@ fn genFunc(self: *Self) InnerError!void {
// we emit an unreachable instruction to tell the stack validator that part will never be reached.
if (func_type.returns.len != 0 and self.air.instructions.len > 0) {
const inst = @intCast(u32, self.air.instructions.len - 1);
- if (self.air.typeOfIndex(inst).isNoReturn()) {
+ const last_inst_ty = self.air.typeOfIndex(inst);
+ if (!last_inst_ty.hasRuntimeBitsIgnoreComptime() or last_inst_ty.isNoReturn()) {
try self.addTag(.@"unreachable");
}
}
diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig
index 1ed733774f..4f72dfe388 100644
--- a/src/link/Wasm.zig
+++ b/src/link/Wasm.zig
@@ -1897,7 +1897,7 @@ pub fn flushModule(self: *Wasm, comp: *Compilation, prog_node: *std.Progress.Nod
if (data_section_index) |data_index| {
try self.emitDataRelocations(file, arena, data_index, symbol_table);
}
- } else {
+ } else if (!self.base.options.strip) {
try self.emitNameSection(file, arena);
}
}
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp
index 40e4440102..3a83d93310 100644
--- a/src/stage1/codegen.cpp
+++ b/src/stage1/codegen.cpp
@@ -2645,6 +2645,9 @@ static LLVMValueRef ir_render_save_err_ret_addr(CodeGen *g, Stage1Air *executabl
Stage1AirInstSaveErrRetAddr *save_err_ret_addr_instruction)
{
assert(g->have_err_ret_tracing);
+ if ((target_is_wasm(g->zig_target) && g->zig_target->os != OsEmscripten) || target_is_bpf(g->zig_target)) {
+ return nullptr;
+ }
LLVMValueRef return_err_fn = get_return_err_fn(g);
bool is_llvm_alloca;
diff --git a/src/stage1/target.cpp b/src/stage1/target.cpp
index 7ff3008911..da6565f0be 100644
--- a/src/stage1/target.cpp
+++ b/src/stage1/target.cpp
@@ -1000,7 +1000,7 @@ ZigLLVM_EnvironmentType target_default_abi(ZigLLVM_ArchType arch, Os os) {
}
bool target_has_debug_info(const ZigTarget *target) {
- return !target_is_wasm(target);
+ return true;
}
bool target_long_double_is_f128(const ZigTarget *target) {
diff --git a/src/target.zig b/src/target.zig
index aafd65e327..27ed1118db 100644
--- a/src/target.zig
+++ b/src/target.zig
@@ -455,7 +455,8 @@ pub fn classifyCompilerRtLibName(target: std.Target, name: []const u8) CompilerR
}
pub fn hasDebugInfo(target: std.Target) bool {
- return !target.cpu.arch.isWasm();
+ _ = target;
+ return true;
}
pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode {