Hey, I have spotted this in my multiplatform proje...
# kotlin-native
u
Hey, I have spotted this in my multiplatform project, but I guess it's konanc related. I'm using 1.4-M1 I am using
UByteArray
inline class in my project. linkDebugStaticLinux task fails (rather silently), but running konanc directly with parameters from the task provides the following output (this is just a snippet:
Copy code
/tmp/konan_temp4669369786604700434/api.cpp:249:216: error: unknown type name 'libmultiplatform_crypto_kref_kotlin_ByteArray'; did you mean 'libmultiplatform_crypto_kref_kotlin_Array'?
                  libmultiplatform_crypto_kref_kotlin_ByteArray (*digest_)(libmultiplatform_crypto_kref_com_ionspin_kotlin_crypto_hash_StatelessHash thiz, libmultiplatform_crypto_kref_kotlin_ByteArray inputMessage, libmultiplatform_crypto_kref_kotlin_ByteArray key, libmultiplatform_crypto_KInt hashLength);
                                                                                                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                                                                                                                                                                       libmultiplatform_crypto_kref_kotlin_Array                                                             
/tmp/konan_temp4669369786604700434/api.cpp:77:3: note: 'libmultiplatform_crypto_kref_kotlin_Array' declared here
} libmultiplatform_crypto_kref_kotlin_Array;
Indicating that
libmultiplatform_crypto_kref_kotlin_ByteArray
is unknown, which is somewhat correct because I am using UByteArray. I worked around this issue by simply declaring one ByteArray in the same class like this
Copy code
val byteArray: ByteArray = byteArrayOf(0, 1)
And then compilation succeeded. My question is, is this a known bug, or should I report it?
a
Hello, @Ugi! This is a known bug, there are some issues with primitive unassigned-type arrays export to native library (see previous report here https://github.com/JetBrains/kotlin-native/issues/3890). Your workaround is also like the one from the issue, well done! Unfortunately, seems like one has to go with it for now.
u
Hi Artyom, thanks for the fast reply!
a
You can also upvote this bug at the Kotlin issue tracker(https://youtrack.jetbrains.com/issue/KT-36878).