oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.38k stars 1.64k forks source link

Unable to build native image if using polyglot API and linking in GraalWasm #4324

Closed nirvdrum closed 2 years ago

nirvdrum commented 2 years ago

Describe the issue

I was looking to embed GraalWasm in a native application. The application also uses the polyglot API in Java to expose a @CEntryPoint using TruffleRuby to implement the logic of the method. Before I even called into the "wasm" language I ran into issues building the native image.

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

  1. git clone --depth 1 https://github.com/nirvdrum/native-image-wasm-issue
  2. cd native-image-wasm-issue
  3. mvn -P native-image -D skipTests=true package

Describe GraalVM and your environment:

More details Consider adding the --native-image-info and --verbose flags when building your native image and paste output below.

Add any other information about the problem here. Especially important are stack traces or log output. Feel free to link to gists or to screenshots if necessary.

native-image output ``` nirvdrum@Kevins-MacBook-Pro-2 ~/d/w/native-image-wasm-issue (main)> mvn -P native-image -D skipTests=true clean package [INFO] Scanning for projects... [INFO] [INFO] ----------< com.shopify.truffleruby:native-image-playground >----------- [INFO] Building native-image-playground 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ native-image-playground --- [INFO] Deleting /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target [INFO] [INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ native-image-playground --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/src/main/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ native-image-playground --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/classes [INFO] [INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ native-image-playground --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ native-image-playground --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ native-image-playground --- [INFO] Tests are skipped. [INFO] [INFO] --- native-maven-plugin:0.9.9:test (test-native) @ native-image-playground --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ native-image-playground --- [INFO] Building jar: /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground-1.0-SNAPSHOT.jar [INFO] [INFO] --- native-maven-plugin:0.9.9:build (build-native) @ native-image-playground --- [WARNING] Ignoring non-jar type ImageClasspath Entry org.graalvm.nativeimage:library-support:maven-plugin:22.0.0:compile [INFO] ImageClasspath Entry: org.graalvm.sdk:graal-sdk:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar) [WARNING] jar:file:///Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar!/META-INF/native-image/org.graalvm.polyglot/native-image.properties does not match recommended META-INF/native-image/${groupId}/${artifactId}/native-image.properties layout. [WARNING] jar:file:///Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar!/META-INF/native-image/org.graalvm.home/native-image.properties does not match recommended META-INF/native-image/${groupId}/${artifactId}/native-image.properties layout. [INFO] ImageClasspath Entry: org.graalvm.nativeimage:svm:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/svm/22.0.0/svm-22.0.0.jar) [INFO] ImageClasspath Entry: org.graalvm.nativeimage:objectfile:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/objectfile/22.0.0/objectfile-22.0.0.jar) [INFO] ImageClasspath Entry: org.graalvm.nativeimage:pointsto:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/pointsto/22.0.0/pointsto-22.0.0.jar) [INFO] ImageClasspath Entry: org.graalvm.compiler:compiler:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/compiler/compiler/22.0.0/compiler-22.0.0.jar) [INFO] ImageClasspath Entry: org.graalvm.truffle:truffle-api:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/truffle/truffle-api/22.0.0/truffle-api-22.0.0.jar) [INFO] ImageClasspath Entry: org.graalvm.nativeimage:native-image-base:jar:22.0.0:compile (file:///Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/native-image-base/22.0.0/native-image-base-22.0.0.jar) [INFO] ImageClasspath Entry: org.apache.sis.core:sis-referencing:jar:1.0:compile (file:///Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-referencing-1.0.jar) [INFO] ImageClasspath Entry: org.apache.sis.core:sis-utility:jar:1.0:compile (file:///Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/sis-utility-1.0.jar) [INFO] ImageClasspath Entry: org.apache.sis.core:sis-metadata:jar:1.0:compile (file:///Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/sis-metadata-1.0.jar) [INFO] ImageClasspath Entry: javax.measure:unit-api:jar:1.0:compile (file:///Users/nirvdrum/.m2/repository/javax/measure/unit-api/1.0/unit-api-1.0.jar) [INFO] ImageClasspath Entry: org.opengis:geoapi:jar:3.0.1:compile (file:///Users/nirvdrum/.m2/repository/org/opengis/geoapi/3.0.1/geoapi-3.0.1.jar) [INFO] ImageClasspath Entry: com.shopify.truffleruby:native-image-playground:jar:1.0-SNAPSHOT (file:///Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground-1.0-SNAPSHOT.jar) [INFO] Executing: /Users/nirvdrum/.sdkman/candidates/java/current/bin/native-image -cp /Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/svm/22.0.0/svm-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/objectfile/22.0.0/objectfile-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/pointsto/22.0.0/pointsto-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/compiler/compiler/22.0.0/compiler-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/truffle/truffle-api/22.0.0/truffle-api-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/native-image-base/22.0.0/native-image-base-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-referencing-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/sis-utility-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/sis-metadata-1.0.jar:/Users/nirvdrum/.m2/repository/javax/measure/unit-api/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/opengis/geoapi/3.0.1/geoapi-3.0.1.jar:/Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground-1.0-SNAPSHOT.jar --language:js --language:wasm --native-image-info --verbose -H:Class=com.shopify.truffleruby.NativeImage -H:Name=native-image-playground Executing [ /Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/bin/java \ -XX:+UseParallelGC \ -XX:+UnlockExperimentalVMOptions \ -XX:+EnableJVMCI \ -Dtruffle.TrustAllTruffleRuntimeProviders=true \ -Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime \ -Dgraalvm.ForcePolyglotInvalid=true \ -Dgraalvm.locatorDisabled=true \ -Dsubstratevm.IgnoreGraalVersionCheck=true \ --add-exports=java.base/com.sun.crypto.provider=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.access.foreign=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.event=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.loader=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.logger=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.module=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.org.xml.sax.helpers=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.perf=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.platform=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.util.xml.impl=ALL-UNNAMED \ --add-exports=java.base/jdk.internal.util.xml=ALL-UNNAMED \ --add-exports=java.base/sun.invoke.util=ALL-UNNAMED \ --add-exports=java.base/sun.net=ALL-UNNAMED \ --add-exports=java.base/sun.nio.ch=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.generics.repository=ALL-UNNAMED \ --add-exports=java.base/sun.reflect.generics.tree=ALL-UNNAMED \ --add-exports=java.base/sun.security.jca=ALL-UNNAMED \ --add-exports=java.base/sun.security.provider=ALL-UNNAMED \ --add-exports=java.base/sun.security.ssl=ALL-UNNAMED \ --add-exports=java.base/sun.security.util=ALL-UNNAMED \ --add-exports=java.base/sun.text.spi=ALL-UNNAMED \ --add-exports=java.base/sun.util.calendar=ALL-UNNAMED \ --add-exports=java.base/sun.util.locale.provider=ALL-UNNAMED \ --add-exports=java.base/sun.util.resources=ALL-UNNAMED \ --add-exports=java.management/sun.management=ALL-UNNAMED \ --add-exports=java.xml.crypto/org.jcp.xml.dsig.internal.dom=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.aarch64=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.amd64=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.site=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code.stack=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.common=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.aarch64=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot.amd64=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.meta=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.runtime=ALL-UNNAMED \ --add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED \ --add-exports=jdk.jfr/jdk.jfr.events=ALL-UNNAMED \ --add-exports=jdk.jfr/jdk.jfr.internal.consumer=ALL-UNNAMED \ --add-exports=jdk.jfr/jdk.jfr.internal.handlers=ALL-UNNAMED \ --add-exports=jdk.jfr/jdk.jfr.internal.jfc=ALL-UNNAMED \ --add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED \ -XX:+UseJVMCINativeLibrary \ -Xss10m \ -Xms1g \ -Djava.awt.headless=true \ -Dorg.graalvm.version=22.0.0.2 \ -Dorg.graalvm.config=CE \ -Dcom.oracle.graalvm.isaot=true \ -Djava.system.class.loader=com.oracle.svm.hosted.NativeImageSystemClassLoader \ -Xshare:off \ -Dtruffle.TruffleRuntime=com.oracle.svm.truffle.api.SubstrateTruffleRuntime \ -Dgraalvm.ForcePolyglotInvalid=false \ -Dpolyglot.image-build-time.PreinitializeContexts=js \ -Djdk.internal.lambda.disableEagerInitialization=true \ -Djdk.internal.lambda.eagerlyInitialize=false \ -Djava.lang.invoke.InnerClassLambdaMetafactory.initializeLambdas=false \ -Xmx13743895344 \ -javaagent:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/svm.jar \ -cp \ /Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/llvm-wrapper-shadowed.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/svm.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/native-image-base.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/objectfile.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/llvm-platform-specific-shadowed.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/javacpp-shadowed.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/svm-llvm.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/builder/pointsto.jar \ --module-path \ /Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/truffle/truffle-api.jar \ 'com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus' \ -imagecp \ /Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-utility-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-metadata-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/geoapi-3.0.1.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/geoapi-3.0.1.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/sis-utility-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/geoapi-3.0.1.jar:/Users/nirvdrum/.m2/repository/org/opengis/geoapi/3.0.1/unit-api-1.0.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/languages/regex/tregex.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/languages/js/graaljs.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/languages/wasm/wasm.jar:/Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/svm/22.0.0/svm-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/objectfile/22.0.0/objectfile-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/pointsto/22.0.0/pointsto-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/compiler/compiler/22.0.0/compiler-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/truffle/truffle-api/22.0.0/truffle-api-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/native-image-base/22.0.0/native-image-base-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-referencing-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/sis-utility-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/sis-metadata-1.0.jar:/Users/nirvdrum/.m2/repository/javax/measure/unit-api/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/opengis/geoapi/3.0.1/geoapi-3.0.1.jar:/Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground-1.0-SNAPSHOT.jar:/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/library-support.jar \ -H:Path=/Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target \ '-H:ClassInitialization@jar:file:///Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar!/META-INF/native-image/org.graalvm.polyglot/native-image.properties=org.graalvm.polyglot:build_time' \ '-H:Features@jar:file:///Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar!/META-INF/native-image/org.graalvm.home/native-image.properties=org.graalvm.home.HomeFinderFeature' \ -H:Features@--macro:truffle=com.oracle.svm.truffle.TruffleFeature,com.oracle.svm.truffle.TruffleBaseFeature,org.graalvm.home.HomeFinderFeature \ -H:MaxRuntimeCompileMethods@--macro:truffle=2000 \ -H:ClassInitialization@--macro:truffle=org.graalvm.launcher:build_time,com.oracle.truffle:build_time,org.graalvm.nativebridge:build_time \ -H:MaxRuntimeCompileMethods@--language:regex=900 \ -H:MaxRuntimeCompileMethods@--language:js=9200 \ -H:ClassInitialization@--language:js=com.oracle.truffle.js:build_time,com.oracle.js.parser:build_time,com.oracle.truffle.regex:build_time \ -H:ClassInitialization@--language:js=com.ibm.icu:run_time \ -H:ReflectionConfigurationResources@--language:js=com/oracle/truffle/js/runtime/resources/reflect-config.json \ -H:ResourceConfigurationResources@--language:js=com/oracle/truffle/js/runtime/resources/resource-config.json \ -H:MaxRuntimeCompileMethods@--language:wasm=2000 \ -H:+DumpTargetInfo \ -H:Class=com.shopify.truffleruby.NativeImage \ -H:Name=native-image-playground \ -H:FallbackThreshold=0 \ -H:CLibraryPath=/Users/nirvdrum/.sdkman/candidates/java/22.0.0.2.r17-grl/lib/svm/clibraries/darwin-amd64 ] ======================================================================================================================== GraalVM Native Image: Generating 'native-image-playground'... ======================================================================================================================== [1/7] Initializing... (9.7s @ 0.20GB) Version info: 'GraalVM 22.0.0.2 Java 17 CE' # Printing compilation-target information to: /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/reports/target_info_20220215_102252.txt [2/7] Performing analysis... [*] (56.5s @ 1.57GB) To see how the classes got initialized, use --trace-class-initialization=org.graalvm.wasm.WasmInstanceGen,org.graalvm.wasm.api.SequenceGen,org.graalvm.wasm.api.DictionaryGen,org.graalvm.wasm.WasmTypeGen,org.graalvm.wasm.exception.WasmExceptionGen,org.graalvm.wasm.WasmFunctionInstanceGen,org.graalvm.wasm.api.ExecutableGen,org.graalvm.wasm.api.ByteArrayBufferGen,org.graalvm.wasm.WasmVoidResultGen,org.graalvm.wasm.memory.WasmMemoryGen 14,206 (96.34%) of 14,745 classes reachable 24,128 (69.04%) of 34,947 fields reachable 75,806 (84.70%) of 89,498 methods reachable 84 classes, 6 fields, and 527 methods registered for reflection Error: Classes that should be initialized at run time got initialized during image building: org.graalvm.wasm.WasmInstanceGen was unintentionally initialized at build time. To see why org.graalvm.wasm.WasmInstanceGen got initialized use --trace-class-initialization=org.graalvm.wasm.WasmInstanceGen org.graalvm.wasm.api.SequenceGen was unintentionally initialized at build time. To see why org.graalvm.wasm.api.SequenceGen got initialized use --trace-class-initialization=org.graalvm.wasm.api.SequenceGen org.graalvm.wasm.api.DictionaryGen was unintentionally initialized at build time. To see why org.graalvm.wasm.api.DictionaryGen got initialized use --trace-class-initialization=org.graalvm.wasm.api.DictionaryGen org.graalvm.wasm.WasmTypeGen was unintentionally initialized at build time. To see why org.graalvm.wasm.WasmTypeGen got initialized use --trace-class-initialization=org.graalvm.wasm.WasmTypeGen org.graalvm.wasm.exception.WasmExceptionGen was unintentionally initialized at build time. To see why org.graalvm.wasm.exception.WasmExceptionGen got initialized use --trace-class-initialization=org.graalvm.wasm.exception.WasmExceptionGen org.graalvm.wasm.WasmFunctionInstanceGen was unintentionally initialized at build time. To see why org.graalvm.wasm.WasmFunctionInstanceGen got initialized use --trace-class-initialization=org.graalvm.wasm.WasmFunctionInstanceGen org.graalvm.wasm.api.ExecutableGen was unintentionally initialized at build time. To see why org.graalvm.wasm.api.ExecutableGen got initialized use --trace-class-initialization=org.graalvm.wasm.api.ExecutableGen org.graalvm.wasm.api.ByteArrayBufferGen was unintentionally initialized at build time. To see why org.graalvm.wasm.api.ByteArrayBufferGen got initialized use --trace-class-initialization=org.graalvm.wasm.api.ByteArrayBufferGen org.graalvm.wasm.WasmVoidResultGen was unintentionally initialized at build time. To see why org.graalvm.wasm.WasmVoidResultGen got initialized use --trace-class-initialization=org.graalvm.wasm.WasmVoidResultGen org.graalvm.wasm.memory.WasmMemoryGen was unintentionally initialized at build time. To see why org.graalvm.wasm.memory.WasmMemoryGen got initialized use --trace-class-initialization=org.graalvm.wasm.memory.WasmMemoryGen Error: Use -H:+ReportExceptionStackTraces to print stacktrace of underlying exception ------------------------------------------------------------------------------------------------------------------------ 4.5s (6.4% of total time) in 26 GCs | Peak RSS: 3.57GB | CPU load: 3.23 ------------------------------------------------------------------------------------------------------------------------ Produced artifacts: /Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground.build_artifacts.txt ======================================================================================================================== Failed generating 'native-image-playground' after 1m 8s. 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:1770) at com.oracle.svm.driver.NativeImage.build(NativeImage.java:1477) at com.oracle.svm.driver.NativeImage.performBuild(NativeImage.java:1438) at com.oracle.svm.driver.NativeImage.main(NativeImage.java:1425) [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:14 min [INFO] Finished at: 2022-02-15T10:23:50-05:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.graalvm.buildtools:native-maven-plugin:0.9.9:build (build-native) on project native-image-playground: Execution of /Users/nirvdrum/.sdkman/candidates/java/current/bin/native-image -cp /Users/nirvdrum/.m2/repository/org/graalvm/sdk/graal-sdk/22.0.0/graal-sdk-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/svm/22.0.0/svm-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/objectfile/22.0.0/objectfile-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/pointsto/22.0.0/pointsto-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/compiler/compiler/22.0.0/compiler-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/truffle/truffle-api/22.0.0/truffle-api-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/graalvm/nativeimage/native-image-base/22.0.0/native-image-base-22.0.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-referencing/1.0/sis-referencing-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-utility/1.0/sis-utility-1.0.jar:/Users/nirvdrum/.m2/repository/org/apache/sis/core/sis-metadata/1.0/sis-metadata-1.0.jar:/Users/nirvdrum/.m2/repository/javax/measure/unit-api/1.0/unit-api-1.0.jar:/Users/nirvdrum/.m2/repository/org/opengis/geoapi/3.0.1/geoapi-3.0.1.jar:/Users/nirvdrum/dev/workspaces/native-image-wasm-issue/target/native-image-playground-1.0-SNAPSHOT.jar --language:js --language:wasm --native-image-info --verbose -H:Class=com.shopify.truffleruby.NativeImage -H:Name=native-image-playground 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 ```
gimbling-away commented 2 years ago

Duplicate of #4319

Did you add an IsolateThread parameter to functions you're exporting through CEntryPoint? Eg.

import org.graalvm.polyglot.*;
import org.graalvm.nativeimage.c.function.CEntryPoint;
import org.graalvm.nativeimage.IsolateThread;

class testing {
    @CEntryPoint(name = "x")
    public static void x(IsolateThread thread) { System.out.println("Hello, World!"); }

    public static void main(String[] args) {}
}
gimbling-away commented 2 years ago

image Yes by the code -- it does look like that the lack of the IsolateThread parameter is causing the error.

There should be a dedicated error message added (again?) to Native image with #4322

nirvdrum commented 2 years ago

@Yush08 Thanks for catching that. I indeed forgot the IsolateThread in this reproduction. But, I'm seeing the issue with a larger project that works just fine before adding the --language:wasm. I've fixed the missing parameter issue and updated the log message in the issue description.

eregon commented 2 years ago

This sounds to me like WASM not properly setting --initialize-at-build-time=, and indeed WASM seems to not set it at all currently: https://github.com/oracle/graal/blob/master/wasm/mx.wasm/native-image.properties compare to: https://github.com/oracle/graaljs/blob/master/graal-js/mx.graal-js/native-image.properties

cc @axel22

axel22 commented 2 years ago

Thanks for the report, seems indeed that this should be fixed.

eregon commented 2 years ago

Fixed by Florian Huemer in https://github.com/oracle/graal/commit/fbb079804fd55ceacde4f75a77fe553f401306c0