Reconfigure interop with LLVM
Use more strict linking. Also remove unused components.
This commit is contained in:
committed by
SvyatoslavScherbina
parent
23f1df015d
commit
d7adbfd221
+3
-3
@@ -413,9 +413,9 @@ private fun processLib(konanHome: String,
|
||||
|
||||
val outLib = File(nativeLibsDir, System.mapLibraryName(libName))
|
||||
|
||||
val linkerCmd = arrayOf("$llvmInstallPath/bin/$linker", *linkerOpts, outOFile.absolutePath, "-shared",
|
||||
"-o", outLib.absolutePath,
|
||||
"-Wl,-flat_namespace,-undefined,dynamic_lookup")
|
||||
val linkerCmd = arrayOf("$llvmInstallPath/bin/$linker",
|
||||
outOFile.absolutePath, "-shared", "-o", outLib.absolutePath,
|
||||
*linkerOpts)
|
||||
|
||||
runCmd(linkerCmd, workDir, verbose)
|
||||
|
||||
|
||||
@@ -91,62 +91,12 @@ task renamePackage(type: Copy) {
|
||||
outputs.files('build/renamed')
|
||||
}
|
||||
|
||||
List<String> llvmLinkerOpts() {
|
||||
// TODO: cannot use llvm-config because it can be inaccessible during project configuration
|
||||
final List<String> libs = [
|
||||
'-lLLVMX86Disassembler',
|
||||
'-lLLVMX86AsmParser',
|
||||
'-lLLVMX86CodeGen',
|
||||
'-lLLVMSelectionDAG',
|
||||
'-lLLVMAsmPrinter',
|
||||
'-lLLVMX86Desc',
|
||||
'-lLLVMMCDisassembler',
|
||||
'-lLLVMX86Info',
|
||||
'-lLLVMX86AsmPrinter',
|
||||
'-lLLVMX86Utils',
|
||||
'-lLLVMInterpreter',
|
||||
'-lLLVMCodeGen',
|
||||
'-lLLVMScalarOpts',
|
||||
'-lLLVMInstCombine',
|
||||
'-lLLVMInstrumentation',
|
||||
'-lLLVMProfileData',
|
||||
'-lLLVMTransformUtils',
|
||||
'-lLLVMBitWriter',
|
||||
'-lLLVMExecutionEngine',
|
||||
'-lLLVMTarget',
|
||||
'-lLLVMAnalysis',
|
||||
'-lLLVMRuntimeDyld',
|
||||
'-lLLVMObject',
|
||||
'-lLLVMMCParser',
|
||||
'-lLLVMBitReader',
|
||||
'-lLLVMMC',
|
||||
'-lLLVMCore',
|
||||
'-lLLVMSupport',
|
||||
'-lLLVMDebugInfoCodeView',
|
||||
'-lLLVMLinker',
|
||||
"-ldebugInfo"
|
||||
]
|
||||
|
||||
final List<String> res = ["-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static"]
|
||||
|
||||
if (isLinux()) {
|
||||
res.addAll(["-Wl,-Bstatic", "-Wl,--whole-archive"]
|
||||
+ libs
|
||||
+ ["-Wl,--no-whole-archive", "-Wl,-Bdynamic"])
|
||||
} else {
|
||||
res.addAll(libs)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
kotlinNativeInterop {
|
||||
llvm {
|
||||
dependsOn ":llvmDebugInfoC:debugInfoStaticLibrary"
|
||||
defFile 'llvm.def'
|
||||
compilerOpts "-fPIC", "-I$llvmDir/include", "-I${project(':llvmDebugInfoC').projectDir}/src/main/include"
|
||||
linkerOpts llvmLinkerOpts()
|
||||
linkerOpts "-L$llvmDir/lib", "-L${project(':llvmDebugInfoC').buildDir}/libs/debugInfo/static"
|
||||
}
|
||||
|
||||
hash { // TODO: copy-pasted from ':common:compileHash'
|
||||
|
||||
+11
-2
@@ -1,4 +1,4 @@
|
||||
headers = llvm-c/Core.h llvm-c/ExecutionEngine.h llvm-c/Target.h llvm-c/Analysis.h llvm-c/BitWriter.h \
|
||||
headers = llvm-c/Core.h llvm-c/Target.h llvm-c/Analysis.h llvm-c/BitWriter.h \
|
||||
llvm-c/BitReader.h llvm-c/Linker.h DebugInfoC.h
|
||||
|
||||
headerFilter = llvm-c/* DebugInfoC.h
|
||||
@@ -15,7 +15,12 @@ linkerOpts = -fPIC -fvisibility-inlines-hidden \
|
||||
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers \
|
||||
-pedantic -Wno-long-long -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor \
|
||||
-std=c++11 \
|
||||
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
|
||||
-DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS \
|
||||
-ldebugInfo -lLLVMTarget -lLLVMMC -lLLVMLinker -lLLVMTransformUtils -lLLVMBitWriter \
|
||||
-lLLVMBitReader -lLLVMAnalysis -lLLVMProfileData -lLLVMCore -lLLVMSupport
|
||||
|
||||
# ./llvm-config --libs analysis bitreader bitwriter core linker target
|
||||
|
||||
|
||||
linkerOpts.osx = \
|
||||
-Wl,-search_paths_first -Wl,-headerpad_max_install_names \
|
||||
@@ -25,4 +30,8 @@ linkerOpts.linux=\
|
||||
-Wl,-z,noexecstack \
|
||||
-lrt -ldl -lpthread -lz -lm
|
||||
|
||||
excludedFunctions = LLVMInitializeAllAsmParsers LLVMInitializeAllAsmPrinters LLVMInitializeAllDisassemblers \
|
||||
LLVMInitializeAllTargetInfos LLVMInitializeAllTargetMCs LLVMInitializeAllTargets LLVMInitializeNativeTarget \
|
||||
LLVMInitializeNativeAsmParser LLVMInitializeNativeAsmPrinter LLVMInitializeNativeDisassembler
|
||||
|
||||
strictEnums = LLVMIntPredicate LLVMOpcode LLVMDLLStorageClass LLVMCallConv LLVMThreadLocalMode LLVMAtomicOrdering
|
||||
Reference in New Issue
Block a user