Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8f3f016
Back out custom no-jlinking Mandrel build fix
jerboaa Dec 20, 2023
9bc358d
Use ModuleFinder to collect names of application modules
olpaw Sep 5, 2023
5c36653
Remove pre-python 3 support code
olpaw Sep 6, 2023
75223cf
Fix SyntaxWarning: invalid escape sequence '\.'
olpaw Sep 14, 2023
4046d1f
Remove modules from -imagemp that are already provided by other means
olpaw Sep 14, 2023
d54741f
Remove debug code
olpaw Sep 19, 2023
89bf7c7
On Windows jdk native library jimage does not depend on stdc++
olpaw Sep 19, 2023
60b5dec
Building driver into image requires JRTFileSystem support
olpaw Sep 19, 2023
fc48509
Fix return type of substituted method
olpaw Sep 19, 2023
250c7b6
Ensure libstdc++ gets statically linked into agents
olpaw Sep 20, 2023
486470e
Implement -H:+StaticLibStdCpp and use if for building the agents
olpaw Sep 20, 2023
552c386
Ensure `ModuleFinder.of` and `ImageReader.open` are not used when ima…
olpaw Sep 21, 2023
e9871a6
Only use full driver build args when building the driver image
olpaw Sep 21, 2023
1f2d416
Remove obsolete agent-based image build code.
olpaw Sep 25, 2023
1df0a49
Ensure jimage static jdk library get statically linked
olpaw Oct 3, 2023
c096c0d
Do not allow jdk.internal.jimage.NativeImageBuffer at image-runtime
olpaw Oct 4, 2023
8c1fe64
Checkstyle fix
olpaw Oct 4, 2023
0ebde1f
Factor out common use of `dynamicLibC || staticLibCpp`
olpaw Oct 10, 2023
508b089
Add new dependencies after graal-sdk split
jerboaa Aug 11, 2023
6a1ab43
Drop polyglot.jar and truffle-api.jar from native-image launcher
jerboaa Aug 14, 2023
e6a183b
Add polyglot.jar only if truffle-runtime-svm is there as well
jerboaa Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,11 +534,11 @@ def extra_image_build_argument(self, benchmark, args):
'-J--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED',
'-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
'--exclude-config' ,
'io\.netty\.netty-codec',
'/META-INF/native-image/io\.netty/netty-codec/generated/handlers/reflect-config\.json',
'io\\.netty\\.netty-codec',
'/META-INF/native-image/io\\.netty/netty-codec/generated/handlers/reflect-config\\.json',
'--exclude-config',
'io\.netty\.netty-handler',
'/META-INF/native-image/io\.netty/netty-handler/generated/handlers/reflect-config\.json',
'io\\.netty\\.netty-handler',
'/META-INF/native-image/io\\.netty/netty-handler/generated/handlers/reflect-config\\.json',
'-H:-AddAllCharsets',
'-H:+ReportExceptionStackTraces',
] + mx_sdk_vm_impl.svm_experimental_options([
Expand Down
14 changes: 6 additions & 8 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#
# ----------------------------------------------------------------------------------------------------

from __future__ import print_function

import os
import re
import tempfile
Expand All @@ -38,6 +36,7 @@
from argparse import ArgumentParser
import fnmatch
import collections
from io import StringIO

import mx
import mx_compiler
Expand All @@ -56,10 +55,6 @@
import sys


if sys.version_info[0] < 3:
from StringIO import StringIO
else:
from io import StringIO

suite = mx.suite('substratevm')
svmSuites = [suite]
Expand Down Expand Up @@ -1016,7 +1011,10 @@ def _native_image_launcher_extra_jvm_args():
'--features=com.oracle.svm.driver.APIOptionFeature',
'--initialize-at-build-time=com.oracle.svm.driver',
'--link-at-build-time=com.oracle.svm.driver,com.oracle.svm.driver.metainf',
] + svm_experimental_options([
]

driver_exe_build_args = driver_build_args + svm_experimental_options([
'-H:+AllowJRTFileSystem',
'-H:IncludeResources=com/oracle/svm/driver/launcher/.*',
'-H:-ParseRuntimeOptions',
f'-R:MaxHeapSize={256 * 1024 * 1024}',
Expand Down Expand Up @@ -1058,7 +1056,7 @@ def _native_image_launcher_extra_jvm_args():
destination="bin/<exe:native-image>",
jar_distributions=["substratevm:SVM_DRIVER"],
main_class=_native_image_launcher_main_class(),
build_args=driver_build_args,
build_args=driver_exe_build_args,
extra_jvm_args=_native_image_launcher_extra_jvm_args(),
home_finder=False,
),
Expand Down
5 changes: 5 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,11 @@
"requires" : [
"jdk.management",
],
"requiresConcealed" : {
"java.base" : [
"jdk.internal.jimage",
],
},
"checkstyle": "com.oracle.svm.hosted",
"workingSets": "SVM",
"annotationProcessors": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.ConcurrentModificationException;
import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -76,12 +75,10 @@
import com.oracle.svm.configure.filters.HierarchyFilterNode;
import com.oracle.svm.configure.trace.AccessAdvisor;
import com.oracle.svm.configure.trace.TraceProcessor;
import com.oracle.svm.core.SubstrateUtil;
import com.oracle.svm.core.configure.ConfigurationFile;
import com.oracle.svm.core.jni.headers.JNIEnvironment;
import com.oracle.svm.core.jni.headers.JNIJavaVM;
import com.oracle.svm.core.jni.headers.JNIObjectHandle;
import com.oracle.svm.driver.NativeImage;
import com.oracle.svm.driver.metainf.NativeImageMetaInfWalker;
import com.oracle.svm.jvmtiagentbase.JNIHandleSet;
import com.oracle.svm.jvmtiagentbase.JvmtiAgentBase;
Expand Down Expand Up @@ -143,7 +140,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
boolean experimentalClassDefineSupport = false;
boolean experimentalUnsafeAllocationSupport = false;
boolean experimentalOmitClasspathConfig = false;
boolean build = false;
boolean configurationWithOrigins = false;
List<String> conditionalConfigUserPackageFilterFiles = new ArrayList<>();
List<String> conditionalConfigClassNameFilterFiles = new ArrayList<>();
Expand Down Expand Up @@ -206,8 +202,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
if (configWritePeriodInitialDelay < 0) {
return usage(1, "config-write-initial-delay-secs must be an integer greater or equal to 0");
}
} else if (isBooleanOption(token, "build")) {
build = getBooleanTokenValue(token);
} else if (isBooleanOption(token, "experimental-configuration-with-origins")) {
configurationWithOrigins = getBooleanTokenValue(token);
} else if (token.startsWith("experimental-conditional-config-filter-file=")) {
Expand All @@ -223,9 +217,9 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
}
}

if (traceOutputFile == null && configOutputDir == null && !build) {
if (traceOutputFile == null && configOutputDir == null) {
configOutputDir = transformPath(AGENT_NAME + "_config-pid{pid}-{datetime}/");
inform("no output/build options provided, tracking dynamic accesses and writing configuration to directory: " + configOutputDir);
inform("no output options provided, tracking dynamic accesses and writing configuration to directory: " + configOutputDir);
}

if (configurationWithOrigins && !conditionalConfigUserPackageFilterFiles.isEmpty()) {
Expand Down Expand Up @@ -377,14 +371,6 @@ protected int onLoadCallback(JNIJavaVM vm, JvmtiEnv jvmti, JvmtiEventCallbacks c
}
}

if (build) {
int status = buildImage(jvmti);
if (status == 0) {
System.exit(status);
}
return status;
}

try {
BreakpointInterceptor.onLoad(jvmti, callbacks, tracer, this, interceptedStateSupplier,
experimentalClassLoaderSupport, experimentalClassDefineSupport, experimentalUnsafeAllocationSupport, trackReflectionMetadata);
Expand Down Expand Up @@ -504,46 +490,6 @@ private static void ignoreConfigFromClasspath(JvmtiEnv jvmti, ConfigurationFileC
private static final Pattern propertyBlacklist = Pattern.compile("(java\\..*)|(sun\\..*)|(jvmci\\..*)");
private static final Pattern propertyWhitelist = Pattern.compile("(java\\.library\\.path)|(java\\.io\\.tmpdir)");

private static int buildImage(JvmtiEnv jvmti) {
System.out.println("Building native image ...");
String classpath = Support.getSystemProperty(jvmti, "java.class.path");
if (classpath == null) {
return usage(1, "Build mode could not determine classpath.");
}
String javaCommand = Support.getSystemProperty(jvmti, "sun.java.command");
String mainClassMissing = "Build mode could not determine main class.";
if (javaCommand == null) {
return usage(1, mainClassMissing);
}
String mainClass = SubstrateUtil.split(javaCommand, " ")[0];
if (mainClass.isEmpty()) {
return usage(1, mainClassMissing);
}
List<String> buildArgs = new ArrayList<>();
// buildArgs.add("--verbose");
String[] keys = Support.getSystemProperties(jvmti);
for (String key : keys) {
boolean whitelisted = propertyWhitelist.matcher(key).matches();
boolean blacklisted = !whitelisted && propertyBlacklist.matcher(key).matches();
if (blacklisted) {
continue;
}
buildArgs.add("-D" + key + "=" + Support.getSystemProperty(jvmti, key));
}
if (mainClass.toLowerCase().endsWith(".jar")) {
buildArgs.add("-jar");
} else {
buildArgs.addAll(Arrays.asList("-cp", classpath));
}
buildArgs.add(mainClass);
buildArgs.add(AGENT_NAME + ".build");
// System.out.println(String.join("\n", buildArgs));
Path javaHome = Paths.get(Support.getSystemProperty(jvmti, "java.home"));
String userDirStr = Support.getSystemProperty(jvmti, "user.dir");
NativeImage.agentBuild(javaHome, userDirStr == null ? null : Paths.get(userDirStr), buildArgs);
return 0;
}

private static String transformPath(String path) {
String result = path;
if (result.contains("{pid}")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,10 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, String ol
};

@Option(help = "Builds a statically linked executable with libc dynamically linked", type = Expert, stability = OptionStability.EXPERIMENTAL)//
public static final HostedOptionKey<Boolean> StaticExecutableWithDynamicLibC = new HostedOptionKey<>(false) {
@Override
protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean oldValue, Boolean newValue) {
StaticExecutable.update(values, true);
super.onValueUpdate(values, oldValue, newValue);
}
};
public static final HostedOptionKey<Boolean> StaticExecutableWithDynamicLibC = new HostedOptionKey<>(false);

@Option(help = "Builds image with libstdc++ statically linked into the image (if needed)", type = Expert, stability = OptionStability.EXPERIMENTAL)//
public static final HostedOptionKey<Boolean> StaticLibStdCpp = new HostedOptionKey<>(false);

public static final int ForceFallback = 10;
public static final int Automatic = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.ByteBuffer;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -115,7 +116,7 @@ final class Target_jdk_internal_module_SystemModuleFinders_SystemImage_JRTEnable
static volatile Target_jdk_internal_jimage_ImageReader_JRTEnabled READER;

@Substitute
static Object reader() {
static Target_jdk_internal_jimage_ImageReader_JRTEnabled reader() {
Target_jdk_internal_jimage_ImageReader_JRTEnabled localRef = READER;
if (localRef == null) {
synchronized (Target_jdk_internal_module_SystemModuleFinders_SystemImage_JRTEnabled.class) {
Expand Down Expand Up @@ -174,3 +175,22 @@ final class Target_jdk_internal_jrtfs_JrtFileSystemProvider_JRTDisabled {
}

// endregion Disable jimage/jrtfs

@TargetClass(className = "jdk.internal.jimage.BasicImageReader")
final class Target_jdk_internal_jimage_BasicImageReader {
/* Ensure NativeImageBuffer never gets used as part of using BasicImageReader */
@Alias //
@RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true) //
// Checkstyle: stop
static boolean USE_JVM_MAP = false;
// Checkstyle: resume
}

@TargetClass(className = "jdk.internal.jimage.NativeImageBuffer")
@Substitute
final class Target_jdk_internal_jimage_NativeImageBuffer {
@Substitute
static ByteBuffer getNativeMap(String imagePath) {
throw VMError.unsupportedFeature("Using jdk.internal.jimage.NativeImageBuffer is not supported");
}
}
Loading