Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Nov 6, 2023

This PR adds support for the NATIVE_IMAGE_OPTIONS environment variable, which allows users and tools to pass additional arguments via the environment. Similar to JAVA_TOOL_OPTIONS, the value of the environment variable is prepended to the options supplied to native-image.

Here's an example that shows how NATIVE_IMAGE_OPTIONScan be used to turn on the quick build mode:

$ NATIVE_IMAGE_OPTIONS="-Ob" native-image -m jdk.httpserver
========================================================================================================================
GraalVM Native Image: Generating 'jdk.httpserver' (executable)...
========================================================================================================================
[1/8] Initializing...                                                                                    (5.0s @ 0.19GB)
 Java version: 22+18, vendor version: Oracle GraalVM 22-dev+18.1
 Graal compiler: optimization level: b, target machine: x86-64-v3, PGO: off
 C compiler: gcc (linux, x86_64, 13.2.0)
 Garbage collector: Serial GC (max heap size: 80% of RAM)
 1 user-specific feature(s):
 - com.oracle.svm.thirdparty.gson.GsonFeature
------------------------------------------------------------------------------------------------------------------------
 Picked up NATIVE_IMAGE_OPTIONS:
 - '-Ob'
------------------------------------------------------------------------------------------------------------------------
...

To allow previous build steps to add additional options (as opposed to overwriting them), consider using:

  • NATIVE_IMAGE_OPTIONS="${NATIVE_IMAGE_OPTIONS} -Ob" native-image ... to append -Ob; or
  • NATIVE_IMAGE_OPTIONS="-Ob ${NATIVE_IMAGE_OPTIONS}" native-image ... to prepend -Ob.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Nov 6, 2023
@graalvmbot graalvmbot force-pushed the fniephaus/GR-39407/native-image-env branch from 90dfce1 to ae2de06 Compare November 6, 2023 21:18
@graalvmbot graalvmbot merged commit ebc75fa into master Nov 7, 2023
@graalvmbot graalvmbot deleted the fniephaus/GR-39407/native-image-env branch November 7, 2023 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

2 participants