https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
j

James Ward

03/25/2023, 5:16 PM
Anyone here a Nix fan & able to get Kotlin/Native linux builds working? Here is what I tried for my
shell.nix
Copy code
with import <nixpkgs> {};
mkShell {
  NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
    stdenv.cc.cc.lib
    zlib
    libclang.lib
  ];
  NIX_LD = lib.fileContents "${<http://stdenv.cc|stdenv.cc>}/nix-support/dynamic-linker";
}
Running:
Copy code
~/.konan/kotlin-native-prebuilt-linux-x86_64-1.8.10/bin/konanc main.kt
I get a working
program.kexe
but the konanc program crashes with:
Copy code
# V  [libjvm.so+0x58aeca]  AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<548964ul, G1BarrierSet>, (AccessInternal::BarrierType)0, 548964ul>::oop_access_barrier(void*, oopDesc*)+0x1a
n

napperley

03/27/2023, 2:24 AM
Do note that K/N doesn't support NixOS. K/N supports Ubuntu, Debian, and any Linux distro that uses Ubuntu or Debian as the base like Linux Mint ( https://linuxmint.com/ ) for example. I'm assuming that NixOS uses its own base. In that case K/N compiler won't work properly, which isn't surprising considering the issues you are encountering.
s

Steve Elliott

10/03/2023, 1:50 AM
Is it true that K/N (still) only supports linux distros based on Ubuntu or Debian? The documentation doesn't mention this: https://kotlinlang.org/docs/native-target-support.html#tier-1
c

CLOVIS

10/03/2023, 8:09 AM
I'm running K/N on ArchLinux without issues. Haven't tried other distros, but I don't see why it would make a difference?
p

Panayotis Katsaloulis

10/03/2023, 9:48 AM
I am using K/N on Arch Linux too with no practical issues. I did have some issues with linking, but when I added the
--allow-shlib-undefined
option, everything works perfectly.
e

Edoardo Luppi

10/03/2023, 3:43 PM
@Panayotis Katsaloulismaybe worth opening a YT issue?
n

napperley

10/03/2023, 9:04 PM
Some C libs require the
--allow-shlib-undefined
to be passed to the linker due to the way they are designed. This isn't an issue specific to Kotlin itself.
s

Steve Elliott

10/04/2023, 2:39 AM
I am using NixOS and am seeing the same issue that @James Ward mentioned earlier. NixOS is pretty unique so it's somewhat unsurprising things aren't working as expected, but I'm curious if there's any insight into the OpenJDK segfault.
83 Views