linux build fix: static/dynamic and libraries ordering
This commit is contained in:
@@ -66,9 +66,12 @@ String[] linkerOpts1() {
|
|||||||
'-lLLVMSupport']
|
'-lLLVMSupport']
|
||||||
List<String> ldflags = new ArrayList<>()
|
List<String> ldflags = new ArrayList<>()
|
||||||
if (System.properties['os.name'].startsWith("Linux"))
|
if (System.properties['os.name'].startsWith("Linux"))
|
||||||
ldflags.addAll(["-L$llvmDir/lib", "-lc++", "-Wl,-whole-archive"]
|
ldflags.addAll(["-L$llvmDir/lib",
|
||||||
|
"-Wl,-Bstatic", "-Wl,--whole-archive"]
|
||||||
+ libs
|
+ libs
|
||||||
+ ["-Wl,-no-whole-archieve", "-L$libffiDir/lib -lffi"])
|
+ ["-Wl,--no-whole-archive", "-Wl,-Bdynamic",
|
||||||
|
"-L$libffiDir/lib -lffi",
|
||||||
|
"-lrt", "-ldl","-lpthread", "-lz", "-lm"])
|
||||||
else
|
else
|
||||||
ldflags.addAll(["-L$llvmDir/lib", "-lc++"]
|
ldflags.addAll(["-L$llvmDir/lib", "-lc++"]
|
||||||
+ libs
|
+ libs
|
||||||
@@ -81,7 +84,7 @@ String[] linkerOpts1() {
|
|||||||
kotlinNativeInterop {
|
kotlinNativeInterop {
|
||||||
llvm {
|
llvm {
|
||||||
defFile 'llvm.def'
|
defFile 'llvm.def'
|
||||||
compilerOpts "-I$llvmDir/include"
|
compilerOpts "-fPIC", "-I$llvmDir/include"
|
||||||
linkerOpts linkerOpts1()
|
linkerOpts linkerOpts1()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +131,7 @@ task run(type: JavaExec) {
|
|||||||
|
|
||||||
args '-output', "$buildDir/out.bc"
|
args '-output', "$buildDir/out.bc"
|
||||||
|
|
||||||
jvmArgs '-ea', "-Djava.library.path=${llvmDir}/lib:${project.buildDir}/nativelibs"
|
jvmArgs '-ea', "-Djava.library.path=${project.buildDir}/nativelibs"
|
||||||
|
|
||||||
dependsOn ':runtime:build'
|
dependsOn ':runtime:build'
|
||||||
|
|
||||||
@@ -136,7 +139,6 @@ task run(type: JavaExec) {
|
|||||||
args '-runtime', project(':runtime').build.outputs.files.singleFile
|
args '-runtime', project(':runtime').build.outputs.files.singleFile
|
||||||
}
|
}
|
||||||
environment 'LD_LIBRARY_PATH' : "${llvmDir}/lib:${project.buildDir}/nativelibs"
|
environment 'LD_LIBRARY_PATH' : "${llvmDir}/lib:${project.buildDir}/nativelibs"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user