I'm linking a c lib which succeeds at finding the ...
# kotlin-native
j
I'm linking a c lib which succeeds at finding the headers and satisfying the def linker requirements
-luring
and shows up as complete in the kotlin/idea compiled cinterop code. the exe compiles and runs but when it hits the liburing struct definition there should be a static const int size, but instead the exe bails with a cryptic error code. there are a number of glibc/kernel headers which are getting the job done until it gets to this missing constant.
n
What is the actual output of the program when running it via a Terminal (eg Gnome Terminal) instead of through Gradle?
You are probably running into a segmentation fault (usually associated with exit code 134 - https://en.wikipedia.org/wiki/Segmentation_fault ), which in that case would require examining memory usage and fixing memory management issues related to interacting with the C libraries.
j
that seems like it was the same as console output in terminal, though i would have to go back and look to be sure. i stashed that and started over for some extra practice. tbh i don't trust the liburing userspace library im using, when i write against the kernel headers alone it works, despite a larger surface area. i build my own kernel but the liburing is brought in through ubuntu bonus for extra corner cases in my conversion sed script.
Copy code
sed  --in-place --regexp-extended\
 -e 's,for\s*\((\w+\s+)(\w+)\s*=\s*(\w+)\;\s*\2.*<([^;]+)\;.*(\2?(\+\+)\2?).*\),for (\2/*as \1*/ in \3 until \4),'\
 -e 's,^\s*void\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2:Unit{,'\
 -e 's,^\s*(\w+_t)\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \2\3:\1{,'\
 -e 's,^\s*void\s*[*](\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2: CPointer<ByteVar> {,'\
 -e 's,^\s*int\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2:Int{,'\
 -e 's,^\s*long\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2:Long{,'\
 -e 's,^\s*const\s+char\s*[*]\s*(\w+)\s*(\(.*\))\s*\{\s*$,fun \1\2:String{,' \
 -e 's,(\s+|\W)void\s*\*\s*(\w+)(\W),\1\2:CPointer<ByteVar> \3,'\
 -e 's,struct\s+(\w+)\s*\*(\w+)(\s|\W),\2:CPointer<\1>\3,'\
 -e 's,(\s+|\W)const char\s*\*\s*(\w+)(\W),\1\2:String\3,'\
 -e 's,(\s+|\W)unsigned\s+int\s+(\w+)(\W),\1\2:UInt\3,'\
 -e 's,(\s+|\W)unsigned\s+long\s+(\w+)(\W),\1\2:ULong\3,'\
 -e 's,(\s+|\W)unsigned\s+char\s+(\w+)(\W),\1\2:UByte\3,'\
 -e 's,(\s+|\W)int\s+(\w+)(\W),\1\2:Int\3,'\
 -e 's,(\s+|\W)long\s+(\w+)(\W),\1\2:Long\3,'\
 -e 's,(\s+|\W)size_t\s+(\w+)(\W),\1\2:size_t\3,'\
 -e 's,(\s+|\W)char\s*\*\s*(\w+)(\W),\1\2:CPointer<ByteVar>\3,'\
 -e 's,struct\s+(\w+)\s*(\w+)(\s|\W),\2:\1\3,'\
 -e 's,([^&])\&\s*(\w+),\1\2.ptr,g'\
 -e 's,\s*(\w+)\s*[-][>]\s*(\w+), \1.pointed.\2 ,g'\
 -e 's,(\s+|\W)(\w+_t)\s+(\w+)(\W),\1\3:\2\4,g'\
 -e 's,switch(.*)[{]$,when \1 {,'\
 -e 's,case (.*):,\1 -> ,'\
 -e 's,(\w+)\s*[|]\s*(\w+), \1 or \2 ,g'\
  $@
tbh it hadn't occurred to me that this was an underlying exit code, I had attributed this to random kotlin native trivia i had yet to track down. good to know