https://kotlinlang.org logo
s

sdeleuze

02/15/2022, 8:42 AM
Hey, I try to build https://github.com/JetBrains/kotlin/tree/master/kotlin-native/tools/benchmarksAnalyzer and have not played with Kotlin/Native for a very long time so sorry if those are basic questions. When importing the project in IDEA, I had both
import platform.posix.*
and
import libcurl.*
in red (unresolved reference) in
kotlin/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin-native/org/jetbrains/analyzer/Utils.kt
. I found in Kotlin Native README that I had to run
./gradlew :kotlin-native:dist :kotlin-native:distPlatformLibs
at the root of the
kotlin
project to get
import platform.posix.*
resolving. This part is now fixed. But I am blocked for libcurl:
Copy code
> Task :compileNativeMainKotlinMetadata FAILED
e: /home/seb/playground/kotlin/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin-native/org/jetbrains/analyzer/Utils.kt: (10, 8): Unresolved reference: libcurl
I have libcurl installed (Archlinux) and headers are in
/usr/local/include
. I tried to modify the build to specify `compilerOpts '-I/usr/local/include'`:
Copy code
fromPreset(presets.linuxX64, 'linux') {
            compilations.main.cinterops {
                libcurl {
                    compilerOpts '-I/usr/local/include'
			        includeDirs.headerFilterOnly '/usr/include', '/usr/local/include'
                }
            }
        }
But still the same error. When I try to build the project with
gradle build
I get:
Copy code
> Task :compileNativeMainKotlinMetadata FAILED
e: /home/seb/playground/kotlin/kotlin-native/tools/benchmarksAnalyzer/src/main/kotlin-native/org/jetbrains/analyzer/Utils.kt: (10, 8): Unresolved reference: libcurl
The command
gradle cinteropLibcurlLinux
seems to run properly and invokes
cinterop -o /home/seb/playground/kotlin/kotlin-native/tools/benchmarksAnalyzer/build/classes/kotlin/linux/main/cinterop/benchmarksAnalyzer-cinterop-libcurl.klib -target linux_x64 -def /home/seb/playground/kotlin/kotlin-native/tools/benchmarksAnalyzer/src/nativeInterop/cinterop/libcurl.def -compiler-option -I/usr/local/include -Xmodule-name benchmarksAnalyzer-cinterop-libcurl
which seems to work fine. Could somebody point me to what I am missing to get libcurl resolving both in IDEA and with
gradle build
?
a

Artyom Degtyarev [JB]

02/15/2022, 8:48 AM
cc @Elena Lepilkina
From what I can tell, it looks like your project is set with correct compiler options, but not the linker ones.
e

Elena Lepilkina

02/15/2022, 9:00 AM
Hello! There are some problems now connected with HMPP. You can use flag as here https://github.com/JetBrains/kotlin/blob/rrn/lepilkina/macosArm64_benchs/kotlin-native/tools/benchmarksAnalyzer/gradle.properties#L3 (I haven't yet commited to master because I wanted to do some other changes in this branch) but pay attention that in this case you need full K/N bundle build (not only dist) or you can disable HMPP with
kotlin.mpp.hierarchicalStructureSupport=false
(in same file). Sorry for inconvenient state of this app in master branch, this will be fixed soon
Also if you need just binaries of these app, you can ignore failure of building metadata. Command
gradlew build --continue
will produce native executables
s

sdeleuze

02/15/2022, 9:14 AM
kotlin.mpp.hierarchicalStructureSupport=false
made the trick, thanks!
n

napperley

02/15/2022, 10:15 PM
Very surprising that HMPP doesn't work in this case since it is supposed to work with Kotlin Native programs that contain one or more Linux targets. My understanding is that HMPP works with Linux targets in a Kotlin Native program, but not with a Kotlin Native library although that should be resolved in the near future.
e

Elena Lepilkina

02/16/2022, 6:43 AM
HMPP works when adding
kotlin.mpp.enableCInteropCommonization=true
in this case. This is case of master branch and features are enabling step by step.
7 Views