From ebc4cf7f96d07a5c2bbfaf51895ca213ed288f72 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Wed, 31 May 2023 04:53:58 +0000 Subject: [PATCH] [K/N] Normalize klib paths for KonanLibraryImpl ^KT-58979 Fixed Merge-request: KT-MR-10372 Merged-by: Vladimir Sukharev --- .../basic-utils/src/main/kotlin/KonanHomeProvider.kt | 6 ++++-- .../jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kotlin-native/utilities/basic-utils/src/main/kotlin/KonanHomeProvider.kt b/kotlin-native/utilities/basic-utils/src/main/kotlin/KonanHomeProvider.kt index 6ac5687279b..45c803bb714 100644 --- a/kotlin-native/utilities/basic-utils/src/main/kotlin/KonanHomeProvider.kt +++ b/kotlin-native/utilities/basic-utils/src/main/kotlin/KonanHomeProvider.kt @@ -14,7 +14,7 @@ object KonanHomeProvider { /** * Determines a path to the current Kotlin/Native distribution. * - * - If the system property "konan.home" is set, the method returns its value. + * - If the system property "konan.home" is set, the method returns its normalized value. * - Otherwise, it determines a path to a jar containing this class. If this path corresponds to the jar path * inside a distribution, the method calculates the path to the distribution on the basis of this jar path. * Otherwise an IllegalStateException is thrown. @@ -22,7 +22,9 @@ object KonanHomeProvider { fun determineKonanHome(): String { val propertyValue = kotlinNativeHome return if (propertyValue != null) { - File(propertyValue).absolutePath + // KT-58979: KonanLibraryImpl needs normalized klib paths to correctly provide symbols from resolved klibs + // For extra safety, path to "konan.home" is also normalized here + Paths.get(File(propertyValue).absolutePath).normalize().toString() } else { val jarPath = PathUtil.getResourcePathForClass(this::class.java) diff --git a/native/utils/src/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt b/native/utils/src/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt index bd14ca1528f..2ce3df4aaab 100644 --- a/native/utils/src/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt +++ b/native/utils/src/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt @@ -19,13 +19,13 @@ package org.jetbrains.kotlin.konan.library.impl import org.jetbrains.kotlin.konan.file.File import org.jetbrains.kotlin.konan.library.* import org.jetbrains.kotlin.konan.properties.Properties -import org.jetbrains.kotlin.konan.properties.loadProperties import org.jetbrains.kotlin.konan.properties.propertyList import org.jetbrains.kotlin.konan.target.KonanTarget import org.jetbrains.kotlin.konan.util.defaultTargetSubstitutions import org.jetbrains.kotlin.konan.util.substitute import org.jetbrains.kotlin.library.* import org.jetbrains.kotlin.library.impl.* +import java.nio.file.Paths open class TargetedLibraryImpl( private val access: TargetedLibraryAccess, @@ -81,11 +81,13 @@ class KonanLibraryImpl( fun createKonanLibrary( - libraryFile: File, + libraryFilePossiblyDenormalized: File, component: String, target: KonanTarget? = null, isDefault: Boolean = false ): KonanLibrary { + // KT-58979: The following access classes need normalized klib path to correctly provide symbols from resolved klibs + val libraryFile = Paths.get(libraryFilePossiblyDenormalized.absolutePath).normalize().File() val baseAccess = BaseLibraryAccess(libraryFile, component) val targetedAccess = TargetedLibraryAccess(libraryFile, component, target) val metadataAccess = MetadataLibraryAccess(libraryFile, component)