mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-30 01:44:36 +00:00
Fix debug symbol generation
This commit is contained in:
@@ -6614,7 +6614,7 @@ gbString gb_string_append_fmt(gbString str, char const *fmt, ...) {
|
||||
char buf[4096] = {0};
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
res = gb_snprintf_va(str, gb_count_of(buf)-1, fmt, va);
|
||||
res = gb_snprintf_va(buf, gb_count_of(buf)-1, fmt, va)-1;
|
||||
va_end(va);
|
||||
return gb_string_append_length(str, buf, res);
|
||||
}
|
||||
|
||||
@@ -1763,14 +1763,14 @@ void ir_print_proc(irFileBuffer *f, irModule *m, irProcedure *proc) {
|
||||
default:
|
||||
ir_fprintf(f, "#0 ");
|
||||
break;
|
||||
case ProcInlining_no_inline:
|
||||
ir_write_string(f, "noinline ");
|
||||
ir_fprintf(f, "#0 ");
|
||||
break;
|
||||
case ProcInlining_inline:
|
||||
ir_write_string(f, "alwaysinline ");
|
||||
ir_fprintf(f, "#1 ");
|
||||
break;
|
||||
case ProcInlining_no_inline:
|
||||
ir_write_string(f, "noinline ");
|
||||
ir_fprintf(f, "#2 ");
|
||||
break;
|
||||
}
|
||||
|
||||
if (m->generate_debug_info && proc->entity != nullptr && proc->body != nullptr) {
|
||||
@@ -1857,11 +1857,12 @@ void print_llvm_ir(irGen *ir) {
|
||||
ir_file_buffer_init(f, &ir->output_file);
|
||||
defer (ir_file_buffer_destroy(f));
|
||||
|
||||
if (m->generate_debug_info) {
|
||||
i32 word_bits = cast(i32)(8*build_context.word_size);
|
||||
ir_fprintf(f, "target datalayout = \"e-m:w-i%d:%d-f80:128-n8:16:32:64-S128\"\n", word_bits, word_bits);
|
||||
ir_fprintf(f, "target triple = \"x86%s-pc-windows-msvc17\"\n\n", word_bits == 64 ? "-64" : "");
|
||||
ir_fprintf(f, "\n\n");
|
||||
i32 word_bits = cast(i32)(8*build_context.word_size);
|
||||
if (build_context.ODIN_OS == "osx" || build_context.ODIN_OS == "macos") {
|
||||
GB_ASSERT(word_bits == 64);
|
||||
ir_write_string(f, "target triple = x86_64-apple-macosx10.8\n\n");
|
||||
} else if (build_context.ODIN_OS == "windows") {
|
||||
ir_fprintf(f, "target triple = \"x86%s-pc-windows\"\n\n", word_bits == 64 ? "_64" : "");
|
||||
}
|
||||
|
||||
ir_print_encoded_local(f, str_lit("..opaque"));
|
||||
@@ -1988,6 +1989,9 @@ void print_llvm_ir(irGen *ir) {
|
||||
ir_write_byte(f, '\n');
|
||||
}
|
||||
|
||||
ir_fprintf(f, "attributes #0 = {nounwind uwtable}\n");
|
||||
ir_fprintf(f, "attributes #1 = {nounwind alwaysinline uwtable}\n");
|
||||
ir_fprintf(f, "attributes #2 = {nounwind noinline optnone uwtable}\n");
|
||||
|
||||
if (m->generate_debug_info) {
|
||||
ir_write_byte(f, '\n');
|
||||
@@ -1999,8 +2003,6 @@ void print_llvm_ir(irGen *ir) {
|
||||
i32 di_code_view = diec+3;
|
||||
i32 di_wchar_size = diec+4;
|
||||
|
||||
ir_fprintf(f, "attributes #0 = {nounwind noinline optnone uwtable}\n");
|
||||
ir_fprintf(f, "attributes #1 = {nounwind alwaysinline uwtable}\n");
|
||||
|
||||
|
||||
ir_fprintf(f, "!llvm.dbg.cu = !{!%d}\n", m->debug_compile_unit->id);
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -736,16 +736,10 @@ int main(int arg_count, char **arg_ptr) {
|
||||
// NOTE(zangent): This is separate because it seems that LLVM tools are packaged
|
||||
// with the Windows version, while they will be system-provided on MacOS and GNU/Linux
|
||||
exit_code = system_exec_command_line_app("llvm-opt", false,
|
||||
"opt \"%.*s\".ll -o \"%.*s\".bc %.*s "
|
||||
"opt \"%.*s.ll\" -o \"%.*s\".bc %.*s "
|
||||
"-mem2reg "
|
||||
"-memcpyopt "
|
||||
"-die "
|
||||
#if defined(GB_SYSTEM_OSX)
|
||||
// This sets a requirement of Mountain Lion and up, but the compiler doesn't work without this limit.
|
||||
// NOTE: If you change this (although this minimum is as low as you can go with Odin working)
|
||||
// make sure to also change the 'macosx_version_min' param passed to 'llc'
|
||||
"-mtriple=x86_64-apple-macosx10.8 "
|
||||
#endif
|
||||
"",
|
||||
LIT(output_base), LIT(output_base),
|
||||
LIT(build_context.opt_flags));
|
||||
@@ -759,12 +753,14 @@ int main(int arg_count, char **arg_ptr) {
|
||||
// For more arguments: http://llvm.org/docs/CommandGuide/llc.html
|
||||
exit_code = system_exec_command_line_app("llvm-llc", false,
|
||||
"\"%.*sbin/llc\" \"%.*s.bc\" -filetype=obj -O%d "
|
||||
"-o \"%.*s.obj\" "
|
||||
"%.*s "
|
||||
// "-debug-pass=Arguments "
|
||||
"",
|
||||
LIT(build_context.ODIN_ROOT),
|
||||
LIT(output_base),
|
||||
build_context.optimization_level,
|
||||
LIT(output_base),
|
||||
LIT(build_context.llc_flags));
|
||||
if (exit_code != 0) {
|
||||
return exit_code;
|
||||
@@ -794,7 +790,7 @@ int main(int arg_count, char **arg_ptr) {
|
||||
link_settings = gb_string_append_fmt(link_settings, "/ENTRY:mainCRTStartup");
|
||||
}
|
||||
|
||||
if (build_context.debug) {
|
||||
if (ir_gen.module.generate_debug_info) {
|
||||
link_settings = gb_string_append_fmt(link_settings, " /DEBUG");
|
||||
}
|
||||
|
||||
@@ -809,7 +805,7 @@ int main(int arg_count, char **arg_ptr) {
|
||||
LIT(output_base), LIT(output_base), output_ext,
|
||||
lib_str, LIT(build_context.link_flags),
|
||||
link_settings
|
||||
);
|
||||
);
|
||||
if (exit_code != 0) {
|
||||
return exit_code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user