Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Add support for $NATIVE_IMAGE_ARGS.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Aug 1, 2022
1 parent 05f6853 commit 7b94940
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions docs/reference-manual/native-image/BuildOutput.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ The garbage collector used within the generated executable:
For more information see the [docs on Memory Management at Image Run Time](MemoryManagement.md).
#### <a name="glossary-env-args"></a>Environment Arguments
The list of additional arguments provided through the `$NATIVE_IMAGE_ARGS` environment variable.
#### <a name="glossary-user-specific-features"></a>User-Specific Features
All [`Features`](https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/hosted/Feature.html) that are either provided or specifically enabled by the user, or implicitly registered for the user, for example, by a framework.
GraalVM Native Image deploys a number of internal features, which are excluded from this list.
Expand Down
1 change: 1 addition & 0 deletions substratevm/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This changelog summarizes major changes to GraalVM Native Image.
* (GR-39390) (GR-39649) (GR-40033) Red Hat added support for the JFR events `JavaMonitorEnter`, `JavaMonitorWait`, and `ThreadSleep`.
* (GR-39497) Add `-H:BuildOutputJSONFile=<file.json>` option for [JSON build output](https://github.com/oracle/graal/edit/master/docs/reference-manual/native-image/BuildOutput.md#machine-readable-build-output). Please feel free to provide feedback so that we can stabilize the schema/API.
* (GR-40170) Add `--silent` option to silence the build output.
* (GR-40176) Add support for `$NATIVE_IMAGE_ARGS` environment variable that can be used, for example by tools, to inject additional build arguments.

## Version 22.2.0
* (GR-20653) Re-enable the usage of all CPU features for JIT compilation on AMD64.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ protected void onValueUpdate(EconomicMap<OptionKey<?>, Object> values, Boolean o
private static ValueUpdateHandler<OptimizationLevel> optimizeValueUpdateHandler;
private static ValueUpdateHandler<Integer> debugInfoValueUpdateHandler = SubstrateOptions::defaultDebugInfoValueUpdateHandler;

public static String environmentArguments() {
return System.getenv("NATIVE_IMAGE_ARGS");
}

@Fold
public static boolean getSourceLevelDebug() {
return SourceLevelDebug.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1749,18 +1749,22 @@ static List<Path> getJars(Path dir, String... jarBaseNames) {

private List<String> processNativeImageArgs() {
NativeImageArgsProcessor argsProcessor = new NativeImageArgsProcessor(null);
String defaultNativeImageArgs = getUserConfigProperties().get(pKeyNativeImageArgs);
if (defaultNativeImageArgs != null && !defaultNativeImageArgs.isEmpty()) {
for (String defaultArg : defaultNativeImageArgs.split(" ")) {
argsProcessor.accept(defaultArg);
}
}
processOptionalArguments(argsProcessor, getUserConfigProperties().get(pKeyNativeImageArgs));
processOptionalArguments(argsProcessor, SubstrateOptions.environmentArguments());
for (String arg : config.getBuildArgs()) {
argsProcessor.accept(arg);
}
return argsProcessor.apply(false);
}

private static void processOptionalArguments(NativeImageArgsProcessor argsProcessor, String additionalArgumentsOrNull) {
if (additionalArgumentsOrNull != null && !additionalArgumentsOrNull.isEmpty()) {
for (String defaultArg : additionalArgumentsOrNull.split(" ")) {
argsProcessor.accept(defaultArg);
}
}
}

protected String getXmsValue() {
return "1g";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ public void printInitializeEnd() {
String gcName = Heap.getHeap().getGC().getName();
recordJsonMetric(GeneralInfo.GC, gcName);
l().a(" ").doclink("Garbage collector", "#glossary-gc").a(": ").a(gcName).println();
String environmentArguments = SubstrateOptions.environmentArguments();
if (environmentArguments != null && !environmentArguments.isEmpty()) {
l().a(" ").doclink("Environment arguments", "#glossary-env-args").a(": '").a(environmentArguments).a("'").println();
}
}

public void printFeatures(List<Feature> features) {
Expand Down

0 comments on commit 7b94940

Please sign in to comment.