diff --git a/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java b/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java index c77da53676a4..8ee041fcad09 100644 --- a/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java +++ b/compiler/src/org.graalvm.compiler.truffle.runtime/src/org/graalvm/compiler/truffle/runtime/GraalTruffleRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -197,20 +197,15 @@ public boolean isLatestJVMCI() { @Override public String getName() { - String compilerConfigurationName = getCompilerConfigurationName(); - assert compilerConfigurationName != null; - String suffix; - if (compilerConfigurationName == null) { - suffix = "Unknown"; - } else if (compilerConfigurationName.equals("community")) { - suffix = "CE"; - } else if (compilerConfigurationName.equals("enterprise")) { - suffix = "EE"; - } else { - assert false : "unexpected compiler configuration name: " + compilerConfigurationName; - suffix = compilerConfigurationName; - } - return "GraalVM " + suffix; + String compilerConfigurationName = String.valueOf(getCompilerConfigurationName()); + return switch (compilerConfigurationName) { + case "community" -> "GraalVM CE"; + case "enterprise" -> "Oracle GraalVM"; + default -> { + assert false : "unexpected compiler configuration name: " + compilerConfigurationName; + yield "GraalVM " + compilerConfigurationName; + } + }; } /** diff --git a/docs/reference-manual/native-image/BuildOutput.md b/docs/reference-manual/native-image/BuildOutput.md index 110c0f6321ad..33709fd5507f 100644 --- a/docs/reference-manual/native-image/BuildOutput.md +++ b/docs/reference-manual/native-image/BuildOutput.md @@ -20,55 +20,55 @@ Below is the example output when building a native executable of the `HelloWorld ================================================================================ GraalVM Native Image: Generating 'helloworld' (executable)... ================================================================================ -[1/8] Initializing... (3.3s @ 0.25GB) - Version info: 'GraalVM dev Java 19+36-jvmci-23.0-b01 CE' - Java version info: '19+36-jvmci-23.0-b01' - Graal compiler: optimization level: '0', target machine: 'x86-64-v3' - C compiler: gcc (linux, x86_64, 11.3.0) +[1/8] Initializing... (3.3s @ 0.15GB) + Java version: 17.0.7+4, vendor: GraalVM Community + Graal compiler: optimization level: '2', target machine: 'x86-64-v3' + C compiler: gcc (linux, x86_64, 12.2.0) Garbage collector: Serial GC (max heap size: 80% of RAM) -[2/8] Performing analysis... [****] (6.2s @ 0.47GB) - 2,880 (71.50%) of 4,028 types reachable - 3,519 (51.06%) of 6,892 fields reachable - 13,339 (45.11%) of 29,570 methods reachable - 879 types, 0 fields, and 356 methods registered for reflection - 57 types, 56 fields, and 52 methods registered for JNI access +[2/8] Performing analysis... [***] (6.4s @ 0.83GB) + 2,905 (71.75%) of 4,049 types reachable + 3,534 (51.13%) of 6,912 fields reachable + 13,234 (43.97%) of 30,095 methods reachable + 901 types, 0 fields, and 344 methods registered for reflection + 58 types, 58 fields, and 52 methods registered for JNI access 4 native libraries: dl, pthread, rt, z -[3/8] Building universe... (1.1s @ 2.26GB) -[4/8] Parsing methods... [*] (1.0s @ 2.76GB) -[5/8] Inlining methods... [***] (0.8s @ 0.99GB) -[6/8] Compiling methods... [***] (6.4s @ 4.86GB) -[7/8] Layouting methods... [**] (4.2s @ 3.98GB) -[8/8] Creating image... [*] (4.0s @ 2.04GB) - 4.52MB (22.97%) for code area: 7,470 compilation units - 7.06MB (35.87%) for image heap: 101,764 objects and 5 resources - 7.52MB (38.24%) for debug info generated in 1.8s - 590.19KB ( 2.93%) for other data - 19.68MB in total +[3/8] Building universe... (1.2s @ 0.34GB) +[4/8] Parsing methods... [*] (0.8s @ 0.84GB) +[5/8] Inlining methods... [***] (0.5s @ 1.19GB) +[6/8] Compiling methods... [***] (5.6s @ 0.84GB) +[7/8] Layouting methods... [*] (1.1s @ 1.03GB) +[8/8] Creating image... [**] (3.9s @ 2.14GB) + 4.42MB (23.20%) for code area: 7,526 compilation units + 8.18MB (42.92%) for image heap: 107,049 objects and 5 resources + 5.87MB (30.78%) for debug info generated in 1.2s + 605.20KB ( 3.10%) for other data + 19.06MB in total -------------------------------------------------------------------------------- Top 10 origins of code area: Top 10 object types in image heap: - 3.43MB java.base 1.01MB byte[] for code metadata - 760.98KB svm.jar (Native Image) 1000.72KB java.lang.String - 102.06KB java.logging 884.18KB byte[] for general heap data - 48.03KB org.graalvm.nativeimage.base 686.91KB byte[] for java.lang.String - 40.49KB jdk.proxy1 659.87KB java.lang.Class - 38.23KB jdk.proxy3 247.50KB c.o.s.c.h.DynamicHubCompanion - 25.73KB jdk.internal.vm.ci 239.25KB java.lang.Object[] - 23.55KB org.graalvm.sdk 226.08KB java.util.HashMap$Node - 11.10KB jdk.proxy2 173.15KB java.lang.String[] - 8.10KB jdk.internal.vm.compiler 163.22KB j.u.c.ConcurrentHashMap$Node - 1.39KB for 2 more origins 1.70MB for 808 more object types + 3.37MB java.base 1008.75KB byte[] for code metadata + 792.12KB svm.jar (Native Image) 995.63KB java.lang.String + 112.32KB java.logging 887.47KB byte[] for general heap data + 62.07KB org.graalvm.nativeimage.base 685.47KB byte[] for java.lang.String + 24.15KB jdk.internal.vm.ci 670.38KB java.lang.Class + 23.14KB org.graalvm.sdk 490.13KB java.util.HashMap$Node + 6.11KB jdk.internal.vm.compiler 297.43KB byte[] for embedded resources + 1.35KB jdk.proxy1 249.65KB c.o.s.c.h.DynamicHubCompanion + 1.27KB jdk.proxy3 195.52KB java.util.HashMap$Node[] + 1.18KB jdk.localedata 171.84KB java.lang.String[] + 594.00B for 2 more packages 1.68MB for 824 more object types -------------------------------------------------------------------------------- Recommendations: HEAP: Set max heap for improved and more predictable memory usage. CPU: Enable more CPU features with '-march=native' for improved performance. -------------------------------------------------------------------------------- - 0.5s (1.8% of total time) in 24 GCs | Peak RSS: 5.62GB | CPU load: 8.92 + 0.5s (2.0% of total time) in 17 GCs | Peak RSS: 3.29GB | CPU load: 10.97 -------------------------------------------------------------------------------- Produced artifacts: - /home/janedoe/helloworld/helloworld (executable, debug_info) + /home/janedoe/helloworld/helloworld (executable) + /home/janedoe/helloworld/helloworld.debug (debug_info) /home/janedoe/helloworld/sources (debug_info) ================================================================================ -Finished generating 'helloworld' in 27.4s. +Finished generating 'helloworld' in 23.3s. ``` ## Build Stages @@ -79,14 +79,10 @@ In this stage, the Native Image build process is set up and [`Features`](https:/ #### Native Image Kind By default, Native Image generates *executables* but it can also generate [*native shared libraries*](InteropWithNativeCode.md) and [*static executables*](guides/build-static-and-mostly-static-executable.md). -#### Version Info -The version info of the Native Image process. -This string is also used for the `java.vm.version` property within the generated native binary. -Please report this version info when you [file issues](https://github.com/oracle/graal/issues/new). - -#### Java Version Info -The Java version info (`java.runtime.version` property) of the Native Image build process. -Please report this version info when you [file issues](https://github.com/oracle/graal/issues/new). +#### Java Version Info +The Java version and vendor of the Native Image process. +Both are also used for the `java.vm.version` and `java.vm.vendor` properties within the generated native binary. +Please report version and vendor when you [file issues](https://github.com/oracle/graal/issues/new). #### Graal Compiler The selected optimization level and targeted machine type used by the Graal compiler. diff --git a/docs/reference-manual/native-image/assets/build-output-schema-v0.9.1.json b/docs/reference-manual/native-image/assets/build-output-schema-v0.9.1.json index 161ba80c9c37..c3c2f01492e0 100644 --- a/docs/reference-manual/native-image/assets/build-output-schema-v0.9.1.json +++ b/docs/reference-manual/native-image/assets/build-output-schema-v0.9.1.json @@ -19,6 +19,7 @@ "name", "graalvm_version", "java_version", + "vendor", "graal_compiler", "c_compiler", "garbage_collector" @@ -32,12 +33,17 @@ "graalvm_version": { "type": "string", "default": "", - "title": "The GraalVM Native Image version. This value is also used for the 'java.vm.version' property within the generated image" + "title": "The GraalVM Native Image version. Deprecated: Please use java_version and vendor instead." }, "java_version": { - "type": ["string", "null"], + "type": "string", + "default": null, + "title": "The Java version of the Native Image build process. This value is also used for the 'java.vm.version' property within the generated image" + }, + "vendor": { + "type": "string", "default": null, - "title": "The Java version of the Native Image build process (or null if not available)" + "title": "The vendor of the VM of the generated image. This value is also used for the 'java.vm.vendor' property within the generated image" }, "graal_compiler": { "type": "object", @@ -76,13 +82,14 @@ "examples": [ { "name": "helloworld", - "graalvm_version": "GraalVM 22.2.0-dev Java 17 EE", + "graalvm_version": "GraalVM CE 17.0.7+4", "graal_compiler": { "pgo": false, "march": "x86-64-v3", "optimization_level": "0" }, - "java_version": "17.0.4+5-jvmci-22.2-b03", + "java_version": "17.0.7+4", + "vendor": "GraalVM Community", "c_compiler": "gcc (linux, x86_64, 9.3.0)", "garbage_collector": "Serial GC" } @@ -506,12 +513,13 @@ { "general_info": { "name": "helloworld", - "graalvm_version": "GraalVM 22.2.0-dev Java 17 CE", + "graalvm_version": "GraalVM CE 17.0.7+4", "graal_compiler": { "march": "x86-64-v3", "optimization_level": "0" }, - "java_version": "17.0.4+5-jvmci-22.2-b03", + "java_version": "17.0.7+4", + "vendor": "GraalVM Community", "c_compiler": "gcc (linux, x86_64, 9.3.0)", "garbage_collector": "Serial GC" }, @@ -574,12 +582,13 @@ { "general_info": { "name": "helloworld", - "graalvm_version": "GraalVM 22.2.0-dev Java 17 CE", + "graalvm_version": "GraalVM CE 17.0.7+4", "graal_compiler": { "march": "x86-64-v3", "optimization_level": "0" }, - "java_version": null, + "java_version": "17.0.7+4", + "vendor": "GraalVM Community", "c_compiler": null, "garbage_collector": "Serial GC" }, diff --git a/sdk/mx.sdk/mx_sdk_vm_impl.py b/sdk/mx.sdk/mx_sdk_vm_impl.py index 835ee7b31914..a6fbb4c050c1 100644 --- a/sdk/mx.sdk/mx_sdk_vm_impl.py +++ b/sdk/mx.sdk/mx_sdk_vm_impl.py @@ -100,16 +100,11 @@ def unicode_utf8(string): _graalvm_base_name = 'GraalVM' - +_registered_graalvm_components = {} +_project_name = 'graal' default_components = [] -graalvm_version_regex = re.compile(r'.*\n.*\n[0-9a-zA-Z()\- ]+GraalVM[a-zA-Z_ ]+(?P[0-9a-z_\-.+]+) \(build [0-9a-zA-Z\-.+]+, mixed mode[a-z, ]*\)') - -_registered_graalvm_components = {} -_env_tests = [] - -_project_name = 'graal' mx.add_argument('--base-dist-name', help='Sets the name of the GraalVM base image ( for complete, ruby ... images), default to "base"', default='base') @@ -494,7 +489,7 @@ def _add_link(_dest, _target, _component=None, _dest_base_name=None): if stage1: # 1. we do not want a GraalVM to be used as base-JDK # 2. we don't need to check if the base JDK is JVMCI-enabled, since JVMCIVersionCheck takes care of that when the GraalVM compiler is a registered component - check_versions(_src_jdk, graalvm_version_regex=graalvm_version_regex, expect_graalvm=False, check_jvmci=False) + check_versions(_src_jdk, expect_graalvm=False, check_jvmci=False) # Add base JDK if mx.get_os() == 'darwin': @@ -3581,10 +3576,9 @@ def _str_to_bool(val): return val -def check_versions(jdk, graalvm_version_regex, expect_graalvm, check_jvmci): +def check_versions(jdk, expect_graalvm, check_jvmci): """ :type jdk: mx.JDKConfig | str - :type graalvm_version_regex: typing.Pattern :type expect_graalvm: bool :type check_jvmci: bool """ @@ -3604,14 +3598,8 @@ def check_versions(jdk, graalvm_version_regex, expect_graalvm, check_jvmci): if os.environ.get('JDK_VERSION_CHECK', None) != 'ignore' and (jdk_version <= mx.VersionSpec('1.8') or mx.VersionSpec('9') <= jdk_version < mx.VersionSpec('11')): mx.abort("GraalVM requires >=JDK11 as base-JDK, while the selected JDK ('{}') is '{}':\n{}\n\n{}.".format(jdk.home, jdk_version, out, check_env)) - if os.environ.get('GRAALVM_VERSION_CHECK', None) != 'ignore': - match = graalvm_version_regex.match(out) - if expect_graalvm and match is None: - mx.abort("'{}' is not a GraalVM. Its version string:\n{}\ndoes not match:\n{}".format(jdk.home, out, graalvm_version_regex.pattern)) - elif expect_graalvm and match.group('graalvm_version') != _suite.release_version(): - mx.abort("'{}' has a wrong GraalVM version:\n{}\nexpected:\n{}".format(jdk.home, match.group('graalvm_version'), _suite.release_version())) - elif not expect_graalvm and match: - mx.abort("GraalVM cannot be built using a GraalVM as base-JDK ('{}').\n{}.".format(jdk.home, check_env)) + if not expect_graalvm and "GraalVM" in out: + mx.abort("GraalVM cannot be built using a GraalVM as base-JDK ('{}').\n{}.".format(jdk.home, check_env)) def print_graalvm_vm_name(args): @@ -3635,9 +3623,7 @@ def graalvm_vendor_version(graalvm_dist): :type jdk_home: str :rtype str: """ - vendor_version = '{} {}'.format(graalvm_dist.base_name, graalvm_dist.vm_config_name.upper()) if graalvm_dist.vm_config_name else graalvm_dist.base_name - vendor_version += ' {}'.format(graalvm_version()) - return vendor_version + return 'Oracle GraalVM' if get_graalvm_edition() == 'ee' else 'GraalVM CE' # GR-37542 current debug info on darwin bloats binary (stripping to a separate .dSYM folder is not implemented) and diff --git a/substratevm/CHANGELOG.md b/substratevm/CHANGELOG.md index 48efcabc0bec..20102cd7c5fc 100644 --- a/substratevm/CHANGELOG.md +++ b/substratevm/CHANGELOG.md @@ -32,6 +32,7 @@ This changelog summarizes major changes to GraalVM Native Image. * (GR-44110) Native Image now targets `x86-64-v3` by default on AMD64 and supports a new `-march` option. Use `-march=compatibility` for best compatibility (previous default) or `-march=native` for best performance if the native executable is deployed on the same machine or on a machine with the same CPU features. To list all available machine types, use `-march=list`. * (GR-43971) Add native-image option `-E[=]` and support environment variable capturing in bundles. Previously almost all environment variables were available in the builder. To temporarily revert back to the old behaviour, env setting `NATIVE_IMAGE_DEPRECATED_BUILDER_SANITATION=true` can be used. The old behaviour will be removed in a future release. * (GR-43382) The build output now includes a section with recommendations that help you get the best out of Native Image. +* (GR-44722) The output of `native-image --version` and various Java properties (e.g. `java.vm.version`) have been aligned with the OpenJDK. To distinguish between GraalVM CE, Oracle GraalVM, and GraalVM distributions from other vendors, please refer to `java.vm.vendor`. ## Version 22.3.0 * (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option. diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VM.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VM.java index 75fd31a6d12e..14d1965340e2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VM.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,25 +24,47 @@ */ package com.oracle.svm.core; +import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.impl.ImageSingletonsSupport; public final class VM { + public final String info; public final String version; public final String vendor; public final String vendorUrl; - public final String runtimeName; + public final String vendorVersion; public final String supportURL; @Platforms(Platform.HOSTED_ONLY.class) - public VM() { - String versionStr = System.getProperty("org.graalvm.version", "Unknown Version"); - String edition = System.getProperty("org.graalvm.config", "CE"); - version = String.format("GraalVM %s Java %s %s", versionStr, Runtime.version(), edition); - vendor = System.getProperty("org.graalvm.vendor", "Oracle Corporation"); - vendorUrl = System.getProperty("org.graalvm.vendorurl", "https://www.graalvm.org/"); - runtimeName = System.getProperty("java.runtime.name", "Unknown Runtime Environment"); + public VM(String vmInfo) { + info = vmInfo; supportURL = System.getProperty("org.graalvm.supporturl", "https://graalvm.org/native-image/error-report/"); + version = stripJVMCISuffix(System.getProperty("java.runtime.version")); + vendor = System.getProperty("org.graalvm.vendor", "GraalVM Community"); + vendorUrl = System.getProperty("org.graalvm.vendorurl", "https://www.graalvm.org/"); + vendorVersion = System.getProperty("org.graalvm.vendorversion", "GraalVM CE"); + } + + @Platforms(Platform.HOSTED_ONLY.class) + public static VM getErrorReportingInstance() { + if (ImageSingletonsSupport.isInstalled() && ImageSingletons.contains(VM.class)) { + return ImageSingletons.lookup(VM.class); + } else { + // create a fall back instance + return new VM(System.getProperty("java.vm.info", "")); + } + } + + @Platforms(Platform.HOSTED_ONLY.class) + private static String stripJVMCISuffix(String javaRuntimeVersion) { + int jvmciIndex = javaRuntimeVersion.indexOf("-jvmci"); + if (jvmciIndex >= 0) { + return javaRuntimeVersion.substring(0, jvmciIndex); + } else { + return javaRuntimeVersion; + } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java index 6647f941dad9..84981ca5f668 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SystemPropertiesSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,7 @@ public abstract class SystemPropertiesSupport implements RuntimeSystemProperties /** System properties that are taken from the VM hosting the image generator. */ private static final String[] HOSTED_PROPERTIES = { "java.version", + "java.version.date", ImageInfo.PROPERTY_IMAGE_KIND_KEY, /* * We do not support cross-compilation for now. Separator might also be cached @@ -65,6 +66,7 @@ public abstract class SystemPropertiesSupport implements RuntimeSystemProperties /* For our convenience for now. */ "file.encoding", "sun.jnu.encoding", "native.encoding", "stdout.encoding", "stderr.encoding", "java.class.version", + "java.runtime.version", "java.specification.name", "java.specification.vendor", "java.specification.version", @@ -109,13 +111,17 @@ protected SystemPropertiesSupport() { } } + initializeProperty("java.runtime.name", "GraalVM Runtime Environment"); + + VM vm = ImageSingletons.lookup(VM.class); + initializeProperty("java.vendor", vm.vendor); + initializeProperty("java.vendor.url", vm.vendorUrl); + initializeProperty("java.vendor.version", vm.vendorVersion); + assert vm.info.equals(vm.info.toLowerCase()) : "java.vm.info should not contain uppercase characters"; + initializeProperty("java.vm.info", vm.info); initializeProperty("java.vm.name", "Substrate VM"); - initializeProperty("java.runtime.name", ImageSingletons.lookup(VM.class).runtimeName); - initializeProperty("java.vm.vendor", ImageSingletons.lookup(VM.class).vendor); - initializeProperty("java.vm.version", ImageSingletons.lookup(VM.class).version); - initializeProperty("java.runtime.version", ImageSingletons.lookup(VM.class).version); - initializeProperty("java.vendor", ImageSingletons.lookup(VM.class).vendor); - initializeProperty("java.vendor.url", ImageSingletons.lookup(VM.class).vendorUrl); + initializeProperty("java.vm.vendor", vm.vendor); + initializeProperty("java.vm.version", vm.version); initializeProperty("java.class.path", ""); initializeProperty("java.endorsed.dirs", ""); diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java index 72a9da22c0c5..2e8064df554a 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -775,6 +775,7 @@ private final class BundleProperties { private static final String PROPERTY_KEY_IMAGE_BUILT = "ImageBuilt"; private static final String PROPERTY_KEY_BUILT_WITH_CONTAINER = "BuiltWithContainer"; private static final String PROPERTY_KEY_NATIVE_IMAGE_PLATFORM = "NativeImagePlatform"; + private static final String PROPERTY_KEY_NATIVE_IMAGE_VENDOR = "NativeImageVendor"; private static final String PROPERTY_KEY_NATIVE_IMAGE_VERSION = "NativeImageVersion"; private final Path bundlePropertiesFile; @@ -814,8 +815,12 @@ private void loadAndVerify() { } catch (NumberFormatException e) { throw NativeImage.showError(fileVersionKey + " in " + bundlePropertiesFileName + " is missing or ill-defined", e); } + String bundleVendor = properties.getOrDefault(PROPERTY_KEY_NATIVE_IMAGE_VENDOR, "unknown"); + String javaVmVendor = System.getProperty("java.vm.vendor"); + String currentVendor = bundleVendor.equals(javaVmVendor) ? "" : " != '" + javaVmVendor + "'"; String bundleVersion = properties.getOrDefault(PROPERTY_KEY_NATIVE_IMAGE_VERSION, "unknown"); - String currentVersion = bundleVersion.equals(NativeImage.getNativeImageVersion()) ? "" : " != '" + NativeImage.getNativeImageVersion() + "'"; + String javaVmVersion = System.getProperty("java.vm.version"); + String currentVersion = bundleVersion.equals(javaVmVersion) ? "" : " != '" + javaVmVersion + "'"; String bundlePlatform = properties.getOrDefault(PROPERTY_KEY_NATIVE_IMAGE_PLATFORM, "unknown"); String currentPlatform = bundlePlatform.equals(NativeImage.platform) ? "" : " != '" + NativeImage.platform + "'"; String bundleCreationTimestamp = properties.getOrDefault(PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP, ""); @@ -827,9 +832,12 @@ private void loadAndVerify() { localDateStr = "unknown time"; } nativeImage.showNewline(); - nativeImage.showMessage(String.format("%sLoaded Bundle from %s", BUNDLE_INFO_MESSAGE_PREFIX, bundleFileName)); - nativeImage.showMessage(String.format("%sBundle created at '%s'", BUNDLE_INFO_MESSAGE_PREFIX, localDateStr)); - nativeImage.showMessage(String.format("%sUsing version: '%s'%s on platform: '%s'%s", BUNDLE_INFO_MESSAGE_PREFIX, bundleVersion, currentVersion, bundlePlatform, currentPlatform)); + nativeImage.showMessage("%sLoaded Bundle from %s", BUNDLE_INFO_MESSAGE_PREFIX, bundleFileName); + nativeImage.showMessage("%sBundle created at '%s'", BUNDLE_INFO_MESSAGE_PREFIX, localDateStr); + nativeImage.showMessage("%sUsing version: '%s'%s (vendor '%s'%s) on platform: '%s'%s", BUNDLE_INFO_MESSAGE_PREFIX, + bundleVersion, currentVersion, + bundleVendor, currentVendor, + bundlePlatform, currentPlatform); } private void write() { @@ -842,7 +850,8 @@ private void write() { properties.put(PROPERTY_KEY_BUILT_WITH_CONTAINER, String.valueOf(false)); } properties.put(PROPERTY_KEY_NATIVE_IMAGE_PLATFORM, NativeImage.platform); - properties.put(PROPERTY_KEY_NATIVE_IMAGE_VERSION, NativeImage.getNativeImageVersion()); + properties.put(PROPERTY_KEY_NATIVE_IMAGE_VENDOR, System.getProperty("java.vm.vendor")); + properties.put(PROPERTY_KEY_NATIVE_IMAGE_VERSION, System.getProperty("java.vm.version")); NativeImage.ensureDirectoryExists(bundlePropertiesFile.getParent()); try (OutputStream outputStream = Files.newOutputStream(bundlePropertiesFile)) { Properties p = new Properties(); diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java index 2a7aaaeae4b1..a5ce469805eb 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java @@ -27,6 +27,7 @@ import java.io.File; import java.nio.file.Paths; import java.util.List; +import java.util.Optional; import java.util.regex.Pattern; import org.graalvm.compiler.options.OptionType; @@ -48,7 +49,7 @@ class CmdLineOptionHandler extends NativeImage.OptionHandler { private static final String VERBOSE_SERVER_OPTION = "--verbose-server"; private static final String SERVER_OPTION_PREFIX = "--server-"; - private static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version"); + private static final String LAUNCHER_NAME = "native-image"; boolean useDebugAttach = false; @@ -84,9 +85,7 @@ private boolean consume(ArgumentQueue args, String headArg) { case "--version": args.poll(); singleArgumentCheck(args, headArg); - String message = NativeImage.getNativeImageVersion(); - message += " (Java Version " + JAVA_RUNTIME_VERSION + ")"; - nativeImage.showMessage(message); + printVersion(); System.exit(ExitStatus.OK.getValue()); return true; case "--help-extra": @@ -189,6 +188,40 @@ private boolean consume(ArgumentQueue args, String headArg) { return false; } + /** + * Prints version output following + * "src/java.base/share/classes/java/lang/VersionProps.java.template#print(boolean)". + */ + private void printVersion() { + /* First line: platform version. */ + String javaVersion = System.getProperty("java.version"); + String javaVersionDate = System.getProperty("java.version.date"); + Optional versionOpt = Runtime.version().optional(); + boolean isLTS = versionOpt.isPresent() && versionOpt.get().startsWith("LTS"); + nativeImage.showMessage("%s %s %s", LAUNCHER_NAME, javaVersion, javaVersionDate, isLTS ? " LTS" : ""); + + /* Second line: runtime version (ie, libraries). */ + String javaRuntimeVersion = System.getProperty("java.runtime.version"); + + String jdkDebugLevel = System.getProperty("jdk.debug", "release"); + if ("release".equals(jdkDebugLevel)) { + /* Do not show debug level "release" builds */ + jdkDebugLevel = ""; + } else { + jdkDebugLevel = jdkDebugLevel + " "; + } + + String javaRuntimeName = System.getProperty("java.runtime.name"); + String vendorVersion = System.getProperty("java.vendor.version"); + nativeImage.showMessage("%s %s (%sbuild %s)", javaRuntimeName, vendorVersion, jdkDebugLevel, javaRuntimeVersion); + + /* Third line: VM information. */ + String javaVMName = System.getProperty("java.vm.name"); + String javaVMVersion = System.getProperty("java.vm.version"); + String javaVMInfo = System.getProperty("java.vm.info"); + nativeImage.showMessage("%s %s (%sbuild %s, %s)", javaVMName, vendorVersion, jdkDebugLevel, javaVMVersion, javaVMInfo); + } + private static void singleArgumentCheck(ArgumentQueue args, String arg) { if (!args.isEmpty()) { NativeImage.showError("Option " + arg + " cannot be combined with other options."); diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java index 03c53c1a3ea0..72e6c94a674c 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java @@ -112,20 +112,9 @@ private static String getPlatform() { return (OS.getCurrent().className + "-" + SubstrateUtil.getArchitectureName()).toLowerCase(); } - static String getNativeImageVersion() { - String message; - if (IS_AOT) { - message = System.getProperty("java.vm.version"); - } else { - message = "native-image " + graalvmVersion + " " + graalvmConfig; - } - return message; - } - - static final String graalvmVersion = System.getProperty("org.graalvm.version", "dev"); - static final String graalvmConfig = System.getProperty("org.graalvm.config", "CE"); - static final String graalvmVendor = System.getProperty("org.graalvm.vendor", "Oracle Corporation"); + static final String graalvmVendor = System.getProperty("org.graalvm.vendor", "GraalVM Community"); static final String graalvmVendorUrl = System.getProperty("org.graalvm.vendorurl", "https://www.graalvm.org/"); + static final String graalvmVendorVersion = System.getProperty("org.graalvm.vendorversion", "GraalVM CE"); private static Map getCompilerFlags() { Map result = new HashMap<>(); @@ -827,12 +816,9 @@ private void prepareImageBuildArgs() { /* Prevent JVM that runs the image builder to steal focus. */ addImageBuilderJavaArgs("-Djava.awt.headless=true"); - addImageBuilderJavaArgs("-Dorg.graalvm.version=" + graalvmVersion); addImageBuilderJavaArgs("-Dorg.graalvm.vendor=" + graalvmVendor); addImageBuilderJavaArgs("-Dorg.graalvm.vendorurl=" + graalvmVendorUrl); - if (!NativeImage.IS_AOT) { - addImageBuilderJavaArgs("-Dorg.graalvm.config=" + graalvmConfig); - } + addImageBuilderJavaArgs("-Dorg.graalvm.vendorversion=" + graalvmVendorVersion); addImageBuilderJavaArgs("-Dcom.oracle.graalvm.isaot=true"); addImageBuilderJavaArgs("-Djava.system.class.loader=" + CUSTOM_SYSTEM_CLASS_LOADER); @@ -1990,6 +1976,10 @@ void showMessage(String message) { show(System.out::println, message); } + void showMessage(String format, Object... args) { + showMessage(String.format(format, args)); + } + void showNewline() { System.out.println(); } @@ -2010,8 +2000,7 @@ void showOutOfMemoryWarning() { } String maxHeapText = lastMaxHeapValue == null ? "" : " (The maximum heap size of the process was set to '" + lastMaxHeapValue + "'.)"; String additionalAction = lastMaxHeapValue == null ? "" : " or increase the maximum heap size using the '" + oXmx + "' option"; - showMessage(String.format("The Native Image build process ran out of memory.%s%nPlease make sure your build system has more memory available%s.", - maxHeapText, additionalAction)); + showMessage("The Native Image build process ran out of memory.%s%nPlease make sure your build system has more memory available%s.", maxHeapText, additionalAction); } public static void showWarning(String message) { @@ -2111,21 +2100,18 @@ protected String getXmxValue(int maxInstances) { return Long.toUnsignedString(memMax); } - private static final boolean IS_CI = SubstrateUtil.isRunningInCI(); - private static final boolean IS_DUMB_TERM = isDumbTerm(); - private static boolean isDumbTerm() { String term = System.getenv().getOrDefault("TERM", ""); return term.isEmpty() || term.equals("dumb") || term.equals("unknown"); } private static boolean hasColorSupport() { - return !IS_DUMB_TERM && !IS_CI && OS.getCurrent() != OS.WINDOWS && + return !isDumbTerm() && !SubstrateUtil.isRunningInCI() && OS.getCurrent() != OS.WINDOWS && System.getenv("NO_COLOR") == null /* https://no-color.org/ */; } private static boolean hasProgressSupport(List imageBuilderArgs) { - return !IS_DUMB_TERM && !IS_CI && + return !isDumbTerm() && !SubstrateUtil.isRunningInCI() && /* * When DebugOptions.Log is used, progress cannot be reported as logging * works around NativeImageSystemIOWrappers to access stdio handles. diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java index 5cc082f19787..15f61d66594b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java @@ -246,14 +246,11 @@ public void printUnsuccessfulInitializeEnd() { public void printInitializeEnd() { stagePrinter.end(getTimer(TimerCollection.Registry.CLASSLIST).getTotalTime() + getTimer(TimerCollection.Registry.SETUP).getTotalTime()); - String version = ImageSingletons.lookup(VM.class).version; - recordJsonMetric(GeneralInfo.GRAALVM_VERSION, version); - l().a(" ").doclink("Version info", "#glossary-version-info").a(": '").a(version).a("'").println(); - String javaVersion = System.getProperty("java.runtime.version"); - recordJsonMetric(GeneralInfo.JAVA_VERSION, javaVersion); - if (javaVersion != null) { - l().a(" ").doclink("Java version info", "#glossary-java-version-info").a(": '").a(javaVersion).a("'").println(); - } + VM vm = ImageSingletons.lookup(VM.class); + recordJsonMetric(GeneralInfo.JAVA_VERSION, vm.version); + recordJsonMetric(GeneralInfo.VENDOR, vm.vendor); + recordJsonMetric(GeneralInfo.GRAALVM_VERSION, vm.vendorVersion + " " + vm.version); // deprecated + l().a(" ").doclink("Java version", "#glossary-java-info").a(": ").a(vm.version).a(", ").doclink("vendor", "#glossary-java-info").a(": ").a(vm.vendor).println(); String optimizationLevel = SubstrateOptions.Optimize.getValue(); recordJsonMetric(GeneralInfo.GRAAL_COMPILER_OPTIMIZATION_LEVEL, optimizationLevel); String march = CPUType.getSelectedOrDefaultMArch(); @@ -695,7 +692,7 @@ private void printErrorMessage(Optional optionalError, OptionValues p l().link(NativeImageOptions.getErrorFilePath(parsedHostedOptions)).println(); l().println(); l().a("If you are unable to resolve this problem, please file an issue with the error report at:").println(); - var supportURL = ImageSingletonsSupport.isInstalled() ? ImageSingletons.lookup(VM.class).supportURL : new VM().supportURL; + var supportURL = VM.getErrorReportingInstance().supportURL; l().link(supportURL, supportURL).println(); } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java index 1a0e2432ad4f..3066d3415df2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterJsonHelper.java @@ -225,6 +225,7 @@ public void record(ProgressReporterJsonHelper helper, Object value) { public enum GeneralInfo implements JsonMetric { IMAGE_NAME("name", null), JAVA_VERSION("java_version", null), + VENDOR("vendor", null), GRAALVM_VERSION("graalvm_version", null), GRAAL_COMPILER_OPTIMIZATION_LEVEL("optimization_level", "graal_compiler"), GRAAL_COMPILER_MARCH("march", "graal_compiler"), diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java index f47d625e1768..7ccebf38e94d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,21 @@ public class VMFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VM.class, new VM()); + ImageSingletons.add(VM.class, new VM(determineVMInfo())); + } + + protected String determineVMInfo() { + return getSelectedGCName(); + } + + protected static final String getSelectedGCName() { + if (SubstrateOptions.UseSerialGC.getValue()) { + return "serial gc"; + } else if (SubstrateOptions.UseEpsilonGC.getValue()) { + return "epsilon gc"; + } else { + return "unknown gc"; + } } @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/VMErrorReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/VMErrorReporter.java index bb636047be8f..53115625fe0c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/VMErrorReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/util/VMErrorReporter.java @@ -80,14 +80,12 @@ private static void reportStackTrace(PrintWriter pw, Throwable t) { private static void reportGraalVMSetup(PrintWriter pw) { pw.println("## GraalVM Setup"); pw.println(); - boolean isImageSingletonsInstalled = ImageSingletonsSupport.isInstalled(); - String version = isImageSingletonsInstalled && ImageSingletons.contains(VM.class) ? ImageSingletons.lookup(VM.class).version : new VM().version; - String javaVersion = System.getProperty("java.runtime.version"); pw.println("| Name | Value |"); pw.println("| ---- | ----- |"); - pw.printf("| GraalVM version | `%s` |%n", version); - pw.printf("| Java version | `%s` |%n", javaVersion); - if (isImageSingletonsInstalled && ImageSingletons.contains(CCompilerInvoker.class)) { + VM vm = VM.getErrorReportingInstance(); + pw.printf("| Java version and vendor | `%s` (%s) |%n", vm.version, vm.vendor); + pw.printf("| Runtime version | `%s` |%n", System.getProperty("java.runtime.version")); + if (ImageSingletonsSupport.isInstalled() && ImageSingletons.contains(CCompilerInvoker.class)) { pw.printf("| C compiler | `%s` |%n", ImageSingletons.lookup(CCompilerInvoker.class).compilerInfo.getShortDescription()); } diff --git a/truffle/CHANGELOG.md b/truffle/CHANGELOG.md index 99150e884068..ff126692972e 100644 --- a/truffle/CHANGELOG.md +++ b/truffle/CHANGELOG.md @@ -64,6 +64,7 @@ This changelog summarizes major changes between Truffle versions relevant to lan * GR-44053 (change of behavior) The default implementation of `InteropLibrary.getExceptionStackTrace()` will now include host stack trace elements if [public host access is allowed](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/HostAccess.Builder.html#allowPublicAccess-boolean-). * GR-44053 (change of behavior) Truffle stack trace information is now attached to host and internal exceptions via suppressed exceptions. The cause of an exception is never modified anymore. * GR-44053 (change of behavior) A `StackOverflowError` or `OutOfMemoryError` crossing a Truffle call boundary will not be injected guest stack trace information anymore. +* GR-44723 `Truffle.getRuntime().getName()` and consequently `Engine.getImplementationName()` have been adjusted to return "Oracle GraalVM" instead of "GraalVM EE". ## Version 22.3.0 diff --git a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/EngineAPITest.java b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/EngineAPITest.java index 42cd64550ec0..46141a35509f 100644 --- a/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/EngineAPITest.java +++ b/truffle/src/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/polyglot/EngineAPITest.java @@ -300,7 +300,7 @@ public void testEngineName() { if (name.equals("DefaultCallTarget")) { assertEquals(implName, "Interpreted"); } else if (name.endsWith("OptimizedCallTarget")) { - assertTrue(implName, implName.equals("GraalVM EE" + suffix) || implName.equals("GraalVM CE")); + assertTrue(implName, implName.equals("Oracle GraalVM" + suffix) || implName.equals("GraalVM CE")); } } diff --git a/vm/mx.vm/mx_vm_gate.py b/vm/mx.vm/mx_vm_gate.py index aafd30f5d62b..a7634bd79168 100644 --- a/vm/mx.vm/mx_vm_gate.py +++ b/vm/mx.vm/mx_vm_gate.py @@ -423,7 +423,7 @@ def gate_body(args, tasks): if t and mx_sdk_vm_impl.has_component('GraalVM compiler'): # 1. the build must be a GraalVM # 2. the build must be JVMCI-enabled since the 'GraalVM compiler' component is registered - mx_sdk_vm_impl.check_versions(mx_sdk_vm_impl.graalvm_output(), graalvm_version_regex=mx_sdk_vm_impl.graalvm_version_regex, expect_graalvm=True, check_jvmci=True) + mx_sdk_vm_impl.check_versions(mx_sdk_vm_impl.graalvm_output(), expect_graalvm=True, check_jvmci=True) libgraal_suite_name = 'substratevm' if mx.suite(libgraal_suite_name, fatalIfMissing=False) is not None: diff --git a/vm/mx.vm/suite.py b/vm/mx.vm/suite.py index b1f47d998a04..b0c6cbc55853 100644 --- a/vm/mx.vm/suite.py +++ b/vm/mx.vm/suite.py @@ -49,7 +49,7 @@ }, { "name": "truffleruby", - "version": "388483f2809e0044f5c2db525066ee1ddeb0c44f", + "version": "b60c98de2069aefee9f161a6219958ca6184fc67", "dynamic": True, "urls": [ {"url": "https://github.com/oracle/truffleruby.git", "kind": "git"},