mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
[K/N] Fix windows dynamic tests for LLD
Adjust compilation and linking flags to workaround absence of direct DLL linkage in LLD.
This commit is contained in:
@@ -327,6 +327,9 @@ Task dynamicTest(String name, Closure<KonanDynamicTest> configureClosure) {
|
||||
baseDir "$testOutputLocal/$name"
|
||||
extraOpts task.flags
|
||||
extraOpts project.globalTestArgs
|
||||
if (targetName == "mingw_x64" || targetName == "mingw_x86") {
|
||||
extraOpts "-linker-option", "-Wl,--out-implib,$testOutputLocal/$name/$targetName/${name}.dll.a"
|
||||
}
|
||||
}
|
||||
}
|
||||
def buildTask = UtilsKt.findKonanBuildTask(project, name, target)
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.gradle.process.ExecSpec
|
||||
import org.jetbrains.kotlin.konan.exec.Command
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.konan.target.Family
|
||||
import org.jetbrains.kotlin.konan.target.LinkerOutputKind
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
@@ -505,11 +507,18 @@ open class KonanDynamicTest : KonanStandaloneTest() {
|
||||
execResult.assertNormalExitValue()
|
||||
|
||||
val linker = project.platformManager.platform(project.testTarget).linker
|
||||
val linkerArgs = when (project.testTarget.family) {
|
||||
// rpath is meaningless on Windows (and isn't supported by LLD).
|
||||
// --allow-multiple-definition is needed because finalLinkCommands statically links a lot of MinGW-specific libraries,
|
||||
// that are already included in DLL produced by Kotlin/Native.
|
||||
Family.MINGW -> listOf("-L", artifactsDir, "-Wl,--allow-multiple-definition")
|
||||
else -> listOf("-L", artifactsDir, "-rpath", artifactsDir)
|
||||
}
|
||||
val commands = linker.finalLinkCommands(
|
||||
objectFiles = listOf("${this@KonanDynamicTest.executable}.o"),
|
||||
executable = executable,
|
||||
libraries = listOf("-l$name"),
|
||||
linkerArgs = listOf("-L", artifactsDir, "-rpath", artifactsDir),
|
||||
linkerArgs = linkerArgs,
|
||||
optimize = isOpt,
|
||||
debug = isDebug,
|
||||
kind = LinkerOutputKind.EXECUTABLE,
|
||||
|
||||
Reference in New Issue
Block a user