diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-10-05 18:31:25 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-10-05 18:34:37 -0400 |
| commit | 4640853d1b49ec17e1e997901c58c2294aca30d6 (patch) | |
| tree | 50d6c2b55e0f8afe50624df558c9e1b8e18f08a5 /src/link.cpp | |
| parent | 8700f4d2b1a169515314fe57bd9f080a906efa59 (diff) | |
| download | zig-4640853d1b49ec17e1e997901c58c2294aca30d6.tar.gz zig-4640853d1b49ec17e1e997901c58c2294aca30d6.zip | |
on linux, link statically if not linking any shared libs
Diffstat (limited to 'src/link.cpp')
| -rw-r--r-- | src/link.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/link.cpp b/src/link.cpp index e3753bff24..8b75f0e783 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -215,9 +215,10 @@ static void construct_linker_job_elf(LinkJob *lj) { lj->args.append(getLDMOption(&g->zig_target)); bool is_lib = g->out_type == OutTypeLib; - bool shared = !g->is_static && is_lib; + bool is_static = g->is_static || (!is_lib && g->link_libs_list.length == 0); + bool shared = !is_static && is_lib; Buf *soname = nullptr; - if (g->is_static) { + if (is_static) { if (g->zig_target.arch.arch == ZigLLVM_arm || g->zig_target.arch.arch == ZigLLVM_armeb || g->zig_target.arch.arch == ZigLLVM_thumb || g->zig_target.arch.arch == ZigLLVM_thumbeb) { @@ -241,7 +242,7 @@ static void construct_linker_job_elf(LinkJob *lj) { if (lj->link_in_crt) { const char *crt1o; const char *crtbegino; - if (g->is_static) { + if (is_static) { crt1o = "crt1.o"; crtbegino = "crtbeginT.o"; } else { @@ -292,7 +293,7 @@ static void construct_linker_job_elf(LinkJob *lj) { lj->args.append(buf_ptr(g->libc_static_lib_dir)); } - if (!g->is_static) { + if (!is_static) { if (g->dynamic_linker != nullptr) { assert(buf_len(g->dynamic_linker) != 0); lj->args.append("-dynamic-linker"); @@ -344,7 +345,7 @@ static void construct_linker_job_elf(LinkJob *lj) { // libc dep if (g->libc_link_lib != nullptr) { - if (g->is_static) { + if (is_static) { lj->args.append("--start-group"); lj->args.append("-lgcc"); lj->args.append("-lgcc_eh"); |
