aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gb/gb.h2
-rw-r--r--src/ir_print.cpp24
-rw-r--r--src/main.cpp14
3 files changed, 19 insertions, 21 deletions
diff --git a/src/gb/gb.h b/src/gb/gb.h
index 3e3f147dc..5d03aed36 100644
--- a/src/gb/gb.h
+++ b/src/gb/gb.h
@@ -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);
}
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 487a0bf5f..bb8259800 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -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);
diff --git a/src/main.cpp b/src/main.cpp
index 35983d1db..cc58a7144 100644
--- a/src/main.cpp
+++ b/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;
}