Hi, I’m trying to link a Rust MinGW static library to a Kotlin/Native MinGW library on macOS. I’m using Rust 1.75 with Kotlin 1.9.21.
I encounter a linker error like the following:
e: /Users/paxbun/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/clang++ invocation reported errors
The /Users/paxbun/.konan/dependencies/apple-llvm-20200714-macos-aarch64-essentials/bin/clang++ command returned non-zero exit code: 1.
output:
lld-link: warning: ignoring unknown argument: -exclude-symbols:___chkstk_ms
lld-link: error: -exclude-symbols:___chkstk_ms is not allowed in .drectve
clang-11: error: linker command failed with exit code 1 (use -v to see invocation)
FAILURE: Build failed with an exception.
and it seems that the flag was added in Clang 16 and then ported to Clang 15.
I want to use K/N with Clang 16, which is installed on my machine. Is there any way to use a user-specified version of Clang when using K/N?
Overriding the Konan linker.<host>-<target> option did work. Issue resolved!
BTW, building my own version of LLVM did not work, as Gradle crashes while running linkDebugExecutableMingwX64. It seems linkDebugExecutableMingwX64 runs the compiler within the Gradle process (so it calls a shared library, I assume), and the crash occurs inside the shared library, which is why Gradle just terminates without any Java exception. Maybe using a different LLVM version entirely is incompatible with the Kotlin Gradle plugin.