| ... | ... | @@ -8457,8 +8457,21 @@ static void init(CodeGen *g) { |
| 8457 | 8457 | Buf *producer = buf_sprintf("zig %d.%d.%d", ZIG_VERSION_MAJOR, ZIG_VERSION_MINOR, ZIG_VERSION_PATCH); |
| 8458 | 8458 | const char *flags = ""; |
| 8459 | 8459 | unsigned runtime_version = 0; |
| 8460 | |
| 8461 | // For macOS stack traces, we want to avoid having to parse the compilation unit debug |
| 8462 | // info. As long as each debug info file has a path independent of the compilation unit |
| 8463 | // directory (DW_AT_comp_dir), then we never have to look at the compilation unit debug |
| 8464 | // info. If we provide an absolute path to LLVM here for the compilation unit debug info, |
| 8465 | // LLVM will emit DWARF info that depends on DW_AT_comp_dir. To avoid this, we pass "." |
| 8466 | // for the compilation unit directory. This forces each debug file to have a directory |
| 8467 | // rather than be relative to DW_AT_comp_dir. According to DWARF 5, debug files will |
| 8468 | // no longer reference DW_AT_comp_dir, for the purpose of being able to support the |
| 8469 | // common practice of stripping all but the line number sections from an executable. |
| 8470 | const char *compile_unit_dir = target_os_is_darwin(g->zig_target->os) ? "." : |
| 8471 | buf_ptr(&g->root_package->root_src_dir); |
| 8472 | |
| 8460 | 8473 | ZigLLVMDIFile *compile_unit_file = ZigLLVMCreateFile(g->dbuilder, buf_ptr(g->root_out_name), |
| 8461 | | buf_ptr(&g->root_package->root_src_dir)); |
| 8474 | compile_unit_dir); |
| 8462 | 8475 | g->compile_unit = ZigLLVMCreateCompileUnit(g->dbuilder, ZigLLVMLang_DW_LANG_C99(), |
| 8463 | 8476 | compile_unit_file, buf_ptr(producer), is_optimized, flags, runtime_version, |
| 8464 | 8477 | "", 0, !g->strip_debug_symbols); |