Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

native-image bash launcher reports different version than native binary #3313

Closed
jerboaa opened this issue Mar 26, 2021 · 6 comments
Closed

Comments

@jerboaa
Copy link
Collaborator

jerboaa commented Mar 26, 2021

Describe the issue
A recent master build from source, revision 3264554, produces different versions for bash launchers vs. a produced native via --macro:native-image-launcher.

Bash launcher:

$ native-image --version
11.0.9+10-jvmci-21.0-b02 (Java Version 11.0.9+10-jvmci-21.0-b02)

Native launcher:

$ native-image --version
GraalVM 21.1.0-dev Java 11 CE (Java Version 11.0.9+10-jvmci-21.0-b02)

Steps to reproduce the issue

  1. Produce a native image with a bash launcher:
$ mx --primary-suite substratevm --java-home $JAVA_HOME native-image HelloWorld
$./substratevm/svmbuild/vm/bin/native-image --version
11.0.9+10-jvmci-21.0-b02 (Java Version 11.0.9+10-jvmci-21.0-b02)
  1. Produce a native image binary for the launcher and try again
$ ./substratevm/svmbuild/vm/bin/native-image --macro:native-image-launcher
$./substratevm/svmbuild/vm/bin/native-image --version
[...]
GraalVM 21.1.0-dev Java 11 CE (Java Version 11.0.9+10-jvmci-21.0-b02)

Describe GraalVM and your environment:

  • GraalVM version: master revision 3264554
  • JDK major version: 11
  • OS: Linux
  • Architecture: x86_64

More details
This looks to be caused by bcf982c

@jerboaa
Copy link
Collaborator Author

jerboaa commented Mar 26, 2021

@olpaw Is this intentional? If so what's the recommendation to produce similar version output for bash launchers?

@olpaw
Copy link
Member

olpaw commented Mar 29, 2021

@olpaw Is this intentional? If so what's the recommendation to produce similar version output for bash launchers?

Yes. This is intentional. Only if you build a native-image image you will get reported GraalVM 21.1.0-dev Java 11 CE (Java Version 11.0.9+10-jvmci-21.0-b02) because that is what that image then actually is (the driver executable image produced by GraalVM 21.1.0-dev Java 11 CE). If you run the driver as an ordinary JVM application (i.e. via bash/cmd-launcher) it will now report running as such. See

String message = System.getProperty("java.vm.version");

@olpaw olpaw closed this as completed Mar 29, 2021
@jerboaa
Copy link
Collaborator Author

jerboaa commented Mar 29, 2021

OK, thanks!

@zakkak
Copy link
Collaborator

zakkak commented Mar 29, 2021

Yes. This is intentional. Only if you build a native-image image you will get reported GraalVM 21.1.0-dev Java 11 CE (Java Version 11.0.9+10-jvmci-21.0-b02) because that is what that image then actually is (the driver executable image produced by GraalVM 21.1.0-dev Java 11 CE). If you run the driver as an ordinary JVM application (i.e. via bash/cmd-launcher) it will now report running as such.

Hi @olpaw ,

I am still a bit confused about this. In the case of tha bash-launcher we have a bash script that starts the Java application com.oracle.svm.driver.NativeImage so passing --version to it should print the version of that application and not the version of the JVM (or at least not only that).
Furthermore, I would expect java MyApp --version to give the same result as native-image MyApp && myapp --version.

My understanding is that there is a need to differentiate the bash launcher from the native launcher through --version, but the current state breaks the Mandrel distribution which ships with a bash launcher instead of a native image and we thus need a way to get the version of the native-image from the bash launcher as well.

Now, I understand that the native image driver is part of GraalVM and thus it doesn't have its own version, but we could say that it inherits its version from the GraalVM distribution it is part of. In that sense would something like
native-image 21.1.0-dev (Java Version 11.0.9+10-jvmci-21.0-b02) make sense as the output of the bash launcher's --version?

Could you please re-open this issue or should we open a new one making this a feature request?

Thanks

@olpaw
Copy link
Member

olpaw commented Mar 29, 2021

We use System.getProperty("java.vm.version") because for us the driver is always shipped as image. The bash/cmd-launcher for us are only intermediate ways of using native-image (bootstrapping). If you need a custom --version output for your usecase of always running the driver via launcher please provide a PR that adds this. E.g. you could add something like

case "--version":
    args.poll();
    singleArgumentCheck(args, headArg);
    String message;
    if (NativeImage.IS_AOT) {
        message = System.getProperty("java.vm.version");
    } else {
        message = "native-image " + NativeImage.graalvmVersion;
    }
    String message = System.getProperty("java.vm.version");
    message += " (Java Version " + javaRuntimeVersion + ")";
    nativeImage.showMessage(message);
    System.exit(0);

@jerboaa
Copy link
Collaborator Author

jerboaa commented Apr 9, 2021

This has been addressed with #3329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants