diff --git a/compilers/concrete-compiler/compiler/include/concretelang/Runtime/utils.h b/compilers/concrete-compiler/compiler/include/concretelang/Runtime/utils.h new file mode 100644 index 0000000000..71c1fb39bf --- /dev/null +++ b/compilers/concrete-compiler/compiler/include/concretelang/Runtime/utils.h @@ -0,0 +1,21 @@ +// Part of the Concrete Compiler Project, under the BSD3 License with Zama +// Exceptions. See +// https://github.com/zama-ai/concrete/blob/main/LICENSE.txt +// for license information. + +#ifndef CONCRETELANG_RUNTIME_UTILS_H +#define CONCRETELANG_RUNTIME_UTILS_H + +#include "llvm/Support/TargetSelect.h" + +namespace mlir { +namespace concretelang { + +// Mainly a wrapper to some LLVM functions. The reason to have this wrapper is +// to avoid linking conflicts between the python binary extension, and LLVM. +void LLVMInitializeNativeTarget(); + +} // namespace concretelang +} // namespace mlir + +#endif diff --git a/compilers/concrete-compiler/compiler/lib/Runtime/CMakeLists.txt b/compilers/concrete-compiler/compiler/lib/Runtime/CMakeLists.txt index 2b2b7e429f..0cb8c8a99b 100644 --- a/compilers/concrete-compiler/compiler/lib/Runtime/CMakeLists.txt +++ b/compilers/concrete-compiler/compiler/lib/Runtime/CMakeLists.txt @@ -1,11 +1,11 @@ add_compile_options(-fsized-deallocation) if(CONCRETELANG_CUDA_SUPPORT) - add_library(ConcretelangRuntime SHARED context.cpp simulation.cpp wrappers.cpp DFRuntime.cpp key_manager.cpp + add_library(ConcretelangRuntime SHARED context.cpp utils.cpp simulation.cpp wrappers.cpp DFRuntime.cpp key_manager.cpp GPUDFG.cpp) target_link_libraries(ConcretelangRuntime PRIVATE hwloc) else() - add_library(ConcretelangRuntime SHARED context.cpp simulation.cpp wrappers.cpp DFRuntime.cpp key_manager.cpp + add_library(ConcretelangRuntime SHARED context.cpp utils.cpp simulation.cpp wrappers.cpp DFRuntime.cpp key_manager.cpp GPUDFG.cpp) endif() diff --git a/compilers/concrete-compiler/compiler/lib/Runtime/utils.cpp b/compilers/concrete-compiler/compiler/lib/Runtime/utils.cpp new file mode 100644 index 0000000000..2067b339b9 --- /dev/null +++ b/compilers/concrete-compiler/compiler/lib/Runtime/utils.cpp @@ -0,0 +1,15 @@ +// Part of the Concrete Compiler Project, under the BSD3 License with Zama +// Exceptions. See +// https://github.com/zama-ai/concrete/blob/main/LICENSE.txt +// for license information. + +#include "concretelang/Runtime/utils.h" + +namespace mlir { +namespace concretelang { +void LLVMInitializeNativeTarget() { + llvm::InitializeNativeTarget(); + llvm::InitializeNativeTargetAsmPrinter(); +} +} // namespace concretelang +} // namespace mlir diff --git a/compilers/concrete-compiler/compiler/lib/Support/Pipeline.cpp b/compilers/concrete-compiler/compiler/lib/Support/Pipeline.cpp index 17ccd7001c..a172b46f29 100644 --- a/compilers/concrete-compiler/compiler/lib/Support/Pipeline.cpp +++ b/compilers/concrete-compiler/compiler/lib/Support/Pipeline.cpp @@ -49,6 +49,7 @@ #include "concretelang/Dialect/RT/Transforms/Passes.h" #include "concretelang/Dialect/TFHE/Analysis/ExtractStatistics.h" #include "concretelang/Dialect/TFHE/Transforms/Transforms.h" +#include "concretelang/Runtime/utils.h" #include "concretelang/Support/CompilerEngine.h" #include "concretelang/Support/Error.h" #include "concretelang/Support/Pipeline.h" @@ -611,8 +612,7 @@ std::unique_ptr lowerLLVMDialectToLLVMIR(mlir::MLIRContext &context, llvm::LLVMContext &llvmContext, mlir::ModuleOp &module) { - llvm::InitializeNativeTarget(); - llvm::InitializeNativeTargetAsmPrinter(); + mlir::concretelang::LLVMInitializeNativeTarget(); mlir::registerLLVMDialectTranslation(*module->getContext()); mlir::registerOpenMPDialectTranslation(*module->getContext());