Use clang instead if llvm-lto for darwin-based targets (#2974)
* Use LLVM C API for optimizations * Use Clang for bitcode compilation * Test bitcode embedding
This commit is contained in:
@@ -30,6 +30,15 @@ model {
|
||||
if (!project.parent.convention.plugins.platformInfo.isWindows())
|
||||
cppCompiler.args "-fPIC"
|
||||
cppCompiler.args "--std=c++11", "-I${llvmDir}/include", "-I${projectDir}/src/main/include"
|
||||
if (isMac()) {
|
||||
cppCompiler.args "-DKONAN_MACOS=1"
|
||||
} else if (isWindows()) {
|
||||
cppCompiler.args "-DKONAN_WINDOWS=1"
|
||||
} else if (isLinux()) {
|
||||
cppCompiler.args "-DKONAN_LINUX=1"
|
||||
} else {
|
||||
throw new Error("Unsupported host OS.")
|
||||
}
|
||||
linker.args "-L${llvmDir}/lib", "-lLLVMCore", "-lLLVMSupport"
|
||||
}
|
||||
binaries.withType(SharedLibraryBinarySpec) { binary ->
|
||||
|
||||
@@ -227,4 +227,22 @@ void LLVMAddInstrProfPass(LLVMPassManagerRef passManagerRef, const char* outputF
|
||||
LLVMTargetLibraryInfoRef LLVMGetTargetLibraryInfo(LLVMModuleRef moduleRef) {
|
||||
auto* libraryInfo = new TargetLibraryInfoImpl(Triple(unwrap(moduleRef)->getTargetTriple()));
|
||||
return llvm::wrap(libraryInfo);
|
||||
}
|
||||
|
||||
void LLVMKotlinInitializeTargets() {
|
||||
#define INIT_LLVM_TARGET(TargetName) \
|
||||
LLVMInitialize##TargetName##TargetInfo();\
|
||||
LLVMInitialize##TargetName##Target();\
|
||||
LLVMInitialize##TargetName##TargetMC();
|
||||
#if KONAN_MACOS
|
||||
INIT_LLVM_TARGET(AArch64)
|
||||
INIT_LLVM_TARGET(ARM)
|
||||
INIT_LLVM_TARGET(Mips)
|
||||
INIT_LLVM_TARGET(X86)
|
||||
INIT_LLVM_TARGET(WebAssembly)
|
||||
#elif KONAN_LINUX
|
||||
#elif KONAN_WINDOWS
|
||||
#endif
|
||||
|
||||
#undef INIT_LLVM_TARGET
|
||||
}
|
||||
@@ -74,8 +74,9 @@ void LLVMAddInstrProfPass(LLVMPassManagerRef passManagerRef, const char* outputF
|
||||
|
||||
LLVMTargetLibraryInfoRef LLVMGetTargetLibraryInfo(LLVMModuleRef moduleRef);
|
||||
|
||||
void LLVMKotlinInitializeTargets();
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
|
||||
# endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user