linux run test fix (except RTTI linking problems)

This commit is contained in:
Vasily Levchenko
2016-11-03 06:19:26 +03:00
parent 1f90f32397
commit 09fb11fbc9
2 changed files with 24 additions and 3 deletions
+20 -2
View File
@@ -40,9 +40,14 @@ abstract class KonanTest extends DefaultTask {
"-headers", project.project(':runtime').file('src/main/kotlin'),
"${sourceKt.absolutePath}"
<<<<<<< Updated upstream
String libraryPath = "${project.llvmDir}/lib:${backendNative.buildDir.canonicalPath}/nativelibs"
environment 'LD_LIBRARY_PATH' : libraryPath
environment 'DYLD_LIBRARY_PATH' : libraryPath
=======
jvmArgs "-Djava.library.path=${backendNative.buildDir.canonicalPath}/nativelibs"
environment LD_LIBRARY_PATH : "${project.parent.llvmDir}/lib"
>>>>>>> Stashed changes
}
return sourceBc
}
@@ -83,13 +88,26 @@ abstract class KonanTest extends DefaultTask {
private String llvmTool(String tool) {
return "${project.llvmDir}/bin/${tool}"
}
private linux() {
return System.properties['os.name'].startsWith('Linux')
}
protected String linkDl() {
if (linux()) {
return "-ldl"
}
else {
return ""
}
}
}
class UnitKonanTest extends KonanTest {
void compileTest(File sourceS, File runtimeS, File exe) {
def testC = sourceS.absolutePath.replace(".kt.S", "-test.c")
project.exec {
commandLine "${llvmC}", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
commandLine "${llvmC}", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
"-o", "${exe.absolutePath}"
args llvmCAdditionalArgs
@@ -100,7 +118,7 @@ class UnitKonanTest extends KonanTest {
class RunKonanTest extends KonanTest {
void compileTest(File sourceS, File runtimeS, File exe) {
project.exec {
commandLine "${llvmC}", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}",
commandLine "${llvmC}", "-DRUN_TEST", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(),
"-o", "${exe.absolutePath}"
args llvmCAdditionalArgs
+4 -1
View File
@@ -1,3 +1,6 @@
#ifdef __linux__
# define _GNU_SOURCE
#endif
#include <dlfcn.h>
#include <stdlib.h>
#include <stdio.h>
@@ -10,7 +13,7 @@ extern int run_test();
void * resolve_symbol(char *name) {
/* here we can add here some magic to resolve symbols in kotlin native*/
return dlsym(RTLD_SELF, name);
return dlsym(RTLD_DEFAULT, name);
}