-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- feat: detect and honor `compilation_mode` flag - feat: build with debug settings if `compilation_mode=dbg` - feat: ability to build a shared library - feat: build with `tool:coverage` if coverage is enabled and a test-only target is being built - docs: add doc which explains shared library feature - docs: add doc for built settings integration (more to come) Relates-To: #78 Relates-To: #85 Signed-off-by: Sam Gammon <sam@elide.ventures>
- Loading branch information
Showing
15 changed files
with
412 additions
and
84 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## How Bazel settings integrate with Native Image | ||
|
||
Several familiar Bazel settings are integrated into the Native Image build pipeline, so that conventional use of Bazel | ||
features translates relatively well to Native Image option control. See the table below for more information. | ||
|
||
### Compilation mode | ||
|
||
> Flag: [`--compilation_mode`][1] or [`-c`][1] | ||
| **Flag setting** | **Effective `native-image` options** | **Notes** | | ||
| ---------------- | ------------------------------------ | ------------------------------------------ | | ||
| `dbg` | `-g` | No optimization flag set | | ||
| `fastbuild` | `-Ob` | Activates GraalVM [fast build][2] mode | | ||
| `opt` | `-O2` | Builds with optimizations turned on | | ||
| (None set) | (Nothing passed) | Default GraalVM behavior builds with `-O2` | | ||
|
||
[1]: https://bazel.build/docs/user-manual#compilation-mode | ||
[2]: https://www.graalvm.org/latest/reference-manual/native-image/overview/BuildOutput/#build-stages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Shared libraries with GraalVM and Bazel | ||
|
||
GraalVM can build [native shared libraries][1] from Java or polyglot code. This functionality is integrated with these | ||
rules, via the `shared_library` target attribute on `native_image`: | ||
|
||
```python | ||
load("@rules_graalvm//:defs.bzl", "native_image") | ||
``` | ||
|
||
```python | ||
java_library( | ||
name = "example", | ||
srcs = ["..."], | ||
) | ||
|
||
native_image( | ||
name = "some_name", | ||
shared_library = True, | ||
deps = [ | ||
":example", | ||
], | ||
) | ||
``` | ||
|
||
### How `main_class` works with shared libraries | ||
|
||
Even when building a shared library, GraalVM typically needs a `main_class`. Instead of becoming a runnable entrypoint, | ||
the `main_class` is used by the Native Image compiler as the starting point for points-to analysis and code gen. | ||
|
||
Alternatively, the [`@CEntryPoint` API][2] can be used to define library entrypoints. See [here][3] for more information. | ||
|
||
[1]: https://www.graalvm.org/latest/reference-manual/native-image/guides/build-native-shared-library/ | ||
[2]: https://www.graalvm.org/sdk/javadoc/org/graalvm/nativeimage/c/function/CEntryPoint.html | ||
[3]: https://www.graalvm.org/latest/reference-manual/native-image/guides/build-native-shared-library/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.