From 20c36949e1d82e9e8790ca51a0f7713f6e853ff0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 13 Mar 2019 23:15:34 -0400 Subject: fix target_requires_pic and reloc_mode disable failing thread local variable test. see #2063 --- src/codegen.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/codegen.cpp') diff --git a/src/codegen.cpp b/src/codegen.cpp index 11a368cda6..44e66c4dd8 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7288,7 +7288,7 @@ static bool detect_dynamic_link(CodeGen *g) { return true; if (g->zig_target->os == OsFreestanding) return false; - if (target_requires_pic(g->zig_target)) + if (target_requires_pic(g->zig_target, g->libc_link_lib != nullptr)) return true; if (g->out_type == OutTypeExe) { // If there are no dynamic libraries then we can disable PIC @@ -7304,7 +7304,7 @@ static bool detect_dynamic_link(CodeGen *g) { } static bool detect_pic(CodeGen *g) { - if (target_requires_pic(g->zig_target)) + if (target_requires_pic(g->zig_target, g->libc_link_lib != nullptr)) return true; switch (g->want_pic) { case WantPICDisabled: @@ -7848,7 +7848,14 @@ static void init(CodeGen *g) { bool is_optimized = g->build_mode != BuildModeDebug; LLVMCodeGenOptLevel opt_level = is_optimized ? LLVMCodeGenLevelAggressive : LLVMCodeGenLevelNone; - LLVMRelocMode reloc_mode = g->have_pic ? LLVMRelocPIC: LLVMRelocStatic; + LLVMRelocMode reloc_mode; + if (g->have_pic) { + reloc_mode = LLVMRelocPIC; + } else if (g->have_dynamic_link) { + reloc_mode = LLVMRelocDynamicNoPic; + } else { + reloc_mode = LLVMRelocStatic; + } const char *target_specific_cpu_args; const char *target_specific_features; -- cgit v1.2.3