build: fix linking tests on Linux
runtime now requires "-lm"
This commit is contained in:
committed by
SvyatoslavScherbina
parent
66bd698270
commit
edf3708515
@@ -86,6 +86,7 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
return project.isLinux()
|
return project.isLinux()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: stop copy-pasting
|
||||||
protected String linkDl() {
|
protected String linkDl() {
|
||||||
if (linux()) {
|
if (linux()) {
|
||||||
return "-ldl"
|
return "-ldl"
|
||||||
@@ -95,6 +96,15 @@ abstract class KonanTest extends DefaultTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String linkM() {
|
||||||
|
if (linux()) {
|
||||||
|
return "-lm"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String rdynamic() {
|
protected String rdynamic() {
|
||||||
if (linux()) {
|
if (linux()) {
|
||||||
return "-rdynamic"
|
return "-rdynamic"
|
||||||
@@ -110,7 +120,7 @@ class UnitKonanTest extends KonanTest {
|
|||||||
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
|
||||||
project.execClang {
|
project.execClang {
|
||||||
commandLine "clang", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
commandLine "clang", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
||||||
"-o", "${exe.absolutePath}", linkDl(), rdynamic()
|
"-o", "${exe.absolutePath}", linkDl(), linkM(), rdynamic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,7 +129,7 @@ class RunKonanTest extends KonanTest {
|
|||||||
void compileTest(File sourceS, File runtimeS, File exe) {
|
void compileTest(File sourceS, File runtimeS, File exe) {
|
||||||
project.execClang {
|
project.execClang {
|
||||||
commandLine "clang", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
commandLine "clang", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
|
||||||
"-o", "${exe.absolutePath}", linkDl(), rdynamic()
|
"-o", "${exe.absolutePath}", linkDl(), linkM(), rdynamic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user