Changed link stage from using "clang++" to "clang -lc++abi".
This commit is contained in:
committed by
alexander-gorshenev
parent
44d07ef829
commit
f79b0bdf6a
@@ -104,41 +104,44 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
return project.isLinux()
|
return project.isLinux()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: stop copy-pasting
|
protected List<String> linkCppAbi() {
|
||||||
protected String linkDl() {
|
if (linux()) {
|
||||||
|
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 ["${project.llvmDir}/lib/libc++abi.a"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected List<String> linkPlatform() {
|
||||||
if (linux()) {
|
if (linux()) {
|
||||||
return "-ldl"
|
return ["-ldl", "-lpthread", "-lm", "-rdynamic"]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return ""
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String linkM() {
|
protected List<String> libLink() {
|
||||||
if (linux()) {
|
def libs = []
|
||||||
return "-lm"
|
libs.addAll(linkPlatform())
|
||||||
}
|
libs.addAll(linkCppAbi())
|
||||||
else {
|
return libs
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String rdynamic() {
|
|
||||||
if (linux()) {
|
|
||||||
return "-rdynamic"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnitKonanTest extends KonanTest {
|
class UnitKonanTest extends KonanTest {
|
||||||
void compileTest(File sourceS, File runtimeS, File stdlibKtBc, File exe) {
|
void compileTest(File sourceS, File runtimeS, File stdlibKtBc, File exe) {
|
||||||
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
||||||
project.execClang {
|
project.execClang {
|
||||||
commandLine "clang++", runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath,
|
executable "clang"
|
||||||
"-o", exe.absolutePath, linkDl(), linkM(), rdynamic(), '-xc', testC, mainC
|
def argList = []
|
||||||
|
argList.addAll([ runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath,
|
||||||
|
"-o", exe.absolutePath, testC, mainC ])
|
||||||
|
argList.addAll(libLink())
|
||||||
|
args argList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,8 +149,12 @@ class UnitKonanTest extends KonanTest {
|
|||||||
class RunKonanTest extends KonanTest {
|
class RunKonanTest extends KonanTest {
|
||||||
void compileTest(File sourceS, File runtimeS, File libraryPath, File exe) {
|
void compileTest(File sourceS, File runtimeS, File libraryPath, File exe) {
|
||||||
project.execClang {
|
project.execClang {
|
||||||
commandLine "clang++", launcherBc.absolutePath, startKtBc.absolutePath, runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath,
|
executable "clang"
|
||||||
"-o", exe.absolutePath, linkDl(), linkM(), rdynamic(), '-xc'
|
def argList = []
|
||||||
|
argList.addAll([ launcherBc.absolutePath, startKtBc.absolutePath,
|
||||||
|
runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath, "-o", exe.absolutePath ])
|
||||||
|
argList.addAll(libLink())
|
||||||
|
args argList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -202,8 +209,12 @@ class LinkKonanTest extends KonanTest {
|
|||||||
void compileTest(File sourceS, File runtimeS, File stdlibKtBc, File exe) {
|
void compileTest(File sourceS, File runtimeS, File stdlibKtBc, File exe) {
|
||||||
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
||||||
project.execClang {
|
project.execClang {
|
||||||
commandLine "clang++", runtimeS.absolutePath, stdlibKtBc.absolutePath, sourceS.absolutePath,
|
executable "clang"
|
||||||
"-o", exe.absolutePath, linkDl(), rdynamic(), '-xc', testC, mainC
|
def argList = []
|
||||||
|
argList.addAll([ runtimeS.absolutePath, stdlibKtBc.absolutePath,
|
||||||
|
sourceS.absolutePath, "-o", exe.absolutePath, testC, mainC ])
|
||||||
|
argList.addAll(libLink())
|
||||||
|
args argList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -29,7 +29,8 @@ allprojects {
|
|||||||
binDir = "$gccToolchainDir/$gnuTriplet/bin"
|
binDir = "$gccToolchainDir/$gnuTriplet/bin"
|
||||||
ext.clangArgs.addAll([
|
ext.clangArgs.addAll([
|
||||||
"--sysroot=$gccToolchainDir/$gnuTriplet/sysroot",
|
"--sysroot=$gccToolchainDir/$gnuTriplet/sysroot",
|
||||||
"--gcc-toolchain=$gccToolchainDir"
|
"--gcc-toolchain=$gccToolchainDir",
|
||||||
|
"-L$llvmDir/lib"
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
binDir = "$sysrootDir/usr/bin"
|
binDir = "$sysrootDir/usr/bin"
|
||||||
|
|||||||
Reference in New Issue
Block a user