Hi everyone. I'm facing cinterop issues when cross...
# kotlin-native
i
Hi everyone. I'm facing cinterop issues when cross-compiling
linux_arm64
on a
linux_x64
host. The cinterop task fails with
UnsatisfiedLinkError
looking for some newer version of glibc than exists on my host (full error in 🧵). I don't understand why it would be trying to use my host OS libs instead of the corresponding libs from the Konan distribution. 🤔 Anyone have experience debugging cinterops?
Full Gradle error output:
From what I can follow so far, the following things are happening: • Gradle task invokes my host's
java
binary, which is Corretto 16 x64. I'm not sure if that's what should be happening if it's trying to cross-compile for
linux_arm64
. 🤷‍♂️ • The Java program it runs is the K/N cli-runner from Konan's
kotlin-native-prebuilt-linux-x86_64-2.1.0
distribution. I think that's fine? • The cinterop generator tries to load libclang from Konan's
llvm-16.0.0-x86_64-linux-essentials-80
dependency. • That libclang requires libm which seems to be picked up from my host's
/lib64
which does not seem correct since I'd expect the cinterop/Konan work to be contained to files from the Konan distribution. • That libclang also requires
GLIBC_2.29
which my host doesn't have. The only version of libc I can find from Konan is in the
aarch64-unknown-linux-gnu-gcc-8.3.0-glibc-2.25-kernel-4.9-2
dependency but, as the name indicates, it's 2.25 not 2.29. This also seems incorrect since I'd expect the libclang to rely on a version of libc that's bundled with Konan. 😖
e
there's a difference between what libraries are necessary for running the compiler and running the binaries it produces
libclang is in the first category, and requires your host to be new enough. the glibc distributed with Konan is for (linking) the second category
i
Ah okay, that's a useful distinction. If libclang is distributed with the compiler (in
llvm-16.0.0-x86_64-linux-essentials-80
) then why isn't glibc also?