aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2021-06-16 12:14:50 +0200
committerVeikka Tuominen <git@vexu.eu>2021-06-18 08:29:23 +0300
commitccb6e1627ec76ffeccef9bdcce321c21d1e72bfd (patch)
tree51a7a47e48fa34cfd6855878013ca1fe10e9b475 /src
parentb9e78593bbb1a92f282795a12462b17ad18ecc8a (diff)
downloadzig-ccb6e1627ec76ffeccef9bdcce321c21d1e72bfd.tar.gz
zig-ccb6e1627ec76ffeccef9bdcce321c21d1e72bfd.zip
stage1: Store the specified code model in the LLVM module
This is needed for LTO builds to pick up the correct module. Closes #9132
Diffstat (limited to 'src')
-rw-r--r--src/stage1/codegen.cpp4
-rw-r--r--src/zig_llvm.cpp6
-rw-r--r--src/zig_llvm.h1
3 files changed, 11 insertions, 0 deletions
diff --git a/src/stage1/codegen.cpp b/src/stage1/codegen.cpp
index d0ec853f06..040203fbab 100644
--- a/src/stage1/codegen.cpp
+++ b/src/stage1/codegen.cpp
@@ -9289,6 +9289,10 @@ static void init(CodeGen *g) {
ZigLLVMSetModulePIELevel(g->module);
}
+ if (g->code_model != CodeModelDefault) {
+ ZigLLVMSetModuleCodeModel(g->module, to_llvm_code_model(g));
+ }
+
const char *target_specific_cpu_args = "";
const char *target_specific_features = "";
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index 722b77406e..8c54af4bb4 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -969,6 +969,12 @@ void ZigLLVMSetModulePIELevel(LLVMModuleRef module) {
unwrap(module)->setPIELevel(PIELevel::Level::Large);
}
+void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model) {
+ bool JIT;
+ unwrap(module)->setCodeModel(*unwrap(code_model, JIT));
+ assert(!JIT);
+}
+
static AtomicOrdering mapFromLLVMOrdering(LLVMAtomicOrdering Ordering) {
switch (Ordering) {
case LLVMAtomicOrderingNotAtomic: return AtomicOrdering::NotAtomic;
diff --git a/src/zig_llvm.h b/src/zig_llvm.h
index 0d08980835..32a969f70e 100644
--- a/src/zig_llvm.h
+++ b/src/zig_llvm.h
@@ -208,6 +208,7 @@ ZIG_EXTERN_C void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module);
ZIG_EXTERN_C void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module);
ZIG_EXTERN_C void ZigLLVMSetModulePICLevel(LLVMModuleRef module);
ZIG_EXTERN_C void ZigLLVMSetModulePIELevel(LLVMModuleRef module);
+ZIG_EXTERN_C void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model);
ZIG_EXTERN_C void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column,
struct ZigLLVMDIScope *scope);