diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-01 11:05:36 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-01 11:05:36 -0700 |
| commit | f18e34c2c6b7884a76d98d86b41857044dbe0f06 (patch) | |
| tree | 010a1f7d5a7689fb5ab31a56ad52aaa50e255a42 /src/link.cpp | |
| parent | 320e26590a31351301992dc7067eb287e4f565f4 (diff) | |
| download | zig-f18e34c2c6b7884a76d98d86b41857044dbe0f06.tar.gz zig-f18e34c2c6b7884a76d98d86b41857044dbe0f06.zip | |
restore shared library functionality
Diffstat (limited to 'src/link.cpp')
| -rw-r--r-- | src/link.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/link.cpp b/src/link.cpp index 1e06566074..2ee7d2d111 100644 --- a/src/link.cpp +++ b/src/link.cpp @@ -159,6 +159,7 @@ static void construct_linker_job_linux(LinkJob *lj) { bool is_lib = g->out_type == OutTypeLib; bool shared = !g->is_static && is_lib; + Buf *soname = nullptr; if (g->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) @@ -169,6 +170,11 @@ static void construct_linker_job_linux(LinkJob *lj) { } } else if (shared) { lj->args.append("-shared"); + + buf_resize(&lj->out_file, 0); + buf_appendf(&lj->out_file, "lib%s.so.%d.%d.%d", + buf_ptr(g->root_out_name), g->version_major, g->version_minor, g->version_patch); + soname = buf_sprintf("lib%s.so.%d", buf_ptr(g->root_out_name), g->version_major); } lj->args.append("-o"); @@ -211,11 +217,7 @@ static void construct_linker_job_linux(LinkJob *lj) { lj->args.append(buf_ptr(get_dynamic_linker(g->target_machine))); } - if (g->out_type == OutTypeLib) { - buf_resize(&lj->out_file, 0); - buf_appendf(&lj->out_file, "lib%s.so.%d.%d.%d", - buf_ptr(g->root_out_name), g->version_major, g->version_minor, g->version_patch); - Buf *soname = buf_sprintf("lib%s.so.%d", buf_ptr(g->root_out_name), g->version_major); + if (shared) { lj->args.append("-soname"); lj->args.append(buf_ptr(soname)); } @@ -849,7 +851,9 @@ void codegen_link(CodeGen *g, const char *out_file) { fprintf(stderr, "%s\n", buf_ptr(&ld_stderr)); } - if (g->out_type == OutTypeLib) { + if (g->out_type == OutTypeLib || + g->out_type == OutTypeObj) + { codegen_generate_h_file(g); } |
