Build failure in jvmpkg

Hi, I’m currently trying to setup TVM RPC for Android on my mac (Big Sur, Apple M1 chip) but I’m failing to successfully run make jvmpkg. I am using Maven 3.6.0 and Oracle JDK 8. The exception is below

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for TVM4J Package - Parent 0.0.1-SNAPSHOT:
[INFO] 
[INFO] TVM4J Package - Parent ............................. SUCCESS [  2.050 s]
[INFO] TVM4J Package - Core ............................... SUCCESS [  9.302 s]
[INFO] TVM4J Package - Native Parent ...................... SUCCESS [  0.061 s]
[INFO] TVM4J Package - Native OSX-x86_64 .................. FAILURE [  0.242 s]
[INFO] TVM4J Package - Full Parent ........................ SKIPPED
[INFO] TVM4J Package - Full OSX-x86_64 .................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.346 s
[INFO] Finished at: 2021-04-21T15:29:50-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:javah (javah) on project libtvm4j-osx-x86_64: Error running javah command: Error executing command line. Exit code:1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:native-maven-plugin:1.0-alpha-7:javah (javah) on project libtvm4j-osx-x86_64: Error running javah command
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error running javah command
    at org.codehaus.mojo.natives.plugin.NativeJavahMojo.execute (NativeJavahMojo.java:183)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.codehaus.mojo.natives.NativeBuildException: Error executing command line. Exit code:1
    at org.codehaus.mojo.natives.util.CommandLineUtil.execute (CommandLineUtil.java:34)
    at org.codehaus.mojo.natives.javah.JavahExecutable.compile (JavahExecutable.java:46)
    at org.codehaus.mojo.natives.plugin.NativeJavahMojo.execute (NativeJavahMojo.java:179)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:567)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[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
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :libtvm4j-osx-x86_64
make: *** [jvmpkg] Error 1

And a potentially useful info in the logs is

[INFO] /bin/sh -c cd /Users/emazuh/gitdir/tvm/jvm/native/osx-x86_64 && c++ -shared -o/Users/emazuh/gitdir/tvm/jvm/native/osx-x86_64/target/libtvm4j-osx-x86_64.jnilib target/objs/org_apache_tvm_native_c_api.o -framework JavaVM '-Wl,-exported_symbol,_Java_*' -undefined dynamic_lookup -Wl,-x
ld: framework not found JavaVM

Does anyone have pointers on how to debug this?

1 Like

Hi Emma,

did you find a solution yet?

I am currently experiencing the same problem…

Thanks in advance

Not yet actually… still waiting for a response.

1 Like

maybe try this? I don’t really know how maven works but perhaps updating jvm/native/osx-x86_64/pom.xml would solve this problem. feel free to send a PR if this can be done in a generic/cross-platform way!

https://stackoverflow.com/questions/64844595/javacpp-builds-failing-on-macos-after-xcode-12-2-update-due-to-missing-javavm-fr

I found a workaround by going back to a really old version of the OpenJDK and redoing everything.

The problem seems to be the “javah” command that would be required by the codehaus module during the build process. javah has been deprecated and removed from the JDK a while ago.

Edit: According to this documentation piece Oracle Docs Oracle JDK 8 should be fine. But your error was the same as mine with Kubuntu 20.04 LTS and a newer openJDK version

" You can safely replace -framework JavaVM with -framework JavaNativeFoundation" This worked. @areusch will I need to add some conditional in the pom.xml since I’m not sure if JavaNativeFoundation will work for other environments?

cc @yzhliu who may know more about the jvm bindings