Skip to content

There is no way to exclude the graal-sdk when building native image that include the truffle-api #7072

@linghengqian

Description

@linghengqian

Describe GraalVM and your environment :

  • GraalVM version or commit id if built from source: [e.g. 19.3] 17.0.7
  • CE or EE: [e.g.: CE] CE
  • JDK version: [e.g.: JDK8] JDK17
  • OS and OS Version: [e.g.: macOS Catalina] Ubuntu 22.04
  • Architecture: [e.g.: amd64] amd64
  • The output of java -Xinternalversion:
OpenJDK 64-Bit Server VM (17.0.7+7-jvmci-23.0-b12) for linux-amd64 JRE (17.0.7+7-jvmci-23.0-b12), built on May 31 2023 12:28:58 by "buildslave" with gcc 10.3.0

Have you verified this issue still happens when using the latest snapshot?
You can find snapshot builds here: https://github.com/graalvm/graalvm-ce-dev-builds/releases

  • No.

Describe the issue
A clear and concise description of the issue.

  • There is no way to exclude the graal-sdk when building native image that include the truffle-api.
  • According to [GR-40187] Dectect invalid use of SVM specific classes on image class- or module-path. #5232, graal-sdk.jar should be excluded from building Native Images, and adding buildArg with -H:+AllowDeprecatedBuilderClassesOnImageClasspath is only a temporary solution. If graal-sdk is excluded from truffle-api, this will cause the project to fail to compile.
        <dependency>
            <groupId>org.graalvm.truffle</groupId>
            <artifactId>truffle-api</artifactId>
            <version>23.0.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.graalvm.sdk</groupId>
                    <artifactId>graal-sdk</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Code snippet or code repository that reproduces the issue

**PASTE CODE/REPO HERE**

Steps to reproduce the issue
Please include both build steps as well as run steps

  1. Step one [e.g.: git clone --depth 1 https://git.myrepo.com/projectone ]
  2. Step two [e.g.: mvn clean package]
sudo apt install unzip zip curl sed -y
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install java 17.0.7-graalce
sudo apt-get install build-essential libz-dev zlib1g-dev -y
gu install espresso

git clone [email protected]:linghengqian/espresso-v2301-native-image-test.git
cd ./espresso-v2301-native-image-test/
./mvnw -PgenerateMetadata clean test native:metadata-copy
./mvnw -Pnative clean test

Expected behavior
A clear and concise description of what you expected to happen.

  • ./mvnw -PgenerateMetadata clean test native:metadata-copy did not execute with errors.

Additional context
Add any other context about the problem here. Specially important are stack traces or log output. Feel free to link to gists or to screenshots if necesary

  • Error Log appears when ./mvnw -PgenerateMetadata clean test native:metadata-copy.
Details
$ ./mvnw -PgenerateMetadata clean test native:metadata-copy
[INFO] Scanning for projects...
[INFO] Found GraalVM installation from JAVA_HOME variable.
[INFO] 
[INFO] -------------< com.lingh:espresso-v2301-native-image-test >-------------
[INFO] Building espresso-v2301-native-image-test 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ espresso-v2301-native-image-test ---
[INFO] Deleting /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ espresso-v2301-native-image-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ espresso-v2301-native-image-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ espresso-v2301-native-image-test ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ espresso-v2301-native-image-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/test-classes
[INFO] 
[INFO] --- maven-dependency-plugin:3.5.0:copy (copy) @ espresso-v2301-native-image-test ---
[INFO] Configured Artifact: org.apache.groovy:groovy:4.0.10:jar
[INFO] Copying groovy-4.0.10.jar to /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/classes/espresso-need-libs/groovy.jar
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0:test (default-test) @ espresso-v2301-native-image-test ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.lingh.EspressoInlineExpressionParserTest
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 206.099 s - in com.lingh.EspressoInlineExpressionParserTest
[INFO] 
[INFO] Results:
[INFO] 
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] 
[INFO] --- native-maven-plugin:0.9.23:merge-agent-files (test-native) @ espresso-v2301-native-image-test ---
[INFO] Merging agent 1 files into /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/native/agent-output/test
[INFO] 
[INFO] --- native-maven-plugin:0.9.23:test (test-native) @ espresso-v2301-native-image-test ---
[INFO] ====================
[INFO] Initializing project: espresso-v2301-native-image-test
[INFO] ====================
[WARNING] Properties file at 'jar:file:///home/linghengqian/.m2/repository/org/graalvm/truffle/truffle-api/23.0.1/truffle-api-23.0.1.jar!/META-INF/native-image/org.graalvm.shadowed.org.jcodings/native-image.properties' does not match the recommended 'META-INF/native-image/org.graalvm.truffle/truffle-api/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///home/linghengqian/.m2/repository/org/graalvm/sdk/graal-sdk/23.0.1/graal-sdk-23.0.1.jar!/META-INF/native-image/org.graalvm.polyglot/native-image.properties' does not match the recommended 'META-INF/native-image/org.graalvm.sdk/graal-sdk/native-image.properties' layout.
[WARNING] Properties file at 'jar:file:///home/linghengqian/.m2/repository/org/graalvm/sdk/graal-sdk/23.0.1/graal-sdk-23.0.1.jar!/META-INF/native-image/org.graalvm.home/native-image.properties' does not match the recommended 'META-INF/native-image/org.graalvm.sdk/graal-sdk/native-image.properties' layout.
[INFO] Executing: /home/linghengqian/.sdkman/candidates/java/current/bin/native-image -cp /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/classes:/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/test-classes:/home/linghengqian/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/home/linghengqian/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/home/linghengqian/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/home/linghengqian/.m2/repository/org/apache/groovy/groovy/4.0.10/groovy-4.0.10.jar:/home/linghengqian/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/home/linghengqian/.m2/repository/org/graalvm/truffle/truffle-api/23.0.1/truffle-api-23.0.1.jar:/home/linghengqian/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-engine/1.9.2/junit-platform-engine-1.9.2.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-commons/1.9.2/junit-platform-commons-1.9.2.jar:/home/linghengqian/.m2/repository/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter/5.9.2/junit-jupiter-5.9.2.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.2/junit-jupiter-engine-5.9.2.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.9.2/junit-jupiter-params-5.9.2.jar:/home/linghengqian/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/home/linghengqian/.m2/repository/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar:/home/linghengqian/.m2/repository/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar:/home/linghengqian/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.2/junit-jupiter-api-5.9.2.jar:/home/linghengqian/.m2/repository/org/graalvm/sdk/graal-sdk/23.0.1/graal-sdk-23.0.1.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/native-maven-plugin/0.9.23/native-maven-plugin-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/junit-platform-native/0.9.23/junit-platform-native-0.9.23.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-console/1.8.1/junit-platform-console-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-reporting/1.8.1/junit-platform-reporting-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.1/junit-platform-launcher-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/utils/0.9.23/utils-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.23/graalvm-reachability-metadata-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/junit-platform-native/0.9.23/junit-platform-native-0.9.23.jar --no-fallback -H:Path=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target -H:Name=native-tests -Djunit.platform.listeners.uid.tracking.output.dir=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/test-ids -H:Class=org.graalvm.junit.platform.NativeImageJUnitLauncher --features=org.graalvm.junit.platform.JUnitPlatformFeature -H:ConfigurationFileDirectories=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/native/agent-output/test -H:+AllowIncompleteClasspath
Error: Class-path entry file:///home/linghengqian/.m2/repository/org/graalvm/sdk/graal-sdk/23.0.1/graal-sdk-23.0.1.jar contains class com.oracle.svm.core.annotate.TargetElement. This class is part of the image builder itself (in jrt:/org.graalvm.sdk) and must not be passed via -cp. This can be caused by a fat-jar that illegally includes svm.jar (or graal-sdk.jar) due to its build-time dependency on it. As a workaround, -H:+AllowDeprecatedBuilderClassesOnImageClasspath allows turning this error into a warning. Note that this option is deprecated and will be removed in a future version.
Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:37 min
[INFO] Finished at: 2023-07-27T17:10:50+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.23:test (test-native) on project espresso-v2301-native-image-test: Execution of /home/linghengqian/.sdkman/candidates/java/current/bin/native-image -cp /home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/classes:/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/test-classes:/home/linghengqian/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/home/linghengqian/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:/home/linghengqian/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar:/home/linghengqian/.m2/repository/org/apache/groovy/groovy/4.0.10/groovy-4.0.10.jar:/home/linghengqian/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/home/linghengqian/.m2/repository/org/graalvm/truffle/truffle-api/23.0.1/truffle-api-23.0.1.jar:/home/linghengqian/.m2/repository/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-engine/1.9.2/junit-platform-engine-1.9.2.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-commons/1.9.2/junit-platform-commons-1.9.2.jar:/home/linghengqian/.m2/repository/com/google/errorprone/error_prone_annotations/2.3.4/error_prone_annotations-2.3.4.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter/5.9.2/junit-jupiter-5.9.2.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.9.2/junit-jupiter-engine-5.9.2.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.9.2/junit-jupiter-params-5.9.2.jar:/home/linghengqian/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar:/home/linghengqian/.m2/repository/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar:/home/linghengqian/.m2/repository/org/checkerframework/checker-qual/3.5.0/checker-qual-3.5.0.jar:/home/linghengqian/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.9.2/junit-jupiter-api-5.9.2.jar:/home/linghengqian/.m2/repository/org/graalvm/sdk/graal-sdk/23.0.1/graal-sdk-23.0.1.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/native-maven-plugin/0.9.23/native-maven-plugin-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/junit-platform-native/0.9.23/junit-platform-native-0.9.23.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-console/1.8.1/junit-platform-console-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-reporting/1.8.1/junit-platform-reporting-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-launcher/1.8.1/junit-platform-launcher-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-engine/1.8.1/junit-platform-engine-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/platform/junit-platform-commons/1.8.1/junit-platform-commons-1.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter/5.8.1/junit-jupiter-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.8.1/junit-jupiter-api-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-params/5.8.1/junit-jupiter-params-5.8.1.jar:/home/linghengqian/.m2/repository/org/junit/jupiter/junit-jupiter-engine/5.8.1/junit-jupiter-engine-5.8.1.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/utils/0.9.23/utils-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/graalvm-reachability-metadata/0.9.23/graalvm-reachability-metadata-0.9.23.jar:/home/linghengqian/.m2/repository/org/graalvm/buildtools/junit-platform-native/0.9.23/junit-platform-native-0.9.23.jar --no-fallback -H:Path=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target -H:Name=native-tests -Djunit.platform.listeners.uid.tracking.output.dir=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/test-ids -H:Class=org.graalvm.junit.platform.NativeImageJUnitLauncher --features=org.graalvm.junit.platform.JUnitPlatformFeature -H:ConfigurationFileDirectories=/home/linghengqian/TwinklingLiftWorks/git/public/espresso-v2301-native-image-test/target/native/agent-output/test -H:+AllowIncompleteClasspath returned non-zero result -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions