-
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: extended native-image build options
- feat: add experimental build setting which controls the `march` parameter - feat: explicit settings with `native_image_settings`, flag overrides with `native_image_info` - fix: preserve legacy rules `march` flag (missing by default) Not yet implemented: Needs integration with Bazel's platforms feature. Signed-off-by: Sam Gammon <[email protected]>
- Loading branch information
Showing
11 changed files
with
211 additions
and
1 deletion.
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,11 @@ | ||
"Defines targets and enumerations for various Native Image builder options." | ||
|
||
load( | ||
"//internal/native_image/options:arch.bzl", | ||
_NativeImageArchitecture = "NativeImageArchitecture", | ||
) | ||
|
||
# Exports | ||
|
||
# buildifier: disable=name-conventions | ||
NativeImageArchitecture = _NativeImageArchitecture |
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,14 @@ | ||
load( | ||
"//internal/native_image/options:arch.bzl", | ||
"arch", | ||
"NativeImageArchitecture", | ||
) | ||
|
||
package(default_visibility = [ | ||
"//visibility:public", | ||
]) | ||
|
||
arch( | ||
name = "arch", | ||
build_setting_default = NativeImageArchitecture.COMPATIBILITY, | ||
) |
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
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,10 @@ | ||
package(default_visibility = [ | ||
"//graalvm/nativeimage/options:__pkg__", | ||
"//graalvm/nativeimage/options:__subpackages__", | ||
"//internal:__pkg__", | ||
"//internal:__subpackages__", | ||
]) | ||
|
||
exports_files([ | ||
"arch.bzl", | ||
]) |
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,50 @@ | ||
"Defines provider info for various Native Image build options." | ||
|
||
_SETTING_ARCH_DEFAULT = "//graalvm/nativeimage/options:arch" | ||
|
||
# buildifier: disable=name-conventions | ||
_NativeImageArchitecture = struct( | ||
COMPATIBILITY = "compatibility", | ||
NATIVE = "native", | ||
AMD_64 = "amd64", | ||
ARM_64 = "amd64", | ||
) | ||
|
||
_NativeImageArchInfo = provider( | ||
fields = ["target_arch"], | ||
doc = "Provides target architecture selection support for GraalVM native image targets.", | ||
) | ||
|
||
supported_architectures = [ | ||
_NativeImageArchitecture.COMPATIBILITY, | ||
_NativeImageArchitecture.NATIVE, | ||
_NativeImageArchitecture.AMD_64, | ||
_NativeImageArchitecture.ARM_64, | ||
] | ||
|
||
def _native_image_arch_impl(ctx): | ||
target_arch = ctx.build_setting_value | ||
if target_arch not in supported_architectures: | ||
fail(str(ctx.label) + " build setting allowed to take values {" | ||
+ ", ".join(supported_architectures) + "} but was set to unallowed value " | ||
+ target_arch) | ||
|
||
return _NativeImageArchInfo( | ||
target_arch = target_arch, | ||
) | ||
|
||
# Exports. | ||
|
||
# buildifier: disable=name-conventions | ||
NativeImageArchitecture = _NativeImageArchitecture | ||
|
||
NativeImageArchInfo = _NativeImageArchInfo | ||
|
||
SETTING_ARCH_DEFAULT = _SETTING_ARCH_DEFAULT | ||
|
||
arch = rule( | ||
implementation = _native_image_arch_impl, | ||
build_setting = config.string( | ||
flag = True, | ||
) | ||
) |
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.