A little more konanc.
This commit is contained in:
committed by
alexander-gorshenev
parent
093409a1af
commit
6a6424f462
+31
-16
@@ -22,7 +22,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
convention.plugins.clangFlags = new ClangFlags(isLinux(), "$llvmDir")
|
||||
convention.plugins.clangFlags = new ClangFlags(new PlatformInfo(), "$llvmDir")
|
||||
ext.clangPath = ["$llvmDir/bin"]
|
||||
ext.clangArgs = []
|
||||
final String binDir
|
||||
@@ -43,6 +43,7 @@ allprojects {
|
||||
ext.jvmArgs = ["-ea"]
|
||||
|
||||
ext.clangLinkArgs = libLink()
|
||||
ext.clangOptArgs = optArgs()
|
||||
|
||||
convention.plugins.execClang = new org.jetbrains.kotlin.ExecClang(project)
|
||||
|
||||
@@ -68,32 +69,44 @@ allprojects {
|
||||
|
||||
class ClangFlags {
|
||||
|
||||
protected Boolean isLinux
|
||||
protected PlatformInfo platform
|
||||
protected String llvmDir
|
||||
|
||||
ClangFlags(linux, llvm) {
|
||||
isLinux = linux
|
||||
private List<String> linkCppAbi, linkPlatform, optArgs
|
||||
|
||||
ClangFlags(platformInfo, llvm) {
|
||||
platform = platformInfo
|
||||
llvmDir = llvm
|
||||
|
||||
if (platform.isLinux()) {
|
||||
linkCppAbi= ["-Wl,-Bstatic", "-lc++abi", "-Wl,-Bdynamic"]
|
||||
linkPlatform= ["-ldl", "-lpthread", "-lm", "-rdynamic"]
|
||||
optArgs = ["-O3"]
|
||||
} else if (platform.isMac()) {
|
||||
// Life is hard. MacOS linker is harder.
|
||||
// This is how we force the linker to link statically.
|
||||
linkCppAbi= ["${llvmDir}/lib/libc++abi.a"]
|
||||
linkPlatform= []
|
||||
optArgs = ["-O3", "-flto", "-Wl,-dead_strip"]
|
||||
} else {
|
||||
throw unsupportedPlatformException()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<String> linkCppAbi() {
|
||||
if (isLinux) {
|
||||
return ["-Wl,-Bstatic", "-lc++abi", "-Wl,-Bdynamic"]
|
||||
} else {
|
||||
// Life is hard. MacOS linker is harder.
|
||||
// This is how we force the linker to link statically.
|
||||
return ["${llvmDir}/lib/libc++abi.a"]
|
||||
}
|
||||
return linkCppAbi
|
||||
}
|
||||
|
||||
public List<String> linkPlatform() {
|
||||
if (isLinux) {
|
||||
return ["-ldl", "-lpthread", "-lm", "-rdynamic"]
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
return linkPlatform
|
||||
}
|
||||
|
||||
public List<String> optArgs() {
|
||||
return optArgs
|
||||
}
|
||||
|
||||
|
||||
public List<String> libLink() {
|
||||
def libs = []
|
||||
libs.addAll(linkPlatform())
|
||||
@@ -160,7 +173,9 @@ task dist_compiler(type: Copy) {
|
||||
include('kotlinc-native')
|
||||
|
||||
def allClangArgs = "${clangArgs.join(' ')} ${clangLinkArgs.join(' ')}"
|
||||
|
||||
filter { line -> line.replaceAll("FILTER_CLANG_PLATFORM_ARGS", allClangArgs) }
|
||||
filter { line -> line.replaceAll("FILTER_CLANG_PLATFORM_OPT", "${clangOptArgs.join(' ')}") }
|
||||
filter { line -> line.replaceAll("FILTER_CLANG_BIN_PATH", "${project.llvmDir}/bin") }
|
||||
|
||||
into('bin')
|
||||
|
||||
+3
-3
@@ -55,9 +55,6 @@ while [ $# -gt 0 ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
# TODO: support -opt on Linux hosts as well.
|
||||
clang_opt_args=("-O3" "-flto" "-Wl,-dead_strip")
|
||||
|
||||
[ -n "$KONAN_COMPILER" ] || KONAN_COMPILER=org.jetbrains.kotlin.cli.bc.K2NativeKt
|
||||
[ -n "$JAVACMD" ] || JAVACMD=java
|
||||
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M"
|
||||
@@ -132,8 +129,11 @@ START="${KONAN_HOME}/lib/start.kt.bc"
|
||||
# We filter this script during installation
|
||||
# substituting the proper platform dependent arguments here.
|
||||
CLANG_PLATFORM_ARGS="FILTER_CLANG_PLATFORM_ARGS"
|
||||
CLANG_PLATFORM_OPT="FILTER_CLANG_PLATFORM_OPT"
|
||||
CLANG_BIN_PATH="FILTER_CLANG_BIN_PATH"
|
||||
|
||||
clang_opt_args=("$CLANG_PLATFORM_OPT")
|
||||
|
||||
CLANG="$CLANG_BIN_PATH/clang"
|
||||
|
||||
# TODO: Compilation without stdlib.kt.bc doesn't work because 'start' requires stdlib, for example.
|
||||
|
||||
Reference in New Issue
Block a user