diff --git a/InteropExample/build.gradle b/InteropExample/build.gradle index 86dbc1c0d11..d66de1f9c51 100644 --- a/InteropExample/build.gradle +++ b/InteropExample/build.gradle @@ -20,7 +20,7 @@ kotlinNativeInterop { llvm { defFile '../backend.native/llvm.def' compilerOpts "-I$llvmDir/include" - linkerOpts "-L$llvmDir/lib" + linkerOpts "-L$llvmDir/lib", "-B$sysrootDir/usr/bin" } } diff --git a/backend.native/build.gradle b/backend.native/build.gradle index 799227484ce..300b8294b9d 100644 --- a/backend.native/build.gradle +++ b/backend.native/build.gradle @@ -96,19 +96,20 @@ String[] linkerOpts1() { + ["-L$libffiDir/lib", "-lffi"]) ArrayList strldflags = new ArrayList<>() ldflags.forEach{strldflags.add(it.toString())} + strldflags.add("-B$sysrootDir/usr/bin".toString()) return strldflags.toArray(new String[0]) } kotlinNativeInterop { llvm { defFile 'llvm.def' - compilerOpts "-fPIC", "-I$llvmDir/include" + compilerOpts "-fPIC", "-I$llvmDir/include", "-B$sysrootDir/usr/bin" linkerOpts linkerOpts1() } hash { // TODO: copy-pasted from ':common:compileHash' compilerOpts '-fPIC' - linkerOpts '-fPIC' + linkerOpts '-fPIC', "-B$sysrootDir/usr/bin" linker 'clang++' linkOutputs ':common:compileHash' diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index 338e6db95cb..ccdfa495086 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -101,7 +101,7 @@ 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}", linkDl(), + commandLine "${llvmC}", "-B${project.sysrootDir}/usr/bin", "${testC}", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(), "-o", "${exe.absolutePath}" args llvmCAdditionalArgs @@ -112,7 +112,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}", linkDl(), + commandLine "${llvmC}", "-DRUN_TEST", "-B${project.sysrootDir}/usr/bin", "${runtimeS.absolutePath}", "${sourceS.absolutePath}", "${mainC}", linkDl(), "-o", "${exe.absolutePath}" args llvmCAdditionalArgs diff --git a/build.gradle b/build.gradle index c20a8f434f0..4aebce93210 100644 --- a/build.gradle +++ b/build.gradle @@ -16,11 +16,12 @@ allprojects { toolChains { clang(Clang) { path "$llvmDir/bin" - eachPlatform { // TODO: will not work when cross-compiling [cCompiler, cppCompiler, linker].each { - it.withArguments { it << "--sysroot=$sysrootDir" } + it.withArguments { it << "--sysroot=$sysrootDir"} + it.withArguments { it << "-B$sysrootDir/usr/bin"} } + } } }