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.clangPath = ["$llvmDir/bin"]
|
||||||
ext.clangArgs = []
|
ext.clangArgs = []
|
||||||
final String binDir
|
final String binDir
|
||||||
@@ -43,6 +43,7 @@ allprojects {
|
|||||||
ext.jvmArgs = ["-ea"]
|
ext.jvmArgs = ["-ea"]
|
||||||
|
|
||||||
ext.clangLinkArgs = libLink()
|
ext.clangLinkArgs = libLink()
|
||||||
|
ext.clangOptArgs = optArgs()
|
||||||
|
|
||||||
convention.plugins.execClang = new org.jetbrains.kotlin.ExecClang(project)
|
convention.plugins.execClang = new org.jetbrains.kotlin.ExecClang(project)
|
||||||
|
|
||||||
@@ -68,32 +69,44 @@ allprojects {
|
|||||||
|
|
||||||
class ClangFlags {
|
class ClangFlags {
|
||||||
|
|
||||||
protected Boolean isLinux
|
protected PlatformInfo platform
|
||||||
protected String llvmDir
|
protected String llvmDir
|
||||||
|
|
||||||
ClangFlags(linux, llvm) {
|
private List<String> linkCppAbi, linkPlatform, optArgs
|
||||||
isLinux = linux
|
|
||||||
|
ClangFlags(platformInfo, llvm) {
|
||||||
|
platform = platformInfo
|
||||||
llvmDir = llvm
|
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() {
|
public List<String> linkCppAbi() {
|
||||||
if (isLinux) {
|
return linkCppAbi
|
||||||
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"]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> linkPlatform() {
|
public List<String> linkPlatform() {
|
||||||
if (isLinux) {
|
return linkPlatform
|
||||||
return ["-ldl", "-lpthread", "-lm", "-rdynamic"]
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> optArgs() {
|
||||||
|
return optArgs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<String> libLink() {
|
public List<String> libLink() {
|
||||||
def libs = []
|
def libs = []
|
||||||
libs.addAll(linkPlatform())
|
libs.addAll(linkPlatform())
|
||||||
@@ -160,7 +173,9 @@ task dist_compiler(type: Copy) {
|
|||||||
include('kotlinc-native')
|
include('kotlinc-native')
|
||||||
|
|
||||||
def allClangArgs = "${clangArgs.join(' ')} ${clangLinkArgs.join(' ')}"
|
def allClangArgs = "${clangArgs.join(' ')} ${clangLinkArgs.join(' ')}"
|
||||||
|
|
||||||
filter { line -> line.replaceAll("FILTER_CLANG_PLATFORM_ARGS", allClangArgs) }
|
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") }
|
filter { line -> line.replaceAll("FILTER_CLANG_BIN_PATH", "${project.llvmDir}/bin") }
|
||||||
|
|
||||||
into('bin')
|
into('bin')
|
||||||
|
|||||||
+3
-3
@@ -55,9 +55,6 @@ while [ $# -gt 0 ]; do
|
|||||||
esac
|
esac
|
||||||
done
|
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 "$KONAN_COMPILER" ] || KONAN_COMPILER=org.jetbrains.kotlin.cli.bc.K2NativeKt
|
||||||
[ -n "$JAVACMD" ] || JAVACMD=java
|
[ -n "$JAVACMD" ] || JAVACMD=java
|
||||||
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M"
|
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms32M"
|
||||||
@@ -132,8 +129,11 @@ START="${KONAN_HOME}/lib/start.kt.bc"
|
|||||||
# We filter this script during installation
|
# We filter this script during installation
|
||||||
# substituting the proper platform dependent arguments here.
|
# substituting the proper platform dependent arguments here.
|
||||||
CLANG_PLATFORM_ARGS="FILTER_CLANG_PLATFORM_ARGS"
|
CLANG_PLATFORM_ARGS="FILTER_CLANG_PLATFORM_ARGS"
|
||||||
|
CLANG_PLATFORM_OPT="FILTER_CLANG_PLATFORM_OPT"
|
||||||
CLANG_BIN_PATH="FILTER_CLANG_BIN_PATH"
|
CLANG_BIN_PATH="FILTER_CLANG_BIN_PATH"
|
||||||
|
|
||||||
|
clang_opt_args=("$CLANG_PLATFORM_OPT")
|
||||||
|
|
||||||
CLANG="$CLANG_BIN_PATH/clang"
|
CLANG="$CLANG_BIN_PATH/clang"
|
||||||
|
|
||||||
# TODO: Compilation without stdlib.kt.bc doesn't work because 'start' requires stdlib, for example.
|
# TODO: Compilation without stdlib.kt.bc doesn't work because 'start' requires stdlib, for example.
|
||||||
|
|||||||
Reference in New Issue
Block a user