fix(common): fix llvm symbol clash with torch dyn lib

This commit is contained in:
Alexandre Péré
2025-04-02 09:16:09 +02:00
parent e90d7c7ff3
commit b5bae3d8ed
5 changed files with 42 additions and 3 deletions

View File

@@ -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

View File

@@ -3,6 +3,7 @@ add_compile_options(-fsized-deallocation)
if(CONCRETELANG_CUDA_SUPPORT)
add_library(
ConcretelangRuntime SHARED
utils.cpp
context.cpp
simulation.cpp
wrappers.cpp
@@ -13,6 +14,7 @@ if(CONCRETELANG_CUDA_SUPPORT)
else()
add_library(
ConcretelangRuntime SHARED
utils.cpp
context.cpp
simulation.cpp
wrappers.cpp

View File

@@ -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

View File

@@ -39,6 +39,7 @@ add_mlir_library(
MLIRExecutionEngine
${LLVM_PTHREAD_LIB}
TFHEDialectAnalysis
ConcreteDialectAnalysis)
ConcreteDialectAnalysis
ConcretelangRuntime)
target_include_directories(ConcretelangSupport PUBLIC ${CONCRETE_CPU_INCLUDE_DIR})

View File

@@ -51,6 +51,7 @@
#include "concretelang/Dialect/SDFG/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"
@@ -630,8 +631,7 @@ std::unique_ptr<llvm::Module>
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());