spring-graalvm-native-plugin
spring-graalvm-native-plugin copied to clipboard
BuildNativeImage fails on /usr/bin/cc, error=17, File exists
I'd like to request help with analysis. It might be the reason in my setup or on Graalvm but I can't investigate by my one. I'd appreciate any clues.
- MacOS Cataline v. 10.15.6 (19G2021)
- graalvm 20.3.0
- com.github.ayltai.spring-graalvm-native-plugin:1.4.0
- org.springframework.experimental:spring-graalvm-native:0.8.2
plugin setup:
nativeImage {
mainClassName = 'io.github.artemptushkin.spintbootnative.SpintBootNativeHello'
reportExceptionStackTraces = true
removeUnusedAutoConfig = true
removeYamlSupport = true
maxHeapSize = '4G'
javaVersion = '8'
disableToolchainChecking = true
}
Steps:
./gradlew buildNativeImage
Result:
Error: Unable to compile C-ABI query code /var/folders/_s/7c1s7rts7xsbv1_r8pcdd6wm0000gn/T/SVM-8178873000820406083/LibFFIHeaderDirectives.c. Make sure native software development toolchain is installed on your system.
com.oracle.svm.core.util.UserError$UserException: Unable to compile C-ABI query code /var/folders/_s/7c1s7rts7xsbv1_r8pcdd6wm0000gn/T/SVM-8178873000820406083/LibFFIHeaderDirectives.c. Make sure native software development toolchain is installed on your system.
at com.oracle.svm.core.util.UserError.abort(UserError.java:82)
at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.compileAndParseError(CCompilerInvoker.java:452)
Error: Unable to compile C-ABI query code /var/folders/_s/7c1s7rts7xsbv1_r8pcdd6wm0000gn/T/SVM-8178873000820406083/LibFFIHeaderDirectives.c. Make sure native software development toolchain is installed on your system.
at com.oracle.svm.hosted.c.CAnnotationProcessor.compileQueryCode(CAnnotationProcessor.java:164)
at com.oracle.svm.hosted.c.CAnnotationProcessor.process(CAnnotationProcessor.java:112)
at com.oracle.svm.hosted.c.NativeLibraries.finish(NativeLibraries.java:540)
at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1574)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1056)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:874)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:556)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:471)
at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.io.IOException: Cannot run program "/usr/bin/cc" (in directory "/var/folders/_s/7c1s7rts7xsbv1_r8pcdd6wm0000gn/T/SVM-8178873000820406083"): error=17, File exists
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.compileAndParseError(CCompilerInvoker.java:426)
Caused by: java.io.IOException: Cannot run program "/usr/bin/cc" (in directory "/var/folders/_s/7c1s7rts7xsbv1_r8pcdd6wm0000gn/T/SVM-8178873000820406083"): error=17, File exists
... 13 more
Caused by: java.io.IOException: error=17, File exists
Caused by: java.io.IOException: error=17, File exists
I'm not sure what caused this error, but it says "Make sure native software development toolchain is installed on your system". So are you sure you have the native toolchain installed?
Reference: https://www.graalvm.org/reference-manual/native-image/
xcode-select --install
Yes, this is installed
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
There are a few similar issues reported: https://github.com/oracle/graal/issues?q=is%3Aissue+Unable+to+compile+C-ABI+query+code
The causes seem to be related to the OS setup or Java version. To troubleshoot, I would suggest either:
- Create a GitHub Action and build your project on a macOS image to isolate OS setup issue; or
- Share a minimal project that reproduces this error and I can run it on my mac. If there is no error, I can share information like my Java version that compiles successfully.
Did you make any progress?
Not really, I pretty sure that it is something wrong with my station...
Could you please try ./gradlew buildNativeImage
from https://github.com/artemptushkin/spring-boot-native-scale-zero ?
I tried to wipe some legacy Java version, check all the dependent libraries, and soft on my station - no result. I started debugging this, but same - can't see the file that exists
I got the same error executing your project with ./gradlew buildNativeImage
, so I think it is not related to the system configurations. I'll take a deeper look.
Found this: https://github.com/oracle/graal/issues/2845 Could be a bug in JDK that is fixed in JDK 14/15 but not 11.
I've been trying with 8.
I think I skipped that ticket as there a different error... Thanks - waiting for the bug fix I think.
I've been having the exact same error, although, my investigations I think are a bit different,
I have the tool chain installed, cause when I do
gcc --version
I get,
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin20.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
so as you see the installed dir is /Library/Developer/CommandLineTools/usr/bin
however as @artemptushkin's log shows (which exactly similar to mine, except we are trying to compile an internal source), it is looking for the files in /usr/bin/cc,
is this path mismatch a possible solution? I am not 100% convinced this is the root cause of the issue, but I felt like pointing it out :)
@codexetreme what have you changed? mine gcc --version
gives the same result, the same directory, but the error perists
I dowloaded, GraalVM from GitHub, 20.3.0, installed native-image on that , and compiled against that, it works ,
./native-image -cp picocli-4.5.2.jar --static -jar ~/mycode/build/ouptuts/cli-0.2.0-beta.0.0+20201207T212423Z.jar cli
this gets me a binary that I can run and execute
EDIT: yes, I am using this for picocli, so I am not sure if this gradle plugin correctly configured, but I highly doubt that to be the case
Thanks @codexetreme for building without this plugin so it does seem this is an issue with the command options generated by this plugin.
Could be the options issue? can you perhaps add an option to show what are the options generated, or something that gives better debug information? I tried the standard --info
and --stacktrace
but they aren't much help
should not, I see that Graalvm provides its own version of CC by the way
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home/languages/llvm/native/bin
ar graalvm-native-clang++ llvm-readelf
c++ graalvm-native-ld llvm-readobj
cc ld llvm-strip
clang ld.lld nm
clang++ ld64 objcopy
g++ lld objdump
gcc llvm-ar ranlib
graalvm-clang llvm-nm readelf
graalvm-clang++ llvm-objcopy readobj
graalvm-native-binutil llvm-objdump strip
graalvm-native-clang llvm-ranlib
but the running command use cc
from the machine
I add maven setup to my https://github.com/artemptushkin/spring-boot-native-scale-zero/tree/master
by the samples: from spring-graalvm-native and is working with ./mvnw -Pnative clean package
Logs are different. Part without JARs: Gradle:
Command: /Users/artemptushkin/JavaProjects/spint-boot-native-scale-zero/build/tmp/buildNativeImage/graalvm-ce-java11-20.3.0/Contents/Home/bin/native-image --allow-incomplete-classpath --report-unsupported-elements-at-runtime --no-fallback --no-server --install-exit-handlers -H:+ReportExceptionStackTraces -H:-CheckToolchain -Dspring.native.remove-unused-autoconfig=true -Dspring.native.remove-yaml-support=true -Dspring.native.remove-xml-support=false -Dspring.native.remove-spel-support=false -Dspring.native.remove-jmx-support=false -Dspring.native.verify=false -Dspring.native.verbose=false -Dspring.native.mode=reflection -J-Xmx4G -H:Name=spring-boot-native-scale-zero
Maven:
-Dspring.native.remove-yaml-support=true -Dspring.spel.ignore=true -H:Class=io.github.artemptushkin.springbootnativescalezero.SpringBootNativeScaleZeroApplication -H:Name=commandlinerunner
Maven calls directly from my JAVA_HOME:
/Library/Java/JavaVirtualMachines/graalvm-ce-java11-20.3.0/Contents/Home/bin/native-image -cp
and Gradle copies this into build
dir
it would be rational to check all the props from the Gradle run in Maven project but it is so slow, I checked these:
-Dspring.native.mode=reflection -H:+ReportExceptionStackTraces -H:-CheckToolchain
and it is okay
I tried installing GraalVM and native-image on the system, but not using this plugin. Change the working directory to <project root/build/native
, run native-image ...(arguments)
by copying and pasting the command using ./gradlew --debug buildNativeImage
), it will work.
So the problem is related to the locally cached copy of GraalVM and native-image.
I tried installing GraalVM and native-image on the system, but not using this plugin. Change the working directory to
<project root/build/native
, runnative-image ...(arguments)
by copying and pasting the command using./gradlew --debug buildNativeImage
), it will work.So the problem is related to the locally cached copy of GraalVM and native-image.
Or even easier, I installed GraalvM via Brew (also to PATH and JAVA_HOME) and added nativeImage { download = 'skip' ... }
It builds fine now...