scalameta / sbt-native-image

Plugin to generate native-image binaries with sbt
252 stars 22 forks source link

Support of LLVM backend #65

Open plokhotnyuk opened 1 year ago

plokhotnyuk commented 1 year ago

Describe the bug

The plugin should support compilation with LLVM backend

To Reproduce

  1. Clone the following repository: git clone --depth 1 https://github.com/plokhotnyuk/jsoniter-scala
  2. Enter to the examples project: cd jsoniter-scala/jsoniter-scala-examples
  3. Add "-H:CompilerBackend=llvm" to the sequence of nativeImageOptions in the build.sbt
  4. Run sbt jsoniter-scala-examplesJVM/nativeImage

Expected behavior

Successfully compiled native image

Current behavior

andriy@notebook:~/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples$ sbt jsoniter-scala-examplesJVM/nativeImage
[info] welcome to sbt 1.7.2 (Azul Systems, Inc. Java 17.0.5)
[info] loading global plugins from /home/andriy/.sbt/1.0/plugins
[info] loading settings for project jsoniter-scala-examples-build-build from sbt-updates.sbt ...
[info] loading project definition from /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/project/project
[info] loading settings for project jsoniter-scala-examples-build from plugins.sbt ...
[info] loading project definition from /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/project
[info] loading settings for project root from build.sbt ...
[info] set current project to root (in build file:/home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/)
[warn] there are 2 keys that are not used by any other settings/tasks:
[warn]  
[warn] * jsoniter-scala-examplesJVM / nativeImageJvm
[warn]   +- /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/build.sbt:27
[warn] * jsoniter-scala-examplesJVM / nativeImageVersion
[warn]   +- /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/build.sbt:26
[warn]  
[warn] note: a setting might still be used by a command; to exclude a key from this `lintUnused` check
[warn] either append it to `Global / excludeLintKeys` or call .withRank(KeyRanks.Invisible) on the key
[info] /home/andriy/.cache/coursier/jvm/graalvm-java17@22.3.0/bin/native-image -cp /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/.jvm/target/native-image-internal/manifest.jar --no-fallback --initialize-at-build-time --diagnostics-mode -H:CompilerBackend=llvm com.github.plokhotnyuk.jsoniter_scala.examples.Example01 /home/andriy/Projects/com/github/plokhotnyuk/jsoniter-scala/jsoniter-scala-examples/.jvm/target/native-image/jsoniter-scala-examples
# Diagnostics mode enabled: image-build reports are saved to reports/diagnostics_20230213_105957
Apply jar:file:///home/andriy/.cache/coursier/jvm/graalvm-java17@22.3.0/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties
Apply jar:file:///home/andriy/.cache/coursier/jvm/graalvm-java17@22.3.0/lib/svm/library-support.jar!/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties
# Printing command line arguments to: reports/diagnostics_20230213_105957/command-line_20230213_105957.txt
Error: Please install the LLVM backend for GraalVM Native Image via `$JAVA_HOME/bin/gu install native-image-llvm-backend`.
Error: Image build request failed with exit status 1
[error] native-image command failed with exit code '1'
[error] (jsoniter-scala-examplesJVM / nativeImage) native-image command failed with exit code '1'
[error] Total time: 2 s, completed Feb 13, 2023, 10:59:58 AM

Installation: