wasm: Add support for debug info

This implements basic DWARF output when building for the wasm target.
Stacktraces, however, are currently not supported.
This commit is contained in:
Luuk de Gram 2022-04-18 13:11:37 +02:00
parent f8d2b87fa1
commit 2193f7c4a2
No known key found for this signature in database
GPG Key ID: A8CFE58E4DC7D664
4 changed files with 10 additions and 2 deletions

View File

@ -114,6 +114,10 @@ pub fn detectTTYConfig() TTY.Config {
pub fn dumpCurrentStackTrace(start_addr: ?usize) void {
nosuspend {
const stderr = io.getStdErr().writer();
if (comptime builtin.target.isWasm()) {
stderr.print("Unable to dump stack trace: not implemented for Wasm\n", .{}) catch return;
return;
}
if (builtin.strip_debug_info) {
stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catch return;
return;

View File

@ -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;

View File

@ -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) {

View File

@ -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 {