v79
11/25/2020, 9:10 AMcomponents.main {
// Compile the component into an executable and a Kotlin/Native library.
outputKinds = [EXECUTABLE, KLIBRARY]
}
Which we all know doesn't work, components.main
is completely invalid syntax. I tried creating an empty Kotlin/Native library using Intellij's new project wizard did not add anything like outputKinds = KLIBRARY
.Frankablu
11/26/2020, 6:55 PMnapperley
11/26/2020, 9:15 PMserebit
11/27/2020, 6:40 PMFrankablu
11/27/2020, 9:16 PMv79
11/28/2020, 4:56 PMEvent
class? https://github.com/JetBrains/kotlin-native/blob/master/samples/weather_function/function/src/main/kotlin/org/example/weather_func/events.kt ? I'm trying to understand how the libcurl examples from the Kotlin native samples code work. It only seems to work for short HTTP responses; when libcurl starts chunking larger responses I lose most of it.napperley
11/30/2020, 12:15 AMArkadii Ivanov
11/30/2020, 4:00 PMTodoDatabase(
NativeSqliteDriver(
DatabaseConfiguration(
name = "",
version = 1,
create = { wrapConnection(it, TodoDatabase.Schema::create) },
inMemory = true
)
)
)
I added some logs and it seems that it actually executes Schema.create. However all queries to this database in tests are failing with errors like no such table
.
Also I see the following message in the logs: Invalid connection: com.apple.coresymbolicationd
. Not sure if it is related actually.
Could somebody give me some advice?Luigi Scarminio
11/30/2020, 4:29 PMArkadii Ivanov
11/30/2020, 8:27 PMnapperley
12/01/2020, 3:23 AMUncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared org.digieng.kmqtt.client.MqttClient@add4d8 from other thread
at kfun:kotlin.Throwable#<init>(kotlin.String?){} (0x2a7e09)
at kfun:kotlin.Exception#<init>(kotlin.String?){} (0x2a1a07)
at kfun:kotlin.RuntimeException#<init>(kotlin.String?){} (0x2a1bb7)
at kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} (0x2cb1c7)
at ThrowIllegalObjectSharingException (0x2cd977)
at (0x3e4acb)
at _ZNK16KRefSharedHolder3refIL11ErrorPolicy2EEEP9ObjHeaderv (0x3e48f3)
at Kotlin_Interop_derefStablePointer (0x3e488e)
at kfun:kotlinx.cinterop.StableRef#get(){}1:0 (0x2692e6)
at kfun:org.digieng.kmqtt.client.onDeliveryComplete#internal (0x37522e)
at _6f72672e64696769656e673a6b6d7174742d636c69656e74_knbridge46 (0x37602b)
at MQTTClient_cycle (0x410d46)
at MQTTClient_run (0x40c4dd)
at (0x7f7a508b56db)
at clone (0x7f7a503c6a3f)
at ((nil))
Aborted (core dumped)
What is the way to resolve this issue? Note that the Linux platform is used as the target, which does allow for multi-threading. However the synchronous version of the Paho MQTT library is used which is single threaded.Animesh Sahu
12/02/2020, 6:59 AMobject MySingleton {
private var testingVar = false
}
Variable in singleton without @ThreadLocal can't be changed after initialization.
On annotating with @ThreadLocal results in error: @ThreadLocal is applicable only to top level declarations
v79
12/02/2020, 7:07 AMlinuxArm32Hfp
for the Raspberry Pi. So I checked out the kotlinx-datetime code, and took a look - perhaps I could make it work? After all, what's the different between linuxX64
and linuxArm32Hfp
- both are POSIX, both are likely to include the same core libraries. It turns out, there isn't a difference - I took kotlinx-datetime, added a single line to build.gradle.kts
- I added target("linuxArm32Hfp")
, compiled, deployed to maven local, and it worked. I was able to use kotlinx-datetime in my Raspberry Pi code just fine. I haven't fully tested it, but for my simple use case, it seems to be working just fine. So I'm beginning to wonder, what other Kotlin/Native libraries will 'just work' on "unsupported" platforms with just a small change to the build configuration?Animesh Sahu
12/02/2020, 3:18 PMmkrussel
12/02/2020, 4:25 PMiosMain
source set.
This used to work correctly but has not for awhile.
I've tried invalidating my cache, doing a full build, but the warnings will not go away.
I'm using 2020.3 community edition.
Kotlin plugin 203-1.4.10-relase-IJ5981.133
Kotlin 1.4.10
Is this a known problem or just something broken with meHankG
12/02/2020, 7:04 PMHankG
12/02/2020, 7:11 PMnapperley
12/02/2020, 11:40 PMUncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared org.digieng.kmqtt.client.MqttClient@66c4d8 from other thread
at kfun:kotlin.Throwable#<init>(kotlin.String?){} (0x2a7e09)
at kfun:kotlin.Exception#<init>(kotlin.String?){} (0x2a1a07)
at kfun:kotlin.RuntimeException#<init>(kotlin.String?){} (0x2a1bb7)
at kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} (0x2cb1c7)
at ThrowIllegalObjectSharingException (0x2cd977)
at (0x3e4b1b)
at _ZNK16KRefSharedHolder3refIL11ErrorPolicy2EEEP9ObjHeaderv (0x3e4943)
at Kotlin_Interop_derefStablePointer (0x3e48de)
at kfun:kotlinx.cinterop.StableRef#get(){}1:0 (0x2692e6)
at kfun:org.digieng.kmqtt.client.onDeliveryComplete#internal (0x37529e)
at _6f72672e64696769656e673a6b6d7174742d636c69656e74_knbridge46 (0x37609b)
at MQTTClient_cycle (0x410d96)
at MQTTClient_run (0x40c52d)
at (0x7f4eb1b756db)
at clone (0x7f4eb1686a3f)
at ((nil))
Aborted (core dumped)
After examining the libcurl ( https://github.com/JetBrains/kotlin-native/tree/master/samples/libcurl ) and curl ( https://github.com/JetBrains/kotlin-native/tree/master/samples/curl ) Kotlin Native samples there are two major differences (stuff not present). First difference is that the initRuntimeIfNeeded function isn't called inside the event handlers (C callbacks), and the second difference is that Kotlin Coroutines aren't used. Is the issue that is being encountered one of the corner cases mentioned in the article ( https://blog.jetbrains.com/kotlin/2020/07/kotlin-native-memory-management-roadmap/ )? Would highly appreciate some guidance from the Kotlin Native team on using Kotlin Coroutines with Kotlin Native's memory model (guides, key things to avoid, best practices etc).Animesh Sahu
12/03/2020, 5:00 AMmemScoped{}
block safe/ok?mkrussel
12/03/2020, 4:35 PMkotlin {
ios {
val frameworkLocation = File(rootDir, "native/TestApp/Pods/Mapbox-iOS-SDK/dynamic/").absolutePath
val frameworks = "-F$frameworkLocation"
binaries.configureEach {
linkerOpts(frameworks)
}
}
}
I get the following error when it runs the tests.
dyld: Library not loaded: @rpath/Mapbox.framework/Mapbox
Referenced from: /Users/mkrussel/pangea/pangea-android/test-app-shared/build/bin/iosX64/debugTest/test.kexe
Reason: image not found
Animesh Sahu
12/04/2020, 5:20 AMAnimesh Sahu
12/04/2020, 11:15 AMAlex Gladkov
12/04/2020, 3:46 PMkevin.cianfarini
12/04/2020, 7:26 PMAnimesh Sahu
12/05/2020, 4:24 AMUnfinished workers detected, 1 workers leaked!
Use `Platform.isMemoryLeakCheckerActive = false` to avoid this check.
Here's a small repro:
object Testing {
val event = MutableSharedFlow<Int>(extraBufferCapacity = 8)
init {
event.subscriptionCount
// .onEach { println("Subscription Count: $it") } // Stub, For seeing the behavior
.launchIn(CoroutineScope(Dispatchers.Unconfined))
}
}
fun main() = runBlocking {
Testing
}
Edit: Sometimes the following error is generated as well:
Memory leaks detected, 76 objects leaked!
Use `Platform.isMemoryLeakCheckerActive = false` to avoid this check.
Animesh Sahu
12/05/2020, 4:04 PMAnimesh Sahu
12/05/2020, 4:42 PMcommonNativeMain
module for all native modules? If yes how, and how to access kotlin.native packages there. I tried using
val commonNativeMain by creating { ... }
But that doesn't seem to access kotlin.native packages...v79
12/05/2020, 9:58 PMAnimesh Sahu
12/06/2020, 10:52 AMlinuxX64 {
val main by compilations.getting
main.cinterops.create("x11") {
defFile("src/linuxX64Main/cinterop/x11.def")
compilerOpts.add("-I" + rootDir.resolve("include"))
}
}
library compiles fine, and published to mavenLocal fine, but when some other project add it as a dependency and runs the linker, it produces the following
> Task :linkReleaseExecutableLinuxX64
e: C:\Users\Animesh\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1/bin/ld.lld invocation reported errors
The C:\Users\Animesh\.konan\dependencies\msys2-mingw-w64-x86_64-clang-llvm-lld-compiler_rt-8.0.1/bin/ld.lld command returned non-zero exit code: 1.
output:
ld.lld: error: undefined symbol: XOpenDisplay
>>> referenced by out
>>> C:\Users\Animesh\AppData\Local\Temp\konan_temp3813013133705122841\result.o:(kfun:com.github.animeshz.keyboard.X11KeyboardHandler#prepare(){})
ld.lld: error: undefined symbol: XPeekEvent
>>> referenced by out
>>> C:\Users\Animesh\AppData\Local\Temp\konan_temp3813013133705122841\result.o:(kfun:com.github.animeshz.keyboard.X11KeyboardHandler#readEvents(){})
ld.lld: error: undefined symbol: XCloseDisplay
>>> referenced by out
>>> C:\Users\Animesh\AppData\Local\Temp\konan_temp3813013133705122841\result.o:(kfun:com.github.animeshz.keyboard.X11KeyboardHandler#cleanup(){})
> Task :linkReleaseExecutableLinuxX64 FAILED
Don't the c-interop symbols get shipped with the artifact?Paul Woitaschek
12/07/2020, 1:19 PMPaul Woitaschek
12/07/2020, 1:19 PMArtyom Degtyarev [JB]
12/07/2020, 1:33 PM