authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-09-21 17:40:50-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-09-21 17:40:50-04:00
log7aeca9bfed654f7f5d0e4b9775459b878f4726ed
treef883943fdfb3cbad4807e0e774e444de2ac7c499
parent3f8f0b9bba5407ed5f7279bfdb7d22afaa126674

fix incorrect linking from previous commit


2 files changed, 21 insertions(+), 15 deletions(-)

src/link.cpp+20-14
...@@ -31,6 +31,14 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) {...@@ -31,6 +31,14 @@ static const char *get_libc_static_file(CodeGen *g, const char *file) {
31 return buf_ptr(out_buf);31 return buf_ptr(out_buf);
32}32}
3333
34static const char *get_o_file_extension(CodeGen *g) {
35 if (g->zig_target.env_type == ZigLLVM_MSVC) {
36 return ".obj";
37 } else {
38 return ".o";
39 }
40}
41
34static Buf *build_o(CodeGen *parent_gen, const char *oname) {42static Buf *build_o(CodeGen *parent_gen, const char *oname) {
35 Buf *source_basename = buf_sprintf("%s.zig", oname);43 Buf *source_basename = buf_sprintf("%s.zig", oname);
36 Buf *std_dir_path = parent_gen->zig_std_dir;44 Buf *std_dir_path = parent_gen->zig_std_dir;
...@@ -62,20 +70,13 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {...@@ -62,20 +70,13 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {
62 }70 }
6371
64 codegen_add_root_code(child_gen, std_dir_path, source_basename, &source_code);72 codegen_add_root_code(child_gen, std_dir_path, source_basename, &source_code);
65 Buf *o_out = buf_sprintf("%s.o", oname);73 const char *o_ext = get_o_file_extension(child_gen);
74 Buf *o_out = buf_sprintf("%s%s", oname, o_ext);
66 codegen_link(child_gen, buf_ptr(o_out));75 codegen_link(child_gen, buf_ptr(o_out));
6776
68 return o_out;77 return o_out;
69}78}
7079
71static const char *get_o_file_extension(CodeGen *g) {
72 if (g->zig_target.env_type == ZigLLVM_MSVC) {
73 return ".obj";
74 } else {
75 return ".o";
76 }
77}
78
79static const char *get_exe_file_extension(CodeGen *g) {80static const char *get_exe_file_extension(CodeGen *g) {
80 if (g->zig_target.os == ZigLLVM_Win32) {81 if (g->zig_target.os == ZigLLVM_Win32) {
81 return ".exe";82 return ".exe";
...@@ -786,16 +787,21 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -786,16 +787,21 @@ void codegen_link(CodeGen *g, const char *out_file) {
786 fprintf(stderr, "-------\n");787 fprintf(stderr, "-------\n");
787 }788 }
788789
789 if (buf_len(&lj.out_file) == 0) {790 bool override_out_file = (buf_len(&lj.out_file) != 0);
791 if (!override_out_file) {
790 assert(g->root_out_name);792 assert(g->root_out_name);
793
791 buf_init_from_buf(&lj.out_file, g->root_out_name);794 buf_init_from_buf(&lj.out_file, g->root_out_name);
792 buf_append_str(&lj.out_file, get_exe_file_extension(g));795 if (g->out_type == OutTypeExe) {
796 buf_append_str(&lj.out_file, get_exe_file_extension(g));
797 }
793 }798 }
794
795 buf_init_from_buf(&lj.out_file_o, &lj.out_file);799 buf_init_from_buf(&lj.out_file_o, &lj.out_file);
796800
797 const char *o_ext = get_o_file_extension(g);801 if (g->out_type != OutTypeObj || !override_out_file) {
798 buf_append_str(&lj.out_file_o, o_ext);802 const char *o_ext = get_o_file_extension(g);
803 buf_append_str(&lj.out_file_o, o_ext);
804 }
799805
800 char *err_msg = nullptr;806 char *err_msg = nullptr;
801 if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o),807 if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o),
std/debug.zig+1-1
...@@ -196,7 +196,7 @@ fn parseFormValue(in_stream: &io.InStream, form_id: u64, is_64: bool) -> %FormVa...@@ -196,7 +196,7 @@ fn parseFormValue(in_stream: &io.InStream, form_id: u64, is_64: bool) -> %FormVa
196 const child_form_id = %return readULeb128(in_stream);196 const child_form_id = %return readULeb128(in_stream);
197 parseFormValue(in_stream, child_form_id, is_64)197 parseFormValue(in_stream, child_form_id, is_64)
198 },198 },
199 else => return error.InvalidDebugInfo,199 else => error.InvalidDebugInfo,
200 }200 }
201}201}
202202