dc8186cb83
By default, C functions compiled to bitcode by clang have the nounwind attribute. If such functions throws an exception, the behaviour is undefined. Our interop machinery can process foreign exceptions on call sites (terminate or wrap them in Kotlin exceptions). But if the interop bridges have the nounwind attribute, LLVM optimizations (particularly inlining) may lead to the situation when a foreign exception is ignored by our foreign exception handler. This patch fixes the issue by compiling bridges with -fexceptions flag. This flag makes clang to not set the nounwind attribute, so exceptions can be thrown through C frames.
Kotlin-native interop
Usage
Create file ../gradle.properties with contents:
llvmInstallPath=/path/to/llvm
Create a Gradle subproject somewhere under ../, using ../InteropExample as a template.
To generate the interop stubs and libraries and build all sources you can run
the following command from ../:
./gradlew InteropExample:build
To run the example (if 'application' plugin is enabled):
./gradlew InteropExample:run