From 05db4ab95d59a2712f9209c4cf106b038cc543a4 Mon Sep 17 00:00:00 2001 From: Colin Davidson Date: Tue, 5 Mar 2024 14:24:25 +0000 Subject: [PATCH] Use PIC_ reloc model when link_shared is set in cookie target For using a cpu model based on dlopen we need to set the PIC_ relocation model when we create the target machine. This is based off the link_shared cookie option. --- .../cookie/{{cookiecutter.target_name}}/source/module.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp index 5e14a0b76..7156bdf72 100644 --- a/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp +++ b/modules/compiler/cookie/{{cookiecutter.target_name}}/source/module.cpp @@ -227,7 +227,8 @@ static llvm::TargetMachine *createTargetMachine(const {{cookiecutter.target_name return llvm_target->createTargetMachine( target.llvm_triple, target.llvm_cpu, target.llvm_features, options, - llvm::Reloc::Model::Static, llvm::CodeModel::Small, + {{cookiecutter.link_shared}} ? llvm::Reloc::Model::PIC_ : llvm::Reloc::Model::Static, + llvm::CodeModel::Small, multi_llvm::CodeGenOptLevel::Aggressive); }