diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt index 2c44887afed..92714f686d0 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt @@ -48,6 +48,7 @@ import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport import org.jetbrains.kotlin.backend.konan.llvm.coverage.CoverageManager import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor +import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.konan.library.KonanLibraryLayout @@ -57,7 +58,7 @@ import org.jetbrains.kotlin.library.SerializedIrModule * Offset for synthetic elements created by lowerings and not attributable to other places in the source code. */ -internal class SpecialDeclarationsFactory(val context: Context) : KotlinMangler by KonanMangler { +internal class SpecialDeclarationsFactory(val context: Context) : KotlinMangler by KonanManglerForBE { private val enumSpecialDeclarationsFactory by lazy { EnumSpecialDeclarationsFactory(context) } private val outerThisFields = mutableMapOf() private val bridgesDescriptors = mutableMapOf, IrSimpleFunction>() @@ -206,6 +207,8 @@ internal class Context(config: KonanConfig) : KonanBackendContext(config) { lateinit var cAdapterGenerator: CAdapterGenerator + lateinit var expectDescriptorToSymbol: MutableMap + override val builtIns: KonanBuiltIns by lazy(PUBLICATION) { moduleDescriptor.builtIns as KonanBuiltIns } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt index 96dffe4060c..95069ffd1d9 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt @@ -17,10 +17,12 @@ import org.jetbrains.kotlin.backend.konan.serialization.* import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.languageVersionSettings +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.konan.isKonanStdlib import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment +import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator import org.jetbrains.kotlin.ir.util.SymbolTable import org.jetbrains.kotlin.ir.util.addChild @@ -165,7 +167,6 @@ internal val psiToIrPhase = konanUnitPhase( // Note: using [llvmModuleSpecification] since this phase produces IR for generating single LLVM module. val exportedDependencies = (getExportedDependencies() + modulesWithoutDCE).distinct() - val deserializer = KonanIrLinker( moduleDescriptor, this as LoggingContext, @@ -195,6 +196,8 @@ internal val psiToIrPhase = konanUnitPhase( dependenciesCount = dependencies.size } + deserializer.initializeExpectActualLinker() + val functionIrClassFactory = BuiltInFictitiousFunctionIrClassFactory( symbolTable, generatorContext.irBuiltIns, reflectionTypes) val irProviderForInteropStubs = IrProviderForInteropStubs() @@ -205,7 +208,11 @@ internal val psiToIrPhase = konanUnitPhase( ) val irProviders = listOf(irProviderForInteropStubs, functionIrClassFactory, deserializer, stubGenerator) stubGenerator.setIrProviders(irProviders) - val module = translator.generateModuleFragment(generatorContext, environment.getSourceFiles(), irProviders) + + expectDescriptorToSymbol = mutableMapOf() + val module = translator.generateModuleFragment(generatorContext, environment.getSourceFiles(), irProviders, expectDescriptorToSymbol) + + deserializer.finalizeExpectActualLinker() if (this.stdlibModule in modulesWithoutDCE) { functionIrClassFactory.buildAllClasses() @@ -247,12 +254,17 @@ internal val copyDefaultValuesToActualPhase = konanUnitPhase( internal val serializerPhase = konanUnitPhase( op = { + val mppKlibs = config.configuration.get(CommonConfigurationKeys.KLIB_MPP)?:false val descriptorTable = DescriptorTable.createDefault() - serializedIr = KonanIrModuleSerializer(this, irModule!!.irBuiltins, descriptorTable).serializedIrModule(irModule!!) + + serializedIr = KonanIrModuleSerializer( + this, irModule!!.irBuiltins, descriptorTable, expectDescriptorToSymbol, skipExpects = !mppKlibs + ).serializedIrModule(irModule!!) + val serializer = KlibMetadataMonolithicSerializer( this.config.configuration.languageVersionSettings, - config.configuration.get(CommonConfigurationKeys.METADATA_VERSION - )!!, descriptorTable) + config.configuration.get(CommonConfigurationKeys.METADATA_VERSION)!!, + descriptorTable, !mppKlibs) serializedMetadata = serializer.serializeModule(moduleDescriptor) }, name = "Serializer", @@ -464,4 +476,4 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) { disableUnless(ghaPhase, getBoolean(KonanConfigKeys.OPTIMIZATION)) disableUnless(verifyBitcodePhase, config.needCompilerVerification || getBoolean(KonanConfigKeys.VERIFY_BITCODE)) } -} \ No newline at end of file +} diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BinaryInterface.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BinaryInterface.kt index 101c7a9848b..912f4836f68 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BinaryInterface.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/BinaryInterface.kt @@ -29,7 +29,7 @@ import org.jetbrains.kotlin.library.uniqueName // TODO: revise the naming scheme to ensure it produces unique names. // TODO: do not serialize descriptors of non-exported declarations. -object KonanMangler : KotlinManglerImpl() { +abstract class AbstractKonanMangler : KotlinManglerImpl() { override val IrType.isInlined get() = this.isInlinedNative() @@ -62,18 +62,19 @@ object KonanMangler : KotlinManglerImpl() { return false } - override val IrFunction.argsPart get() = this.valueParameters.map { + override fun IrFunction.valueParamsPart(typeParameterNamer: (IrTypeParameter) -> String): String { + return this.valueParameters.map { - // TODO: there are clashes originating from ObjectiveC interop. - // kotlinx.cinterop.ObjCClassOf.create(format: kotlin.String): T defined in platform.Foundation in file Foundation.kt - // and - // kotlinx.cinterop.ObjCClassOf.create(string: kotlin.String): T defined in platform.Foundation in file Foundation.kt - - val argName = - if (this.hasObjCMethodAnnotation || this.hasObjCFactoryAnnotation || this.isObjCClassMethod()) "${it.name}:" else "" - "$argName${typeToHashString(it.type)}${if (it.isVararg) "_VarArg" else ""}" - }.joinToString(";") + // TODO: there are clashes originating from ObjectiveC interop. + // kotlinx.cinterop.ObjCClassOf.create(format: kotlin.String): T defined in platform.Foundation in file Foundation.kt + // and + // kotlinx.cinterop.ObjCClassOf.create(string: kotlin.String): T defined in platform.Foundation in file Foundation.kt + val argName = + if (this.hasObjCMethodAnnotation || this.hasObjCFactoryAnnotation || this.isObjCClassMethod()) "${it.name}:" else "" + "$argName${typeToHashString(it.type, typeParameterNamer)}${if (it.isVararg) "_VarArg" else ""}" + }.joinToString(";") + } override val IrFunction.platformSpecificFunctionName: String? get() { @@ -123,6 +124,13 @@ object KonanMangler : KotlinManglerImpl() { } } +object KonanMangler : AbstractKonanMangler() + +object KonanManglerForBE : AbstractKonanMangler() { + override fun mangleTypeParameter(typeParameter: IrTypeParameter, typeParameterNamer: (IrTypeParameter) -> String): String = + typeParameter.name.asString() +} + internal val IrClass.writableTypeInfoSymbolName: String get() { assert (this.isExported()) @@ -138,15 +146,15 @@ internal val IrClass.objectInstanceGetterSymbolName: String return "kobjget:$fqNameForIrSerialization" } -val IrFunction.functionName get() = with(KonanMangler) { functionName } +val IrFunction.functionName get() = with(KonanManglerForBE) { functionName } -val IrFunction.symbolName get() = with(KonanMangler) { symbolName } +val IrFunction.symbolName get() = with(KonanManglerForBE) { symbolName } -val IrField.symbolName get() = with(KonanMangler) { symbolName } +val IrField.symbolName get() = with(KonanManglerForBE) { symbolName } -val IrClass.typeInfoSymbolName get() = with(KonanMangler) { typeInfoSymbolName } +val IrClass.typeInfoSymbolName get() = with(KonanManglerForBE) { typeInfoSymbolName } -fun IrDeclaration.isExported() = with(KonanMangler) { isExported() } +fun IrDeclaration.isExported() = with(KonanManglerForBE) { isExported() } // TODO: bring here dependencies of this method? internal fun RuntimeAware.getLlvmFunctionType(function: IrFunction): LLVMTypeRef { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrFileSerializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrFileSerializer.kt index bcb3925ef42..a182caf5c5c 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrFileSerializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrFileSerializer.kt @@ -4,15 +4,19 @@ import org.jetbrains.kotlin.backend.common.LoggingContext import org.jetbrains.kotlin.backend.common.serialization.DeclarationTable import org.jetbrains.kotlin.backend.common.serialization.IrFileSerializer import org.jetbrains.kotlin.backend.konan.RuntimeNames +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.util.hasAnnotation class KonanIrFileSerializer( - logger: LoggingContext, - declarationTable: DeclarationTable, - bodiesOnlyForInlines: Boolean = false -): IrFileSerializer(logger, declarationTable, bodiesOnlyForInlines) { + logger: LoggingContext, + declarationTable: DeclarationTable, + expectDescriptorToSymbol: MutableMap, + skipExpects: Boolean, + bodiesOnlyForInlines: Boolean = false +): IrFileSerializer(logger, declarationTable, expectDescriptorToSymbol, skipExpects = skipExpects, bodiesOnlyForInlines = bodiesOnlyForInlines) { override fun backendSpecificExplicitRoot(declaration: IrFunction) = declaration.annotations.hasAnnotation(RuntimeNames.exportForCppRuntime) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt index bba1cc329a1..01267f553e5 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrModuleSerializer.kt @@ -4,9 +4,11 @@ import org.jetbrains.kotlin.backend.common.LoggingContext import org.jetbrains.kotlin.backend.common.descriptors.propertyIfAccessor import org.jetbrains.kotlin.backend.common.serialization.* import org.jetbrains.kotlin.backend.konan.descriptors.isFromInteropLibrary +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns +import org.jetbrains.kotlin.ir.symbols.IrSymbol import org.jetbrains.kotlin.ir.util.UniqId import org.jetbrains.kotlin.resolve.descriptorUtil.module @@ -34,13 +36,14 @@ private class KonanDeclarationTable( class KonanIrModuleSerializer( logger: LoggingContext, irBuiltIns: IrBuiltIns, - private val descriptorTable: DescriptorTable + private val descriptorTable: DescriptorTable, + private val expectDescriptorToSymbol: MutableMap, + val skipExpects: Boolean ) : IrModuleSerializer(logger) { private val globalDeclarationTable = KonanGlobalDeclarationTable(irBuiltIns) override fun createSerializerForFile(file: IrFile): KonanIrFileSerializer = - KonanIrFileSerializer(logger, KonanDeclarationTable(descriptorTable, globalDeclarationTable, 0)) - -} \ No newline at end of file + KonanIrFileSerializer(logger, KonanDeclarationTable(descriptorTable, globalDeclarationTable, 0), expectDescriptorToSymbol, skipExpects = skipExpects) +} diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt index 80402c47f74..09694ec8a2a 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt @@ -31,12 +31,12 @@ import org.jetbrains.kotlin.ir.util.UniqId import org.jetbrains.kotlin.resolve.descriptorUtil.module class KonanIrLinker( - currentModule: ModuleDescriptor, - logger: LoggingContext, - builtIns: IrBuiltIns, - symbolTable: SymbolTable, - forwardModuleDescriptor: ModuleDescriptor?, - exportedDependencies: List + currentModule: ModuleDescriptor, + logger: LoggingContext, + builtIns: IrBuiltIns, + symbolTable: SymbolTable, + forwardModuleDescriptor: ModuleDescriptor?, + exportedDependencies: List ) : KotlinIrLinker(logger, builtIns, symbolTable, exportedDependencies, forwardModuleDescriptor, KonanMangler), DescriptorUniqIdAware by DeserializedDescriptorUniqIdAware { diff --git a/gradle.properties b/gradle.properties index a99de20bb88..9fe2ce0b52b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,12 +18,12 @@ buildKotlinVersion=1.3.70-dev-1070 buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1070,branch:default:any,pinned:true/artifacts/content/maven remoteRoot=konan_tests -kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-2841,branch:default:any,pinned:true/artifacts/content/maven -kotlinVersion=1.3.70-dev-2841 +kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.4.0-dev-216,branch:default:any,pinned:true/artifacts/content/maven +kotlinVersion=1.4.0-dev-216 kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-2841,branch:default:any,pinned:true/artifacts/content/maven -kotlinStdlibVersion=1.3.70-dev-2841 -kotlinStdlibTestsVersion=1.3.70-dev-2841 -testKotlinCompilerVersion=1.3.70-dev-2841 +kotlinStdlibVersion=1.4.0-dev-216 +kotlinStdlibTestsVersion=1.4.0-dev-216 +testKotlinCompilerVersion=1.4.0-dev-216 konanVersion=1.4.0 # A version of Xcode required to build the Kotlin/Native compiler. @@ -34,4 +34,3 @@ org.gradle.workers.max=4 # Uncomment to enable composite build #kotlinProjectPath= - diff --git a/klib/src/main/kotlin/org/jetbrains/kotlin/cli/klib/main.kt b/klib/src/main/kotlin/org/jetbrains/kotlin/cli/klib/main.kt index aaf7e4325b4..f48dbbbe0ad 100644 --- a/klib/src/main/kotlin/org/jetbrains/kotlin/cli/klib/main.kt +++ b/klib/src/main/kotlin/org/jetbrains/kotlin/cli/klib/main.kt @@ -17,7 +17,9 @@ import org.jetbrains.kotlin.konan.target.Distribution import org.jetbrains.kotlin.konan.target.PlatformManager import org.jetbrains.kotlin.konan.util.DependencyProcessor import org.jetbrains.kotlin.library.unpackZippedKonanLibraryTo -import org.jetbrains.kotlin.konan.utils.KonanFactories.DefaultDeserializedDescriptorFactory +import org.jetbrains.kotlin.konan.util.KlibMetadataFactories +import org.jetbrains.kotlin.konan.utils.createKonanBuiltIns +import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer import org.jetbrains.kotlin.util.Logger import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf import org.jetbrains.kotlin.konan.library.KonanLibrary @@ -27,6 +29,8 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager import java.lang.System.out import kotlin.system.exitProcess +object KlibFactories : KlibMetadataFactories(::createKonanBuiltIns, DynamicTypeDeserializer) + fun printUsage() { println("Usage: klib ") println("where the commands are:") @@ -159,7 +163,7 @@ class Library(val name: String, val requestedRepository: String?, val target: St val storageManager = LockBasedStorageManager("klib") val library = libraryInRepoOrCurrentDir(repository, name) val versionSpec = LanguageVersionSettingsImpl(currentLanguageVersion, currentApiVersion) - val module = DefaultDeserializedDescriptorFactory.createDescriptorAndNewBuiltIns(library, versionSpec, storageManager, null) + val module = KlibFactories.DefaultDeserializedDescriptorFactory.createDescriptorAndNewBuiltIns(library, versionSpec, storageManager, null) val defaultModules = mutableListOf() if (!module.isKonanStdlib()) { @@ -170,7 +174,7 @@ class Library(val name: String, val requestedRepository: String?, val target: St logger = KlibToolLogger) resolver.defaultLinks(false, true, true) .mapTo(defaultModules) { - DefaultDeserializedDescriptorFactory.createDescriptor( + KlibFactories.DefaultDeserializedDescriptorFactory.createDescriptor( it, versionSpec, storageManager, module.builtIns, null) } } diff --git a/runtime/src/main/kotlin/kotlin/text/Appendable.kt b/runtime/src/main/kotlin/kotlin/text/Appendable.kt index 79c68c4ce03..74f572e022b 100644 --- a/runtime/src/main/kotlin/kotlin/text/Appendable.kt +++ b/runtime/src/main/kotlin/kotlin/text/Appendable.kt @@ -10,28 +10,28 @@ package kotlin.text */ public actual interface Appendable { /** - * Appends the specified character [c] to this Appendable and returns this instance. + * Appends the specified character [value] to this Appendable and returns this instance. * - * @param c the character to append. + * @param value the character to append. */ - actual fun append(c: Char): Appendable + actual fun append(value: Char): Appendable /** - * Appends the specified character sequence [csq] to this Appendable and returns this instance. + * Appends the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence to append. If [csq] is `null`, then the four characters `"null"` are appended to this Appendable. + * @param value the character sequence to append. If [value] is `null`, then the four characters `"null"` are appended to this Appendable. */ - actual fun append(csq: CharSequence?): Appendable + actual fun append(value: CharSequence?): Appendable /** - * Appends a subsequence of the specified character sequence [csq] to this Appendable and returns this instance. + * Appends a subsequence of the specified character sequence [value] to this Appendable and returns this instance. * - * @param csq the character sequence from which a subsequence is appended. If [csq] is `null`, - * then characters are appended as if [csq] contained the four characters `"null"`. - * @param start the beginning (inclusive) of the subsequence to append. - * @param end the end (exclusive) of the subsequence to append. + * @param value the character sequence from which a subsequence is appended. If [value] is `null`, + * then characters are appended as if [value] contained the four characters `"null"`. + * @param startIndex the beginning (inclusive) of the subsequence to append. + * @param endIndex the end (exclusive) of the subsequence to append. * - * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [start] or [end] is out of range of the [csq] character sequence indices or when `start > end`. + * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`. */ - actual fun append(csq: CharSequence?, start: Int, end: Int): Appendable + actual fun append(value: CharSequence?, startIndex: Int, endIndex: Int): Appendable } diff --git a/runtime/src/main/kotlin/kotlin/text/StringBuilder.kt b/runtime/src/main/kotlin/kotlin/text/StringBuilder.kt index abb3a0f9f18..c3f509e673e 100644 --- a/runtime/src/main/kotlin/kotlin/text/StringBuilder.kt +++ b/runtime/src/main/kotlin/kotlin/text/StringBuilder.kt @@ -46,20 +46,20 @@ actual class StringBuilder private constructor ( actual override fun subSequence(startIndex: Int, endIndex: Int): CharSequence = substring(startIndex, endIndex) // Of Appenable. - actual override fun append(c: Char) : StringBuilder { + actual override fun append(value: Char) : StringBuilder { ensureExtraCapacity(1) - array[_length++] = c + array[_length++] = value return this } - actual override fun append(csq: CharSequence?): StringBuilder { + actual override fun append(value: CharSequence?): StringBuilder { // Kotlin/JVM processes null as if the argument was "null" char sequence. - val toAppend = csq ?: "null" + val toAppend = value ?: "null" return append(toAppend, 0, toAppend.length) } @UseExperimental(ExperimentalStdlibApi::class) - actual override fun append(csq: CharSequence?, start: Int, end: Int): StringBuilder = this.appendRange(csq, start, end) + actual override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder = this.appendRange(value, startIndex, endIndex) /** * Reverses the contents of this string builder and returns this instance. diff --git a/shared/src/library/kotlin/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt b/shared/src/library/kotlin/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt index 6da0cca1cf2..3f444e3f91e 100644 --- a/shared/src/library/kotlin/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt +++ b/shared/src/library/kotlin/org/jetbrains/kotlin/konan/library/impl/KonanLibraryImpl.kt @@ -36,9 +36,14 @@ open class TargetedLibraryImpl( override val targetList by lazy { access.inPlace { it: TargetedKotlinLibraryLayout -> - it.targetsDir.listFiles.map { - it.name - } + if (!it.targetsDir.exists) + // TODO: We have a choice: either assume it is the CURRENT TARGET + // or a list of ALL KNOWN targets. + access.target ?. let { listOf(it.visibleName) } ?: emptyList() + else + it.targetsDir.listFiles.map { + it.name + } } } @@ -100,4 +105,4 @@ fun createKonanLibrary( val bitcode = BitcodeLibraryImpl(bitcodeAccess, targeted) return KonanLibraryImpl(targeted, metadata, ir, bitcode) -} \ No newline at end of file +}