Skip to content

Commit d56c156

Browse files
LesiaChabanolyagpl
authored andcommitted
[GR-48336] Update Native Image build options documentation.
PullRequest: graal/15482
2 parents 266a13b + 8280e60 commit d56c156

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

docs/reference-manual/native-image/BuildOptions.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,50 @@ Depending on the GraalVM version, the options to the `native-image` builder may
1515
* `--add-modules <module name>[,<module name>...]`: add root modules to resolve in addition to the initial module. `<module name>` can also be `ALL-DEFAULT`, `ALL-SYSTEM`, `ALL-MODULE-PATH`.
1616
* `-D<name>=<value>`: set a system property
1717
* `-J<flag>`: pass an option directly to the JVM running the `native-image` builder
18-
* `--diagnostics-mode`: enable diagnostics output which includes class initialization, substitutions, etc.
18+
* `--diagnostics-mode`: enable diagnostics output: class initialization, substitutions, etc.
1919
* `--enable-preview`: allow classes to depend on preview features of this release
20-
* `--enable-native-access <module name>[,<module name>...]` modules that are permitted to perform restricted native operations. `<module name>` can also be `ALL-UNNAMED`.
20+
* `--enable-native-access <module name>[,<module name>...]`: enable modules that are permitted to perform restricted native operations. `<module name>` can also be `ALL-UNNAMED`
2121
* `--verbose`: enable verbose output
2222
* `--version`: print the product version and exit
2323
* `--help`: print this help message
2424
* `--help-extra`: print help on non-standard options
25-
* `--auto-fallback`: build standalone native executable if possible
25+
* `--auto-fallback`: build a standalone executable if possible
26+
* `--color`: color build output (`always`, `never`, or `auto`)
2627
* `--configure-reflection-metadata`: enable runtime instantiation of reflection objects for non-invoked methods
27-
* `--enable-all-security-services`: add all security service classes to a generated native executable
28+
* `--enable-all-security-services`: add all security service classes to the generated native executable
2829
* `--enable-http`: enable HTTP support in a native executable
2930
* `--enable-https`: enable HTTPS support in a native executable
3031
* `--enable-monitoring`: enable monitoring features that allow the VM to be inspected at run time. A comma-separated list can contain `heapdump`, `jfr`, `jvmstat`, `jmxserver` (experimental), `jmxclient` (experimental), or `all` (deprecated behavior: defaults to `all` if no argument is provided). For example: `--enable-monitoring=heapdump,jfr`.
31-
* `--enable-sbom`: embed a Software Bill of Materials (SBOM) in a native executable or shared library for passive inspection. A comma-separated list can contain `cyclonedx`, `strict` (defaults to `cyclonedx` if no argument is provided), or `export` to save the SBOM to the native executable's output directory. The optional `strict` flag aborts the build if any class cannot be matched to a library in the SBOM. For example: `--enable-sbom=cyclonedx,strict`. (Not available in GraalVM Community Edition.)
32+
* `--enable-sbom`: embed a Software Bill of Materials (SBOM) in the executable or shared library for passive inspection. A comma-separated list can contain `cyclonedx`, `strict` (defaults to `cyclonedx` if no argument is provided), or `export` to save the SBOM to the native executable's output directory. The optional `strict` flag aborts the build if any class cannot be matched to a library in the SBOM. For example: `--enable-sbom=cyclonedx,strict`. (Not available in GraalVM Community Edition.)
3233
* `--enable-url-protocols`: list comma-separated URL protocols to enable
3334
* `--features`: a comma-separated list of fully qualified [Feature implementation classes](https://www.graalvm.org/sdk/javadoc/index.html?org/graalvm/nativeimage/hosted/Feature.html)
3435
* `--force-fallback`: force building of a fallback native executable
35-
* `--gc=<value>`: select Native Image garbage collector implementation. Allowed options for `<value>` are: `G1` for G1 garbage collector (not available in GraalVM Community Edition); `epsilon` for Epsilon garbage collector; `serial` for Serial garbage collector (default).
36+
* `--gc=<value>`: select a Native Image garbage collector implementation. Allowed options for `<value>` are: `G1` for G1 garbage collector (not available in GraalVM Community Edition); `epsilon` for Epsilon garbage collector; `serial` for Serial garbage collector (default).
3637
* `--initialize-at-build-time`: a comma-separated list of packages and classes (and implicitly all of their superclasses) that are initialized during generation of a native executable. An empty string designates all packages.
3738
* `--initialize-at-run-time`: a comma-separated list of packages and classes (and implicitly all of their subclasses) that must be initialized at run time and not during generation. An empty string is currently not supported.
3839
* `--install-exit-handlers`: provide `java.lang.Terminator` exit handlers
3940
* `--libc`: select the `libc` implementation to use. Available implementations are `glibc`, `musl`, `bionic`.
40-
* `--link-at-build-time`: require types to be fully defined at executable's build time. If used without arguments, all classes in scope of the option are required to be fully defined.
41-
* `--link-at-build-time-paths`: require all types in given class or module-path entries to be fully defined at at executable's build time
41+
* `--link-at-build-time`: require types to be fully defined at native executable build time. If used without arguments, all classes in scope of the option are required to be fully defined.
42+
* `--link-at-build-time-paths`: require all types in given class or module path entries to be fully defined at native executable build time
4243
* `--list-cpu-features`: show CPU features specific to the target platform and exit
4344
* `--list-modules`: list observable modules and exit
4445
* `--native-compiler-options`: provide a custom C compiler option used for query code compilation
4546
* `--native-compiler-path`: provide a custom path to the C compiler used to query code compilation and linking
4647
* `--native-image-info`: show the native toolchain information and executable's build settings
4748
* `--no-fallback`: build a standalone native executable or report a failure
48-
* `--pgo`: a comma-separated list of files from which to read the data collected for profile-guided optimizations of AOT-compiled code (reads from _default.iprof_ if nothing is specified). (Not available in GraalVM Community Edition.)
49-
* `--pgo-instrument`: instrument AOT-compiled code to collect data for profile-guided optimizations into the _default.iprof_ file. (Not available in GraalVM Community Edition.)
49+
* `--parallelism`: specify the maximum number of threads to use concurrently during native executable generation
50+
* `--pgo`: provide a comma-separated list of files from which to read the data collected for Profile-guided optimization of AOT-compiled code (reads from _default.iprof_ if nothing is specified). Each file must contain a single `PGOProfiles` object, serialized in JSON format, optionally compressed by gzip. (Not available in GraalVM Community Edition.)
51+
* `--pgo-instrument`: instrument AOT-compiled code to collect data for Profile-guided optimization into the _default.iprof_ file. (Not available in GraalVM Community Edition.)
52+
* `--pgo-sampling`: perform profiling by sampling the AOT compiled code to collect data for Profile-guided optimization. (Not available in GraalVM Community Edition.)
5053
* `--report-unsupported-elements-at-runtime`: report the usage of unsupported methods and fields at run time when they are accessed the first time, instead of an error during executable's building
5154
* `--shared`: build a shared library
5255
* `--silent`: silence build output
5356
* `--static`: build a statically-linked executable (requires `libc` and `zlib` static libraries)
54-
* `--target`: select the compilation target for `native-image` (in <OS>-<architecture> format). It defaults to host's OS-architecture pair.
57+
* `--strict-image-heap`: enable the strict image heap mode that allows all classes to be used at build-time but also requires types of all objects in the heap to be explicitly marked for build-time initialization.
58+
* `--target`: select the compilation target for `native-image` (in the `<OS>-<architecture>` format). It defaults to host's OS-architecture pair.
5559
* `--trace-class-initialization`: provide a comma-separated list of fully-qualified class names that a class initialization is traced for
5660
* `--trace-object-instantiation`: provide a comma-separated list of fully-qualified class names that an object instantiation is traced for
57-
* `-O<level>`: control code optimizations where available variants are `b` for quick build mode for development, `0` - no optimizations, `1` - basic optimizations, `2` - aggressive optimizations (default)
61+
* `-O<level>`: control code optimizations where available variants are: `b` - optimize for fastest build time, `0` - no optimizations, `1` - basic optimizations, `2` - aggressive optimizations, `3` - all optimizations for best performance (enabled automatically with the Profile-guided optimization)
5862
* `-da`, `-da[:[packagename]|:[classname]`, `disableassertions[:[packagename]|:[classname]`: disable assertions with specified granularity at run time
5963
* `-dsa`, `-disablesystemassertions`: disable assertions in all system classes at run time
6064
* `-ea`, `-ea[:[packagename]|:[classname]`, `enableassertions[:[packagename]|:[classname]`: enable assertions with specified granularity at run time
@@ -65,37 +69,33 @@ Depending on the GraalVM version, the options to the `native-image` builder may
6569

6670
### Macro Options
6771

68-
* `--language:nfi`: make the Truffle Native Function Interface language available
69-
* `--tool:coverage`: add source code coverage support to a GraalVM-supported language
70-
* `--tool:insight`: add support for detailed access to program's runtime behavior, allowing users to inspect values and types at invocation or allocation sites
71-
* `--tool:dap`: allow image to open a debugger port serving the Debug Adapter Protocol in IDEs like Visual Studio Code
72-
* `--tool:chromeinspector`: add debugging support to a GraalVM-supported language
73-
* `--tool:insightheap`: snapshot a region of image heap during the execution
74-
* `--tool:lsp`: add the Language Server Protocol support to later attach compatible debuggers to GraalVM in IDEs like Visual Studio Code
75-
* `--tool:sandbox`: enables the Truffle sandbox resource limits. For more information, check the [dedicated documentation](../../security/polyglot-sandbox.md)
76-
* `--tool:profiler`: add profiling support to a GraalVM-supported language
77-
78-
The `--language:js` `--language:nodejs`, `--language:python`, `--language:ruby`, `--language:R`, `--language:wasm`, `--language:llvm`, `--language:regex` (enables the Truffle Regular Expression engine) polyglot macro options become available once the corresponding languages are added to the base GraalVM JDK.
72+
* `--macro:native-image-agent-library`
73+
* `--macro:native-image-configure-launcher`
74+
* `--macro:native-image-diagnostics-agent-library`
75+
* `--macro:native-image-launcher`
7976

8077
### Non-standard Options
8178

8279
Run `native-image --help-extra` for non-standard options help.
8380

84-
* `--exclude-config`: exclude configuration for a comma-separated pair of classpath/modulepath pattern and resource pattern. For example: '--exclude-config foo.jar,META-INF\/native-image\/.*.properties' ignores all .properties files in 'META-INF/native-image' in all JARs named 'foo.jar'.
81+
* `--exclude-config`: exclude configuration for a comma-separated pair of classpath/modulepath pattern and resource pattern. For example: `--exclude-config foo.jar,META-INF\/native-image\/.*.properties` ignores all .properties files in _META-INF/native-image_ in all JARs named _foo.jar`-.
8582
* `--expert-options`: list image build options for experts
86-
* `--expert-options-all `: list all image build options for experts (use at your own risk). Options marked with _Extra help available_ contain help that can be shown with `--expert-options-detail`
83+
* `--expert-options-all`: list all image build options for experts (use at your own risk). Options marked with _Extra help available_ contain help that can be shown with `--expert-options-detail`
8784
* `--expert-options-detail`: display all available help for a comma-separated list of option names. Pass `*` to show extra help for all options that contain it.
8885
* `--configurations-path <search path of option-configuration directories>`: a separated list of directories to be treated as option-configuration directories.
89-
* `--debug-attach[=< port (* can be used as host meaning bind to all interfaces)>]`: attach to debugger during image building (default port is 8000)
86+
* `--debug-attach[=<port or host:port (* can be used as host meaning bind to all interfaces)>]`: attach to a debugger during native executable generation (default port is 8000)
9087
* `--diagnostics-mode`: Enables logging of image-build information to a diagnostics folder.
9188
* `--dry-run`: output the command line that would be used for building
92-
* `--bundle-create[=new-bundle.nib]`: in addition to image building, create a native image bundle file _(*.nibfile)_ that allows rebuilding of that image again at a later point. If a bundle-file gets passed the bundle will be created with the given name. Otherwise, the bundle-file name is derived from the image name. Note both bundle options can be combined with `--dry-run` to only perform the bundle operations without any actual image building.
93-
* `--bundle-apply=some-bundle.nib`: an image will be built from the given bundle file with the exact same arguments and files that have been passed to Native Image originally to create the bundle. Note that if an extra `--bundle-create` gets passed after `--bundle-apply`, a new bundle will be written based on the given bundle args plus any additional arguments that haven been passed afterwards. For example: `native-image --bundle-apply=app.nib --bundle-create=app_dbg.nib -g` creates a new bundle <app_dbg.nib> based on the given _app.nib_ bundle. Both bundles are the same except the new one also uses the -g option.
94-
* `-E<env-var-key>[=<env-var-value>]`: allow Native Image to access the given environment variable during image build. If the optional <env-var-value> is not given, the value of the environment variable will be taken from the environment Native Image was invoked from.
95-
* `-V<key>=<value>`: provide values for placeholders in `native-image.properties` files
89+
* `--bundle-create[=new-bundle.nib]`: in addition to image building, create a native image bundle file _(*.nibfile)_ that allows rebuilding of that image again at a later point. If a bundle file gets passed, the bundle will be created with the given name. Otherwise, the bundle file name is derived from the image name. Note both bundle options can be extended with `dry-run` and `container`.
90+
- `dry-run`: only perform the bundle operations without any actual native executable building
91+
- `container`: set up a container image and perform a native executable generation from inside that container. Requires Podman or rootless Docker to be installed. If available, Podman is preferred and rootless Docker is the fallback. Specifying one or the other as `=<container-tool>` forces the use of a specific tool.
92+
- `dockerfile=<Dockerfile>`: use a user provided `Dockerfile` instead of the default based on [Oracle Linux 8 base images for GraalVM](https://github.com/graalvm/container)
93+
* `--bundle-apply=some-bundle.nib[,dry-run][,container[=<container-tool>][,dockerfile=<Dockerfile>]]`: an image will be built from the given bundle file with the exact same arguments and files that have been passed to Native Image originally to create the bundle. Note that if an extra `--bundle-create` gets passed after `--bundle-apply`, a new bundle will be written based on the given bundle args plus any additional arguments that haven been passed afterwards. For example: `native-image --bundle-apply=app.nib --bundle-create=app_dbg.nib -g` creates a new bundle _app_dbg.nib_ based on the given _app.nib_ bundle. Both bundles are the same except the new one also uses the `-g` option.
94+
* `-E<env-var-key>[=<env-var-value>]`: allow Native Image to access the given environment variable during native executable generation. If the optional `<env-var-value>` is not given, the value of the environment variable will be taken from the environment Native Image was invoked from.
95+
* `-V<key>=<value>`: provide values for placeholders in the _native-image.properties_ files
9696
* `--add-exports`: value `<module>/<package>=<target-module>(,<target-module>)` updates `<module>` to export `<package>` to `<target-module>`, regardless of module declaration. `<target-module>` can be `ALL-UNNAMED` to export to all unnamed modules
97-
* `--add-opens`: value `<module>/<package>=<target-module>(,<target-module>)` updates `<module>` to open `<package>` to `<target-module>`, regardless of module declaration.
98-
* `--add-reads`: value `<module>=<target-module>(,<target-module>)` updates `<module>` to read `<target-module>`, regardless of module declaration. `<target-module>` can be `ALL-UNNAMED` to read all unnamed modules.
97+
* `--add-opens`: value `<module>/<package>=<target-module>(,<target-module>)` updates `<module>` to open `<package>` to `<target-module>`, regardless of module declaration
98+
* `--add-reads`: value `<module>=<target-module>(,<target-module>)` updates `<module>` to read `<target-module>`, regardless of module declaration. `<target-module>` can be `ALL-UNNAMED` to read all unnamed modules
9999

100100
Native Image options are also distinguished as [hosted and runtime options](HostedvsRuntimeOptions.md).
101101

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,6 @@ More precisely, this mode reduces the number of optimizations performed by the G
304304
The quick build mode is not only useful for development, it can also cause the generated executable file to be smaller in size.
305305
Note, however, that the overall peak throughput of the executable may be lower due to the reduced number of optimizations.
306306
307-
308307
## Resource Usage Statistics
309308
310309
#### <a name="glossary-garbage-collection"></a>Garbage Collections
@@ -340,6 +339,12 @@ Traceback (most recent call last):
340339
AssertionError: Too many reachable methods: 12128
341340
```
342341
342+
## Colorful Build Output
343+
344+
By default, the `native-image` builder colors the build output for better readability when it finds an appropriate terminal.
345+
It also honors the <a href="https://no-color.org" target="_target">`NO_COLOR`</a>, `CI`, and `TERM` environment variables when checking for color support.
346+
To explicitly control colorful output, set the `--color` option to `always`, `never`, or `auto` (default).
347+
343348
## Related Documentation
344349
345350
- [Build a Native Shared Library](guides/build-native-shared-library.md)

0 commit comments

Comments
 (0)