From 84c9266b5b6612539148b14b3dfdaef08b520353 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Thu, 29 Sep 2022 18:38:37 +0200 Subject: [PATCH 1/3] Only require libmanagement_ext if it's actually needed. On some systems/apps, libawt_headless gets pulled in. This currently brings in libmanagement_ext unconditionally. However, libmanagement_ext should only be present for linking iff com.sun.management.internal.OperatingSystemImpl class becomes reachable. Closes: #5119 --- .../svm/hosted/jdk/JNIRegistrationManagementExt.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java index 90dc6d3ca7d7..c7af55bb1e1d 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java @@ -43,15 +43,17 @@ @AutomaticallyRegisteredFeature public class JNIRegistrationManagementExt extends JNIRegistrationUtil implements InternalFeature { + + private static final String OPERATING_SYSTEM_IMPL = "com.sun.management.internal.OperatingSystemImpl"; private NativeLibraries nativeLibraries; @Override public void beforeAnalysis(BeforeAnalysisAccess access) { nativeLibraries = ((BeforeAnalysisAccessImpl) access).getNativeLibraries(); - rerunClassInit(access, "com.sun.management.internal.OperatingSystemImpl"); + rerunClassInit(access, OPERATING_SYSTEM_IMPL); - access.registerReachabilityHandler(this::linkManagementExt, clazz(access, "com.sun.management.internal.OperatingSystemImpl")); + access.registerReachabilityHandler(this::linkManagementExt, clazz(access, OPERATING_SYSTEM_IMPL)); PlatformNativeLibrarySupport.singleton().addBuiltinPkgNativePrefix("com_sun_management_internal_OperatingSystemImpl"); } @@ -77,7 +79,8 @@ private void linkManagementExt(@SuppressWarnings("unused") DuringAnalysisAccess @Override public void afterAnalysis(AfterAnalysisAccess access) { - if (NativeLibrarySupport.singleton().isPreregisteredBuiltinLibrary("awt_headless")) { + boolean managementExtNeeded = access.isReachable(clazz(access, OPERATING_SYSTEM_IMPL)); + if (managementExtNeeded && NativeLibrarySupport.singleton().isPreregisteredBuiltinLibrary("awt_headless")) { /* * Ensure that `management_ext` comes before `awt_headless` on the linker command line. * This is necessary to prevent linker errors such as JDK-8264047. From f810a2c6cfb64d74625b55f331657c8e57fb94c6 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 11 Oct 2022 09:30:08 +0200 Subject: [PATCH 2/3] Windows SDK comes with VS, not VSC. Closes #5082. --- docs/getting-started/graalvm-community/windows.md | 6 +++--- .../graalvm-enterprise/installation-windows.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/getting-started/graalvm-community/windows.md b/docs/getting-started/graalvm-community/windows.md index 9d59760f110e..2e1c534d9445 100644 --- a/docs/getting-started/graalvm-community/windows.md +++ b/docs/getting-started/graalvm-community/windows.md @@ -54,11 +54,11 @@ The GraalVM Community distribution for Windows platforms includes OpenJDK with t Currently, the GraalVM environment on Windows can be extended with [Native Image](../../reference-manual/native-image/README.md), [Java on Truffle](../../reference-manual/java-on-truffle/README.md), [LLVM runtime](../../reference-manual/llvm/README.md), WebAssembly, JavaScript and Node.js support. ## Prerequisites for Using Native Image on Windows -On Windows, Native Image requires Visual Studio Code and Microsoft Visual C++(MSVC). +On Windows, Native Image requires Visual Studio and Microsoft Visual C++(MSVC). You can use Visual Studio 2017 version 15.9 or later. There are two installation options: -- Install the Visual Studio Code Build Tools with the Windows 10 SDK -- Install Visual Studio Code with the Windows 10 SDK +- Install the Visual Studio Build Tools with the Windows 10 SDK +- Install Visual Studio with the Windows 10 SDK The last prerequisite is the proper [Developer Command Prompt](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#developer_command_prompt_shortcuts) for your version of [Visual Studio](https://visualstudio.microsoft.com/vs/). On Windows, the `native-image` tool only works when it is executed from the **x64 Native Tools Command Prompt**. diff --git a/docs/getting-started/graalvm-enterprise/installation-windows.md b/docs/getting-started/graalvm-enterprise/installation-windows.md index d15d07d70f55..9e86d18dc93c 100644 --- a/docs/getting-started/graalvm-enterprise/installation-windows.md +++ b/docs/getting-started/graalvm-enterprise/installation-windows.md @@ -49,11 +49,11 @@ The GraalVM Enterprise distribution for Windows platforms includes Oracle JDK wi Currently, the GraalVM environment on Windows can be extended with [Native Image](../../reference-manual/native-image/README.md), [Java on Truffle](../../reference-manual/java-on-truffle/README.md), [LLVM runtime](../../reference-manual/llvm/README.md), WebAssembly, JavaScript and Node.js support. ## Prerequisites for Using Native Image on Windows -On Windows, Native Image requires Visual Studio Code and Microsoft Visual C++(MSVC). +On Windows, Native Image requires Visual Studio and Microsoft Visual C++(MSVC). You can use Visual Studio 2017 version 15.9 or later. There are two installation options: -- Install the Visual Studio Code Build Tools with the Windows 10 SDK -- Install Visual Studio Code with the Windows 10 SDK +- Install the Visual Studio Build Tools with the Windows 10 SDK +- Install Visual Studio with the Windows 10 SDK The last prerequisite is the proper [Developer Command Prompt](https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=vs-2019#developer_command_prompt_shortcuts) for your version of [Visual Studio](https://visualstudio.microsoft.com/vs/). On Windows the `native-image` tool only works when it is executed from the **x64 Native Tools Command Prompt**. From 1a7d773cb261bda507d5a21e137012a9d0fbcf7f Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Tue, 11 Oct 2022 09:33:08 +0200 Subject: [PATCH 3/3] Fix some typos. Closes #4225 and fixes #4040 --- .../src/org/graalvm/compiler/hotspot/EncodedSnippets.java | 2 +- .../src/com/oracle/svm/core/jdk/SecuritySubstitutions.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/EncodedSnippets.java b/compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/EncodedSnippets.java index 6d84d52454c6..9c587aa2f26f 100644 --- a/compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/EncodedSnippets.java +++ b/compiler/src/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/EncodedSnippets.java @@ -320,7 +320,7 @@ static StructuredGraph decodeSnippetGraph(SymbolicEncodedGraph encodedGraph, Res private static void postDecode(DebugContext debug, StructuredGraph result, ResolvedJavaMethod original) { debug.dump(DebugContext.VERBOSE_LEVEL, result, "Before PartialIntrinsicCallTargetNode replacement"); for (PartialIntrinsicCallTargetNode partial : result.getNodes(PartialIntrinsicCallTargetNode.TYPE)) { - // Ensure the orignal method matches + // Ensure the original method matches assert partial.checkName(original); ValueNode[] arguments = partial.arguments().toArray(new ValueNode[partial.arguments().size()]); MethodCallTargetNode target = result.add(new MethodCallTargetNode(partial.invokeKind(), original, diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java index 5627b2cc61bc..d6a2dd98a4d9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SecuritySubstitutions.java @@ -373,7 +373,7 @@ static Exception getVerificationResult(Provider p) { /* End code block copied from original method. */ /* * If the verification result is not found in the verificationResults map JDK proceeds to - * verify it. That requires accesing the code base which we don't support. The substitution + * verify it. That requires accessing the code base which we don't support. The substitution * for getCodeBase() would be enough to take care of this too, but substituting * getVerificationResult() allows for a better error message. */