@@ -3,8 +3,9 @@ It uses the Bazel build system and contains two libraries: protowire and kgrpc.
33
44### Protowire
55
6- Is a thin layer over the CodedStream implementation of the C++ protobuf library.
7- To build (e.g. ios_arm64) run
6+ Is a thin layer over the CodedStream implementation of the C++ protobuf library.
7+ To build (e.g. ios_arm64) run
8+
89``` bash
910bazel build :protowire_fat --config=ios_arm64 --config=release
1011```
@@ -15,9 +16,10 @@ We are using the gRPC-core library, which already exports its API with a C ABI.
1516Therefore, the KgRPC library is almost empty primarily used for convenient functions
1617or API that is not exposed by the C API.
1718
18- Because the gRPC takes a while to build when compiling for multiple targets, we store
19+ Because the gRPC takes a while to build when compiling for multiple targets, we store
1920it as a prebuilt static (fat) in ` prebuilt-deps/grpc_fat ` .
2021The binary can be updated by running
22+
2123``` bash
2224./gradlew :grpc:grpc-core:buildDependencyCLibGrpc_fat_iosArm64
2325```
@@ -27,6 +29,32 @@ The binary can be updated by running
2729To produce K/N compatible static libraries, we use the Konan toolchain for compilation.
2830The Bazel toolchain is specified in ` toolchain/ ` and requires the user to specify the
2931` KONAN_HOME ` variable like
32+
3033``` bash
3134bazel build //:protowire --config=linux_arm64 --define=KONAN_HOME=$HOME /.konan/kotlin-native-prebuilt-macos-aarch64-2.2.10
32- ```
35+ ```
36+
37+ #### Upgrading the Kotlin Compiler Version
38+
39+ When we upgrade the project's Kotlin compiler version, compilation for Linux will fail.
40+ Bazel will throw an error like
41+
42+ ```
43+ [1,351 / 1,353] Compiling src/kgrpc.cpp; 1s darwin-sandbox
44+ ERROR: /Users/jozott/development/jetbrains/kotlinx-rpc/cinterop-c/BUILD.bazel:11:11: Compiling src/kgrpc.cpp failed: absolute path inclusion(s) found in rule '//:kgrpc_lib':
45+ the source file 'src/kgrpc.cpp' includes the following non-builtin files with absolute paths (if these are builtin files, make sure these paths are in your toolchain):
46+ /Users/jozott/development/jetbrains/kotlinx-rpc/cinterop-c/BUILD.bazel:11:11: Compiling src/kgrpc.cpp failed: absolute path inclusion(s) found in rule '//:kgrpc_lib':
47+
48+ /Users/jozott/.konan/dependencies/llvm-19-aarch64-macos-essentials-79/bin/clang ... -c src/kgrpc.cpp -o bazel-out/linux_arm64-opt/bin/_objs/kgrpc_lib/kgrpc.o
49+ '/Users/jozott/.konan/dependencies/llvm-19-aarch64-macos-essentials-79/lib/clang/19/include/stdbool.h'
50+ '/Users/jozott/.konan/dependencies/llvm-19-aarch64-macos-essentials-79/lib/clang/19/include/stdint.h'
51+ ...
52+ ```
53+
54+ To fix this, we need to adjust the clang built-in include paths defined in the ` toolchain/cc_toolchain_config.bzl ` file.
55+ In the case above, the path at ` cxx_builtin_include_directories ` must be replaced by
56+ ` deps + "llvm-19-aarch64-macos-essentials-79/lib/clang/19/include" ` .
57+ This must be done for aarch64 and x86_64 separately.
58+ The current LLVM toolchain bundle paths can be found in
59+ [ kotlin/kotlin-native/gradle.properties] ( https://github.com/JetBrains/kotlin/blob/master/kotlin-native/gradle.properties )
60+ of the Kotlin repository.
0 commit comments