Describe the issue
Attempting to build a native image creates:
Error: Unable to compile C-ABI query code. 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. Make sure native software development toolchain is installed on your system.
Steps to reproduce the issue
Please include both build steps as well as run steps
git clone https://github.com/apereo/cas-overlay-template overlay
cd overlay
git checkout graal
./gradlew buildNativeImage
Describe GraalVM and your environment:
Gradle 6.6.1
Spring Boot 2.3.3
GraalVM EE 20.2.0 (build 11.0.8.0.2+1-LTS-jvmci-20.2-b03)
MacOS Catalina 10.15.6
When I run: xcode-select --install, I get back xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Also,
/usr/bin/cc -v
Apple clang version 11.0.3 (clang-1103.0.32.62)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
More details
The project uses this plugin to build a native-image, based on Spring's plugin that provides experimental support for GraalVM.
nativeImage {
mainClassName = "org.apereo.cas.CasNativeWebApplication"
traceClassInitialization = true
reportExceptionStackTraces = true
removeUnusedAutoConfig = true
disableToolchainChecking = true
enableHttp = true
enableHttps = true
maxHeapSize = "4G"
verbose = true
javaVersion = project.targetCompatibility
}
Stacktrace:
Error: Unable to compile C-ABI query code. 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. Make sure native software development toolchain is installed on your system.
at com.oracle.svm.core.util.UserError.abort(UserError.java:79)
at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.compileAndParseError(CCompilerInvoker.java:430)
at com.oracle.svm.hosted.c.CAnnotationProcessor.compileQueryCode(CAnnotationProcessor.java:149)
at com.oracle.svm.hosted.c.CAnnotationProcessor.process(CAnnotationProcessor.java:97)
at com.oracle.svm.hosted.c.NativeLibraries.finish(NativeLibraries.java:526)
at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1539)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1036)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:868)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:553)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:468)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1407)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.io.IOException: Cannot run program "/usr/bin/cc" (in directory "/var/folders/wf/rcc_265x1ld1n8jh47bgmbqm0000gn/T/SVM-8097225211978132151"): error=0, posix_spawn failed
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
at com.oracle.svm.hosted.c.codegen.CCompilerInvoker.compileAndParseError(CCompilerInvoker.java:405)
... 14 more
Caused by: java.io.IOException: error=0, posix_spawn failed
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
... 16 more
Error: Image build request failed with exit status 1
com.oracle.svm.driver.NativeImage$NativeImageError: Image build request failed with exit status 1
at com.oracle.svm.driver.NativeImage.showError(NativeImage.java:1558)
at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1308)
at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1269)
at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1228)
at com.oracle.svm.driver.NativeImage$JDK9Plus.main(NativeImage.java:1740)
@mmoayyed As per my initial check, I can see that there is a bug reported in openjdk regarding posix_spawn failure, which is not yet back ported to Java 11
https://bugs.openjdk.java.net/browse/JDK-8223777
for the time being, I will check further and update you
Thanks much for the analysis. Looks like a fix will be available for 11.0.9, due for release on Oct 20th. I'll double check once the jdk release is available.
@mmoayyed So for now I am closing this ticket, Once you check and if the fix is not there,then you can reopen it
I still have the same issue on graal 20.3.0 which is based on OpenJDK 11.0.9
According to https://bugs.openjdk.java.net/browse/JDK-8223777 the fix is in JDK14 and 15 and there is a plan to backport it to JDK 11. This backport wasn't done yet since they are waiting until https://bugs.openjdk.java.net/browse/JDK-8226192 is fixed. That is currently not yet done.