Distractic
06/21/2025, 7:01 AMSkolson5903
06/22/2025, 7:25 PM#include "getrandom_wrapper.h"
ssize_t call_getrandom(void *buf, size_t buflen, unsigned int flags) {
return getrandom(buf, buflen, flags);
}
and the header is this:
#include <sys/random.h>
// Wrapper function to call getrandom()
ssize_t wrapper_getrandom(void *buf, size_t buflen, unsigned int flags);
This compiles and links fine using gcc and produces a small static library. The .def file looks like this:
headers = getrandom_wrapper.h
package = com.oldguy.crypto
linkerOpts = -L.,/usr/include/x86_64-linux-gnu/ -lgetrandom_wrapper
The gradle setup for linuxX64 cinterop is this:
compilations.getByName("main") {
val path = "${project.rootDir}/KmpCrypto/src/linuxMain/cinterop"
cinterops {
val myLibraryCinterop by creating {
defFile(project.file("$path/getrandom_wrapper.def"))
includeDirs(path, "/usr/include/x86_64-linux-gnu") // Ubuntu location of sys/random.h
}
}
}
At cinterop (gradle sync) time, this error pops:
/usr/include/x86_64-linux-gnu/sys/cdefs.h:153:34: error: function-like macro '__glibc_clang_prereq' is not defined
Has anyone else seen this and knows what causes it? This macro should be defined by the sys/features.h that gets pulled in by sys/random.h. The code snippet from features.h that isn't working looks like this:
/* Similarly for clang. Features added to GCC after version 4.2 may
or may not also be available in clang, and clang's definitions of
__GNUC(_MINOR)__ are fixed at 4 and 2 respectively. Not all such
features can be queried via __has_extension/__has_feature. */
#if defined __clang_major__ && defined __clang_minor__
# define __glibc_clang_prereq(maj, min) \
((__clang_major__ << 16) + __clang_minor__ >= ((maj) << 16) + (min))
#else
# define __glibc_clang_prereq(maj, min) 0
#endif
Thanks in advance for any ideas on how to diagnose/fix this.rkechols
06/23/2025, 2:51 AMJimmy Nelle
06/25/2025, 1:58 PMSkolson5903
06/28/2025, 12:03 AMld.lld: error: undefined symbol: fcntl64
I think fcntl
was renamed to fcntl64
in glibc 2.28, and I'm afraid this is newer than the native konan stack is handling. I tried this line in the .def:
linkerOpts.linux = --allow-shlib-undefined -L/usr/lib/x86_64-linux-gnu -licui18n -licuuc -licudata -lz -llzma -lpthread
hoping that the --allow option would tell the linker to ignore the missing symbol, but no help. Libxml2 required all those other libs. Has anyone seen this issue with the fcntl64 undefined symbol and have a fix/workaround?CLOVIS
06/29/2025, 6:18 PMHamid
06/30/2025, 1:35 PMinternal fun LogMessage.detail(data: NSData?, operation: Operation) {
detail(data?.toByteArray(), operation)
}
internal fun LogMessage.detail(error: NSError?) {
if (error != null) detail("error", error.toString())
}
internal fun LogMessage.detail(service: CBService? = null) {
detail("service", service?.UUID?.UUIDString ?: "Unknown UUID")
}
internal fun LogMessage.detail(characteristic: CBCharacteristic) {
val serviceUuid = characteristic.service
?.UUID
?.toUuid()
if (serviceUuid == null) {
detail("service", "Unknown (null value)")
return
}
detail(serviceUuid, characteristic.UUID.toUuid())
}
internal fun LogMessage.detail(descriptor: CBDescriptor) {
val characteristic = descriptor.characteristic
if (characteristic == null) {
detail("characteristic", "Unknown (null value)")
return
}
val serviceUuid = characteristic.service
?.UUID
?.toUuid()
if (serviceUuid == null) {
detail("service", "Unknown (null value)")
return
}
detail(
serviceUuid,
characteristic.UUID.toUuid(),
descriptor.UUID.toUuid(),
)
}
and this is the error I got.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CBDescriptor service]: unrecognized selector sent to instance 0x1086a94d0'
*** First throw call stack:
(0x193fff21c 0x191499abc 0x194069614 0x193f13a1c 0x193f13aa0 0x10dddacf0 0x10ddd1a98 0x10ddd4538 0x1bd7cad94 0x1bd7caec4 0x1bd7c7a18 0x1bd786a40 0x1bd78422c 0x1bd784114 0x1034a8584 0x1034c2064 0x1034b091c 0x1034b15d8 0x1034b0758 0x1034b15a4 0x1034bd894 0x1034bceb0 0x21e5f4a0c 0x21e5f4aac)
libc++abi: terminating due to uncaught exception of type NSException
and I also attached the XCode error. Anyone has any idea how to fix it? please let me know if more information is needed.
Thread in Slack Conversationאליהו הדס
07/01/2025, 2:33 AMVaibhav Jaiswal
07/01/2025, 11:19 AMkotlin.native.cocoapods
plugin and by using this
pod("...") { ..... }
Mats-Hjalmar
07/02/2025, 8:02 AMdyld[4166]: Symbol not found: __ZTINSt3__117bad_function_callE
Referenced from:
/private/var/containers/Bundle/Application/[my app].debug.dylib
Expected in: /usr/lib/libc++.1.dylib
It was working before then i upgraded a few libraries.
My current versions:
kotlin = "2.2.0"
agp = "8.5.2"
compose = "1.8.2"
composeCompiler = "1.5.15"
However, when i build the app for iPhone XS it works.
And if i revert to these versions
kotlin = "2.0.20"
agp = "8.5.0"
compose = "1.7.0"
composeCompiler = "1.5.14"
It works on both iPad and iPhone.zt
07/04/2025, 4:01 AMzt
07/04/2025, 11:50 PMFrançois
07/05/2025, 9:18 AMDan Kaser
07/07/2025, 2:28 PMGhasem Shirdel
07/07/2025, 6:09 PMsupportsMainMenu
, which I naturally don’t use anywhere in the iOSApp code. Is this being used in the background by Compose?
The second issue happens when the function stackTraceToString
is called — a leak occurs. Libraries like Napier and other logging libraries use this function. Is this problem only present in debug mode?
My Compose version is 1.8.1 and Kotlin version is 2.2.0.
Thread in Slack ConversationGhasem Shirdel
07/07/2025, 6:09 PMcafonsomota
07/10/2025, 4:55 PMsmallBinary
feature released on 2.2.20-Beta1 but I didn’t noticed any change on the frameworks size; I’ve tested both added on gradle.properties
and on build.gradle.kts
. Am I missing something? 🤔Mikolaj
07/15/2025, 1:13 PMDmitriy Tarasevich
07/18/2025, 2:28 AMException in thread "main" java.lang.IllegalStateException: Unresolved classifier: platform/darwin/NSObjectProtocolMeta
at org.jetbrains.kotlin.commonizer.metadata.CirDeserializers.type(CirDeserializers.kt:655)
at org.jetbrains.kotlin.commonizer.metadata.CirDeserializers.clazz(CirDeserializers.kt:241)
at org.jetbrains.kotlin.commonizer.tree.deserializer.CirTreeClassDeserializer.invoke(CirTreeClassDeserializer.kt:32)
at org.jetbrains.kotlin.commonizer.tree.deserializer.CirTreePackageDeserializer.invoke(CirTreePackageDeserializer.kt:41)
at org.jetbrains.kotlin.commonizer.tree.deserializer.CirTreeModuleDeserializer.invoke(CirTreeModuleDeserializer.kt:32)
at org.jetbrains.kotlin.commonizer.tree.deserializer.RootCirTreeDeserializer.invoke(RootCirTreeDeserializer.kt:37)
at org.jetbrains.kotlin.commonizer.FacadeKt.deserializeTarget(facade.kt:38)
at org.jetbrains.kotlin.commonizer.FacadeKt.deserializeTarget(facade.kt:44)
at org.jetbrains.kotlin.commonizer.CommonizerQueueKt.CommonizerQueue$lambda$1$lambda$0(CommonizerQueue.kt:22)
at org.jetbrains.kotlin.commonizer.CommonizerQueue.deserializedTargets$lambda$1$lambda$0(CommonizerQueue.kt:56)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:408)
at org.jetbrains.kotlin.commonizer.CommonizerQueue.commonize(CommonizerQueue.kt:106)
at org.jetbrains.kotlin.commonizer.CommonizerQueue.enqueue$lambda$6(CommonizerQueue.kt:97)
at org.jetbrains.kotlin.storage.LockBasedStorageManager$LockBasedLazyValue.invoke(LockBasedStorageManager.java:408)
at org.jetbrains.kotlin.commonizer.CommonizerQueue.invokeTarget(CommonizerQueue.kt:90)
at org.jetbrains.kotlin.commonizer.CommonizerQueue.invokeAll(CommonizerQueue.kt:83)
at org.jetbrains.kotlin.commonizer.FacadeKt.runCommonization(facade.kt:32)
at org.jetbrains.kotlin.commonizer.konan.LibraryCommonizer.commonizeAndSaveResults(LibraryCommonizer.kt:51)
at org.jetbrains.kotlin.commonizer.konan.LibraryCommonizer.run(LibraryCommonizer.kt:30)
at org.jetbrains.kotlin.commonizer.cli.NativeKlibCommonize.execute(nativeTasks.kt:79)
at org.jetbrains.kotlin.commonizer.cli.CommonizerCLI.executeTasks(cli.kt:60)
at org.jetbrains.kotlin.commonizer.cli.CommonizerCLI.main(cli.kt:17)
No idea where to go from hereJohannes Zottele
07/18/2025, 3:07 PMPinned
objects in K/N.
1. If I pin an object using the pin()
extension function and never unpin()
it, will the garbage collector eventually collect it? I found a thread on this channel that suggests that a pinned object remains unchanged and is not moved or freed. However, I’ve written a test program that demonstrates that the callback passed to createCleaner is invoked for both the pinned value object and the Pinned -Object itself.
@OptIn(ExperimentalNativeApi::class, ExperimentalForeignApi::class)
private fun allocate(): Unit {
// create a dummy resource and pin it (but never unpin)
val dummy = Any()
val pinned = dummy.pin()
// setup clean-up callbacks for both, the pinned value and the pinned-object
createCleaner(dummy) {
println("Cleaning up dummy (${markNow()})")
}
createCleaner(pinned) {
println("Cleaning up pinned (${markNow()})")
}
}
@OptIn(NativeRuntimeApi::class)
fun main() {
allocate()
// trigger garbage collection manually
GC.collect()
runBlocking {
// wait 10 secs to see cleaner callbacks
delay(10000)
}
println("Done. (${markNow()})")
}
This outputs
Cleaning up pinned (ValueTimeMark(reading=15083))
Cleaning up dummy (ValueTimeMark(reading=129458))
Done. (ValueTimeMark(reading=10002954250))
So, according to this, the garbage collector actually recognizes both objects, implying that they are being freed. Is that accurate, or are those callbacks triggered even though the underlying object memory remains valid?
2. Assuming pinned is getting collected by the GC, will it unpin()
the dummy object automatically?Nikolay Kasyanov
07/29/2025, 2:52 PM@Volatile
cannot be applied to local variables, which makes sense historically, but applies to JVM only, what about native?wwalkingg
07/30/2025, 5:51 AMaltavir
08/01/2025, 7:25 AM.konan\dependencies\msys2-mingw-w64-x86_64-2\bin\ld.gold: error: cannot find -lunistring
does anybody know how to fix it? For some reason it happens only on some projects.Ghasem Shirdel
08/04/2025, 6:31 AMVishal kumar singhvi
08/05/2025, 8:37 AMDidier Villevalois
08/07/2025, 2:41 PMkotlin-native-prebuilt-2.2.0-linux-aarch64.tar.gz
on Maven Central... Is that expected? I encountered that while loading the MCP SDK to make some PRs. I run Fedora Linux (Asahi) on an M1 MBP. I will disable the native targets for now, but that's quite uncomfortable... 😭Raed Ghazal
08/08/2025, 1:17 PMStefan Oltmann
08/17/2025, 6:37 PMAdam S
08/22/2025, 8:42 AM-include-binary
KN compiler arg actually do? Does it just tell the compiler to package the files into the my-lib.klib
in the /my-lib/default/targets/${targetName}/included/
dir?
Context: I have two .a
static library files ( 'debug' and 'release'). I can't see how my subproject my-app
can only use the debug my-lib
when running runMyAppDebugExecutableMacosArm64
and the release my-lib
when running runMyAppReleaseExecutableMacosArm64
.
I was thinking about making two variants of my library, one that produces a my-lib-release.klib
and another that produces my-lib-debug.klib
. The only difference being the included static libs. If I can build the .klib
manually, and just update the included files, that'd be a solution (albeit complicated and something I'd prefer to avoid).loke
08/25/2025, 5:30 AM.kt
source file.