hfhbd
09/05/2022, 1:01 PMw: Linking two modules of different data layouts: '/var/folders/8j/m605_xwx6s93xxf3tjfbkqlm0000gn/T/native4890200288988106563/cstubs.bc' is 'e-m:o-p:32:32-Fi8-i64:64-a:0:32-n32-S128' whereas 'out' is 'e-m:o-p:32:32-i64:64-i128:128-n32:64-S128'
w: Linking two modules of different target triples: /var/folders/8j/m605_xwx6s93xxf3tjfbkqlm0000gn/T/native4890200288988106563/cstubs.bc' is 'thumbv7k-apple-watchos5.0.0' whereas 'out' is 'aarch64_32-apple-watchos5.0.0'
Kotlin 1.7.20-Beta with macOS 13 (22A5331f) and Xcode 14.0 beta 6 (14A5294g)darkmoon_uk
09/07/2022, 12:49 PMfloat
representation to a Kotlin ByteArray
?darkmoon_uk
09/07/2022, 12:50 PMByteArray
since I need to do this very often (preparing data for a shader).Adam Cooper
09/07/2022, 9:30 PMusePinned
works in terms of C code? I am wondering why it is necessary, or perhaps if I am misusing it. If I am misusing it, then I would like to know what situations it should be used in. The way I have used it is similar to this:
// declare a 256 byte array to pass to a C function as an output parameter
UByteArray(SHA256_DIGEST_LENGTH).usePinned { signatureBuf ->
c_func(signatureBuf.addressOf(0))
}
My understanding of the equivalent of this in C:
unsigned char signatureBuf[SHA256_DIGEST_LENGTH];
c_func(signatureBuf);
c_func
computes some value and stores it in the address provided by its parameter. This is a simplistic example and obv not good code. Just want to show my understanding of it.Adam Cooper
09/08/2022, 12:28 AMzt
09/09/2022, 3:38 AMe: Could not find 'main' in '<root>' package.
when trying to build either of the modules in my project. I've set up the gradle config like this
linuxX64("native") {
binaries {
executable("prism")
}
}
Paddy O'Brien
09/14/2022, 8:11 PMswift_name
attribute when generating the Objective-C header? Upgrading to Apollo 3 and Codegen is now resulting in a scalar whose name is URL
which of course is resulting in name conflicts when importing the framework into swift, Been bitten by this before, just wondering if theres a way that doesn’t involve changing swift code to accommodate changes in the Kotlin envPaddy O'Brien
09/14/2022, 8:15 PMkevin.cianfarini
09/16/2022, 8:36 PMArrays of value types should be packed, without indirections, as arrays of primitives are now.Since Kotlin has separate, specialized, types for each primitive value how does this bode for value classes on Native? I imagine that
Array<MyValueClass>
would be boxed unless the compiler/runtime were doing some magic I’m unaware of.Adam Cooper
09/17/2022, 6:23 AM/usr/lib
and /usr/include
. My program is able to build just fine on this distro.
I'm trying to build on Ubuntu, which uses {/usr/lib,/usr/include}/x86_64-linux-gnu
. I have my compiler options defined in a .def:
compilerOpts.linux = -I/usr/include -I/usr/include/x86_64-linux-gnu
linkerOpts.linux = -L /usr/lib -L/usr/lib/x86_64-linux-gnu -lpthread -lssl -lcrypto
My executable is defined in build.gradle.kts
as follows:
binaries {
executable {
// Use system C libraries
val sysRoot = "/"
val libgccRoot = File("/lib/gcc/x86_64-linux-gnu/").takeIf { it.exists() }
?: File("/lib/gcc/x86_64-pc-linux-gnu/")
// Use the most recent GCC available on the host
val libgccPath = file("${libgccRoot.absolutePath}/${libgccRoot.list()!!.last()}")
val overriddenProperties =
"targetSysRoot.linux_x64=$sysRoot;libGcc.linux_x64=$libgccPath"
val compilerArgs = "-Xoverride-konan-properties=$overriddenProperties"
this.freeCompilerArgs += listOf(compilerArgs)
this.entryPoint = "opstopus.deploptopus.main"
this@binaries.findTest("debug")?.let { it.freeCompilerArgs += listOf(compilerArgs) }
}
}
On Ubuntu, I consistently get this error:
/root/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold: error: cannot open //usr/lib/crt1.o: No such file or directory
/root/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold: error: cannot open //usr/lib/crti.o: No such file or directory
/root/.konan/dependencies/x86_64-unknown-linux-gnu-gcc-8.3.0-glibc-2.19-kernel-4.9-2/x86_64-unknown-linux-gnu/bin/ld.gold: error: cannot open //usr/lib/crtn.o: No such file or directory
I confirmed that all 3 of these object files are in /usr/lib/x86_64-linux-gnu
on Ubuntu. Why is it only searching in /usr/lib
?Jonas TM
09/17/2022, 10:28 AMJeff Lockhart
09/18/2022, 12:37 AMTo get the pointer,should be allocated in native memory, e.g..cstr
Butval cString = kotlinString.cstr.getPointer(nativeHeap)
getPointer()
accepts an AutofreeScope
parameter, which nativeHeap
doesn't fulfill. Seems like it should be accepting a NativePlacement
instead. (Maybe it used to?)
Is there a more concise/idiomatic way to copy a Kotlin string to the native heap than something like this?
val string = "my kotlin string"
val bytes = string.encodeToByteArray()
val cPtr = nativeHeap.allocArray<ByteVar>(bytes.size + 1)
bytes.usePinned {
memcpy(cPtr, it.addressOf(0), bytes.size.convert())
}
napperley
09/19/2022, 1:35 AMJeff Lockhart
09/21/2022, 1:26 AMCValuesRef<*>
)?
My API requires passing an arbitrary Kotlin lambda to a C library as a C function pointer. My understanding is that staticCFunction()
would not be able to capture the lambda to call inside it: staticCFunction { ~lambda()~ }
. I am able to have a context passed to the C Function as a COpaquePointer
though. I could have the lambda passed as this context parameter, if there would be a way to get a reference to it as a C pointer.martmists
09/21/2022, 3:11 PMJeff Lockhart
09/22/2022, 9:03 PM[]
only available for CPointer<ByteVar>
? The docs seem to imply it should be possible for any CPointer<T>
, but I only see the extension available for CPointer<ByteVar>
(the docs show CPointer<BytePtr>
in the example code). Do I have to reinterpret<ByteVar>()
in order to iterate an array of a different pointer type?Phạm Nhật
09/23/2022, 6:55 AMRihards
09/26/2022, 10:37 AMonBindViewHolder
they are zero.Alexandre Brown
09/27/2022, 2:10 PMKrystian
09/28/2022, 9:26 PMPablo
09/29/2022, 11:48 AMspierce7
09/29/2022, 3:27 PMspierce7
09/29/2022, 3:27 PMJeff Lockhart
09/30/2022, 2:08 AMribesg
09/30/2022, 8:53 AMVARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL
still meaningful with the NMM or not?Krystian
10/01/2022, 6:00 PMTrevor Stone
10/03/2022, 9:03 PMKatarzyna
10/06/2022, 8:31 AMKrystian
10/08/2022, 10:41 AMJeff Lockhart
10/11/2022, 6:19 PMstaticCFunction
called from C code. On Windows, the exception is propagated and I can catch it in Kotlin with a try/catch surrounding the call to the C code that calls the staticCFunction
. But on Linux, this exception is instead caught by the underlying C code and returned in the error code from the C function as an "unknown C++ exception".
I'm trying to determine if this difference in behavior is due to Kotlin/Native, the C library, or possibly the GCC/MinGW compilers. I'd like to have access to the original exception to keep the behavior consistent between the two platforms. Is there a difference between the way Kotlin/Native exceptions behave on Windows vs Linux?Jeff Lockhart
10/11/2022, 6:19 PMstaticCFunction
called from C code. On Windows, the exception is propagated and I can catch it in Kotlin with a try/catch surrounding the call to the C code that calls the staticCFunction
. But on Linux, this exception is instead caught by the underlying C code and returned in the error code from the C function as an "unknown C++ exception".
I'm trying to determine if this difference in behavior is due to Kotlin/Native, the C library, or possibly the GCC/MinGW compilers. I'd like to have access to the original exception to keep the behavior consistent between the two platforms. Is there a difference between the way Kotlin/Native exceptions behave on Windows vs Linux?staticCFunction
and save a global reference to a caught exception from within the staticCFunction
to then access from outside the call if the "unknown C++ exception" error is encountered.