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

[GR-36905] Implement --link-at-build-time and @<prop-values-file>. #4305

Merged
merged 36 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fef7fcc
Add initial implementation of --require-complete-classdef
olpaw Feb 9, 2022
233f7c1
Make SubstrateOptionsParser.commandArgument smarter when option is re…
olpaw Feb 14, 2022
51fb6fc
Generalize OptionOrigin use introduced for LinkAtBuildTime option
olpaw Feb 16, 2022
3eb9031
Add jdk/internal/reflect/GeneratedSerializationConstructorAccessor* h…
olpaw Feb 16, 2022
5ab1d98
Support @<prop-values-file> also for directory-based class-path and m…
olpaw Feb 16, 2022
802265b
Handle macro options like command line options
olpaw Feb 16, 2022
13f45e9
Disable debug output
olpaw Feb 16, 2022
9bf4e60
Style fix
olpaw Feb 16, 2022
14ef9fd
Cache ClassLoaderSupport ImageSingletons
olpaw Feb 17, 2022
bf43e74
Make requiresCompleteDefinition package-private
olpaw Feb 17, 2022
7fc2303
Remove duplicate entries from svm-junit.packages
olpaw Feb 17, 2022
99fdb33
Style fix
olpaw Feb 17, 2022
c42a493
Consolidate Exception handling in resolveOptionValueRedirectionFlatMap
olpaw Feb 17, 2022
1648216
Support all variants of MacroOptionOrigin and remove UnsupportedOpti…
olpaw Feb 17, 2022
0b6593f
Inline single-use method
olpaw Feb 17, 2022
9179718
Remove debug code
olpaw Feb 17, 2022
6cba492
Record where class and package link-at-build-time options are coming …
olpaw Feb 17, 2022
880e231
Use qualified --link-at-build-time for svm-driver to allow building o…
olpaw Feb 17, 2022
71ede25
Do not default synthetic modules and classes to link-at-build-time
olpaw Feb 21, 2022
eab7062
Replace usages of AllowIncompleteClasspath
Feb 17, 2022
e4da0b6
Add info why class is seen as requiring link-at-build-time
olpaw Feb 22, 2022
93183a7
Style fix
olpaw Feb 22, 2022
1c1ef87
Ensure LinkAtBuildTimeSupport is already available after afterRegistr…
olpaw Feb 23, 2022
0537b3e
Ensure all images of a GraalVM build require --link-at-build-time
olpaw Mar 1, 2022
2381518
Document OptionOrigin.getRedirectionValues
olpaw Mar 1, 2022
6de6a9f
Rename resolveOptionValueRedirectionFlatMap
olpaw Mar 1, 2022
45a8a13
Allow individual launchers to opt-out of --link-at-build-time
olpaw Mar 1, 2022
a0d139d
Implement strict checking of --link-at-build-time arguments
olpaw Mar 2, 2022
bf1b83a
Add support for @<prop-values-file> use in macro-options
olpaw Mar 3, 2022
ed4525d
Move @<prop-values-file>-use from c.o.s.junit native-image.properties…
olpaw Mar 3, 2022
29ad095
Change SharedBytecodeParser allowIncompleteClassPath to linkAtBuildTi…
olpaw Mar 3, 2022
4dd1540
Fix strict checking of --link-at-build-time arguments for jar-files o…
olpaw Mar 3, 2022
4e330cd
Implement --link-at-build-time-paths
olpaw Mar 7, 2022
7838db3
Fully document --link-at-build-time and --link-at-build-time-paths
olpaw Mar 7, 2022
c3227c8
Make OptionOrigin classes package-private
olpaw Mar 8, 2022
1655cb2
Add changelog entry
olpaw Mar 8, 2022
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
3 changes: 2 additions & 1 deletion sdk/mx.sdk/mx_sdk_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def add_relative_home_path(self, language, path):
class LauncherConfig(AbstractNativeImageConfig):
def __init__(self, destination, jar_distributions, main_class, build_args, is_main_launcher=True,
default_symlinks=True, is_sdk_launcher=False, custom_launcher_script=None, extra_jvm_args=None,
use_modules=None, main_module=None, option_vars=None, home_finder=True, **kwargs):
use_modules=None, main_module=None, link_at_build_time=True, option_vars=None, home_finder=True, **kwargs):
"""
:param str main_class
:param bool is_main_launcher
Expand All @@ -174,6 +174,7 @@ def __init__(self, destination, jar_distributions, main_class, build_args, is_ma
self.main_module = main_module
assert self.use_modules is None or self.main_module
self.main_class = main_class
self.link_at_build_time = link_at_build_time
self.is_main_launcher = is_main_launcher
self.default_symlinks = default_symlinks
self.is_sdk_launcher = is_sdk_launcher
Expand Down
2 changes: 2 additions & 0 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,8 @@ def contents(self):
build_args += ['-ea', '-H:-AOTInline', '-H:+PreserveFramePointer', '-H:-DeleteLocalSymbols']
if _get_svm_support().is_debug_supported():
build_args += ['-g']
if getattr(image_config, 'link_at_build_time', True):
build_args += ['--link-at-build-time']

graalvm_dist = get_final_graalvm_distribution()
graalvm_location = dirname(graalvm_dist.find_single_source_location('dependency:' + self.subject.name))
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* Remove support for JDK8. As a result, `JDK8OrEarlier` and `JDK11OrLater` have been deprecated and will be removed in a future release.
* (GR-26814) (GR-37018) (GR-37038) Red Hat added support for the following JFR events: `SafepointBegin`, `SafepointEnd`, `GarbageCollection`, `GCPhasePause`, and `GCPhasePauseLevel*`. All GC-related JFR events are currently limited to the serial GC.
* (GR-35721) Deprecate `-H:±BuildOutputUseNewStyle` option. The old build output style will be removed in a future release.
* (GR-36905) Allow incomplete classes at build-time is now default. Add --link-at-build-time option and @<prop-values-file> support for native-image.properties. Add --link-at-build-time-paths option.

## Version 22.0.0
* (GR-33930) Decouple HostedOptionParser setup from classpath/modulepath scanning (use ServiceLoader for collecting options).
Expand Down
3 changes: 2 additions & 1 deletion substratevm/mx.substratevm/macro-junit.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ ImageClasspath = ${.}/junit-tool.jar:${.}/junit.jar:${.}/hamcrest.jar
Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
-H:TestFile=${*} \
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
[email protected]
3 changes: 2 additions & 1 deletion substratevm/mx.substratevm/macro-junitcp.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ ImageClasspath = ${.}/junit-support.jar:${.}/junit-tool.jar:${.}/junit.jar:${.}/
Args = -H:Features=com.oracle.svm.junit.JUnitFeature \
-H:Class=com.oracle.svm.junit.SVMJUnitRunner \
-H:TestFile=${*} \
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest
--initialize-at-build-time=org.junit,com.oracle.mxtool.junit.MxJUnitRequest \
[email protected]
2 changes: 2 additions & 0 deletions substratevm/mx.substratevm/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,7 @@
"description" : "Native-image based junit testing support",
"layout" : {
"native-image.properties" : "file:mx.substratevm/macro-junit.properties",
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
},
},

Expand All @@ -1611,6 +1612,7 @@
"description" : "Native-image based junit testing support but with running image-builder on classpath",
"layout" : {
"native-image.properties" : "file:mx.substratevm/macro-junitcp.properties",
"svm-junit.packages" : "file:mx.substratevm/svm-junit.packages",
},
},

Expand Down
18 changes: 18 additions & 0 deletions substratevm/mx.substratevm/svm-junit.packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
com.oracle.mxtool.junit
junit.framework
junit.runner
org.hamcrest
org.hamcrest.core
org.hamcrest.internal
org.junit
org.junit.internal
org.junit.internal.builders
org.junit.internal.runners.model
org.junit.internal.runners.statements
org.junit.rules
org.junit.runner
org.junit.runner.manipulation
org.junit.runner.notification
org.junit.runners
org.junit.runners.model
org.junit.validator
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,18 @@ public final class ReflectionConfigurationParser<T> extends ConfigurationParser
private static final String CONSTRUCTOR_NAME = "<init>";

private final ReflectionConfigurationParserDelegate<T> delegate;
private final boolean allowIncompleteClasspath;
private static final List<String> OPTIONAL_REFLECT_CONFIG_OBJECT_ATTRS = Arrays.asList("allDeclaredConstructors", "allPublicConstructors",
"allDeclaredMethods", "allPublicMethods", "allDeclaredFields", "allPublicFields",
"allDeclaredClasses", "allPermittedSubclasses", "allPublicClasses", "methods", "queriedMethods", "fields", CONDITIONAL_KEY,
"queryAllDeclaredConstructors", "queryAllPublicConstructors", "queryAllDeclaredMethods", "queryAllPublicMethods");

public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate) {
this(delegate, false, true);
this(delegate, true);
}

public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate, boolean allowIncompleteClasspath, boolean strictConfiguration) {
public ReflectionConfigurationParser(ReflectionConfigurationParserDelegate<T> delegate, boolean strictConfiguration) {
super(strictConfiguration);
this.delegate = delegate;
this.allowIncompleteClasspath = allowIncompleteClasspath;
}

@Override
Expand Down Expand Up @@ -282,19 +280,15 @@ private String formatMethod(T clazz, String methodName, List<T> paramTypes) {
return delegate.getTypeName(clazz) + '.' + methodName + '(' + parameterTypeNames + ')';
}

private void handleError(String message) {
private static void handleError(String message) {
handleError(message, null);
}

private void handleError(String msg, Throwable cause) {
private static void handleError(String msg, Throwable cause) {
String message = msg;
if (cause != null) {
message += " Reason: " + formatError(cause) + '.';
}
if (allowIncompleteClasspath) {
System.err.println("Warning: " + message);
} else {
throw new JSONParserException(message + " To allow unresolvable reflection configuration, use option --allow-incomplete-classpath");
}
System.err.println("Warning: " + message);
olpaw marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.oracle.svm.common.option.LocatableOption;
import com.oracle.svm.common.option.MultiOptionValue;
import org.graalvm.collections.Pair;

import com.oracle.svm.common.option.LocatableOption;
import com.oracle.svm.common.option.MultiOptionValue;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.util.ClassUtil;

Expand Down Expand Up @@ -76,8 +76,8 @@ public List<T> values() {
return values.stream().map(Pair::getLeft).collect(Collectors.toList());
}

public Stream<Pair<T, String>> getValuesWithOrigins() {
return values.stream();
public Stream<Pair<T, OptionOrigin>> getValuesWithOrigins() {
return values.stream().map(pair -> Pair.create(pair.getLeft(), OptionOrigin.from(pair.getRight())));
}

@Override
Expand Down
Loading