| ... | @@ -215,9 +215,10 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -215,9 +215,10 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 215 | lj->args.append(getLDMOption(&g->zig_target)); | 215 | lj->args.append(getLDMOption(&g->zig_target)); |
| 216 | | 216 | |
| 217 | bool is_lib = g->out_type == OutTypeLib; | 217 | bool is_lib = g->out_type == OutTypeLib; |
| 218 | bool shared = !g->is_static && is_lib; | 218 | bool is_static = g->is_static || (!is_lib && g->link_libs_list.length == 0); |
| | 219 | bool shared = !is_static && is_lib; |
| 219 | Buf *soname = nullptr; | 220 | Buf *soname = nullptr; |
| 220 | if (g->is_static) { | 221 | if (is_static) { |
| 221 | if (g->zig_target.arch.arch == ZigLLVM_arm || g->zig_target.arch.arch == ZigLLVM_armeb || | 222 | if (g->zig_target.arch.arch == ZigLLVM_arm || g->zig_target.arch.arch == ZigLLVM_armeb || |
| 222 | g->zig_target.arch.arch == ZigLLVM_thumb || g->zig_target.arch.arch == ZigLLVM_thumbeb) | 223 | g->zig_target.arch.arch == ZigLLVM_thumb || g->zig_target.arch.arch == ZigLLVM_thumbeb) |
| 223 | { | 224 | { |
| ... | @@ -241,7 +242,7 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -241,7 +242,7 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 241 | if (lj->link_in_crt) { | 242 | if (lj->link_in_crt) { |
| 242 | const char *crt1o; | 243 | const char *crt1o; |
| 243 | const char *crtbegino; | 244 | const char *crtbegino; |
| 244 | if (g->is_static) { | 245 | if (is_static) { |
| 245 | crt1o = "crt1.o"; | 246 | crt1o = "crt1.o"; |
| 246 | crtbegino = "crtbeginT.o"; | 247 | crtbegino = "crtbeginT.o"; |
| 247 | } else { | 248 | } else { |
| ... | @@ -292,7 +293,7 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -292,7 +293,7 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 292 | lj->args.append(buf_ptr(g->libc_static_lib_dir)); | 293 | lj->args.append(buf_ptr(g->libc_static_lib_dir)); |
| 293 | } | 294 | } |
| 294 | | 295 | |
| 295 | if (!g->is_static) { | 296 | if (!is_static) { |
| 296 | if (g->dynamic_linker != nullptr) { | 297 | if (g->dynamic_linker != nullptr) { |
| 297 | assert(buf_len(g->dynamic_linker) != 0); | 298 | assert(buf_len(g->dynamic_linker) != 0); |
| 298 | lj->args.append("-dynamic-linker"); | 299 | lj->args.append("-dynamic-linker"); |
| ... | @@ -344,7 +345,7 @@ static void construct_linker_job_elf(LinkJob *lj) { | ... | @@ -344,7 +345,7 @@ static void construct_linker_job_elf(LinkJob *lj) { |
| 344 | | 345 | |
| 345 | // libc dep | 346 | // libc dep |
| 346 | if (g->libc_link_lib != nullptr) { | 347 | if (g->libc_link_lib != nullptr) { |
| 347 | if (g->is_static) { | 348 | if (is_static) { |
| 348 | lj->args.append("--start-group"); | 349 | lj->args.append("--start-group"); |
| 349 | lj->args.append("-lgcc"); | 350 | lj->args.append("-lgcc"); |
| 350 | lj->args.append("-lgcc_eh"); | 351 | lj->args.append("-lgcc_eh"); |