aboutsummaryrefslogtreecommitdiff
path: root/src/codegen.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-10-09 13:20:27 -0400
committerGitHub <noreply@github.com>2018-10-09 13:20:27 -0400
commit9e38a81230bcaefb50fae610c071005449a7abfb (patch)
treef706728a6b853da0b66379539018645df583519b /src/codegen.cpp
parentd40c4e7c896c5dfed9dd35e8c0d2117f7cf5c53c (diff)
parent81c6f087241b6b7a1c12de72a2061cb02df0f93f (diff)
downloadzig-9e38a81230bcaefb50fae610c071005449a7abfb.tar.gz
zig-9e38a81230bcaefb50fae610c071005449a7abfb.zip
Merge pull request #1647 from ziglang/static-libs
Support building static libraries
Diffstat (limited to 'src/codegen.cpp')
-rw-r--r--src/codegen.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp
index e792fd77aa..02105b4d2a 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -7228,7 +7228,10 @@ static void init(CodeGen *g) {
bool is_optimized = g->build_mode != BuildModeDebug;
LLVMCodeGenOptLevel opt_level = is_optimized ? LLVMCodeGenLevelAggressive : LLVMCodeGenLevelNone;
- LLVMRelocMode reloc_mode = g->is_static ? LLVMRelocStatic : LLVMRelocPIC;
+ if (g->out_type == OutTypeExe && g->is_static) {
+ g->disable_pic = true;
+ }
+ LLVMRelocMode reloc_mode = g->disable_pic ? LLVMRelocStatic : LLVMRelocPIC;
const char *target_specific_cpu_args;
const char *target_specific_features;
@@ -7487,7 +7490,9 @@ static void gen_root_source(CodeGen *g) {
{
g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap.zig");
}
- if (g->zig_target.os == OsWindows && !g->have_dllmain_crt_startup && g->out_type == OutTypeLib) {
+ if (g->zig_target.os == OsWindows && !g->have_dllmain_crt_startup &&
+ g->out_type == OutTypeLib && !g->is_static)
+ {
g->bootstrap_import = add_special_code(g, create_bootstrap_pkg(g, g->root_package), "bootstrap_lib.zig");
}
@@ -8045,6 +8050,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
cache_bool(ch, g->linker_rdynamic);
cache_bool(ch, g->no_rosegment_workaround);
cache_bool(ch, g->each_lib_rpath);
+ cache_bool(ch, g->disable_pic);
cache_buf_opt(ch, g->mmacosx_version_min);
cache_buf_opt(ch, g->mios_version_min);
cache_usize(ch, g->version_major);