-
Notifications
You must be signed in to change notification settings - Fork 78
refactor: register toolchains with @zig_sdk//...
#207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
08c2ab4 to
29c90bd
Compare
|
Do you think it possible to keep the toolchain in their current locations, and register with: |
|
Hi @linzhp, thanks for having a look. register_toolchains(
"@zig_sdk//toolchain/linux-amd64/...",
"@zig_sdk//libc_aware/toolchain/windows-arm64/...",
)Yeah, I guess this is doable 😄 I will try to merge both repos then. |
@zig_sdk//...
@zig_sdk//...@zig_sdk//...
Can we have the same behavior for MODULE.bazel? I saw toolchains like |
Yes, that was because module extension has always pass With the latest change Only toolchains for an additional execution platforms will be placed in corresponding subpackage, e.g. for |
BREAKING CHANGE: `zig_toolchains` reposotory
holds all toolchains definitions.
Simplify toolchain registering API.
MODULE.bazel:
`toolchain` module_extension now creates repositories:
- `@zig_skd`: holds all common platforms & constraints
definitions
- `zig_config-{os}-{arch}`: contains toolchain config rules
and all needed targets to register toolchains for particular
platform
- `zig_toolchains`: holds all supported toolchain
definitions.
WORKSPACE:
The difference here is that only one
`@zig_config` repository will be created for the
host platform. `@zig_sdk` & `zig_toolchains` are the
same as for bzlmod case.
Possible toolchain registration with:
```py
register_toolchains(
"@zig_toolchains//...",
)
```
Make toolchain for zig wrapper target.
Define zig wrapper toolchain targets for every supported platform.
Use zig wrapper toolchain for `zig_binary` rule.
As we now registers all available toolchains with
`register_toolchains("@zig_toolchains//...")` the first
one registered who will match is `linux_amd64_gnu.2.17`.
Reference:
https://bazel.build/extending/toolchains#toolchain-resolution
Update documentation with the `@zig_sdk`,
`@zig_toolchains` and `@zig_config-{os}-{arch}`
repository changes.
Move/rename definitions/files to make all more consistent as a whole.
Fix bazel queries to print particular targets of `@zig_sdk` & `@zig_toolchains` repositories.
`hermetic_cc_toolchain` does not supports MacOS SDK thus do not register affected toolchains (uber#10). Add missing alias for host `zig`: - `@zig_sdk//:zig`
Separate `@zig_toolchains` repository makes to big noise thus all toolchain definitions should go to `@zig_sdk`. Merge `@zig_toolchains` repository into `@zig_sdk`.
3045429 to
2c79f8e
Compare
linzhp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, rules can depend on the zig binary with something like:
"_compiler": attr.label(
executable = True,
cfg = "exec",
default = "@zig_sdk//:zig",
allow_single_file = True,
),Can we continue to support this usage? With this PR, such rules would fail with:
alias '@@zig_sdk//:zig' referring to target '@@zig_config//:zig' is not visible from target '//some/package:target'. Check the visibility declaration of the former target if you think the dependency is legitimate. To set the visibility of that source file target, use the exports_files() function
Create toolchains for HOST execution platform in
default location of:
```
"@zig_sdk//toolchain/...",
"@zig_sdk//libc_aware/toolchain/...",
```
Add `sdk` tag class for module extention to specify
additional exwcution platforms than HOST. Those will
have additional _subpackage_ of `{os}-{arch}` i.e.
```
"@zig_sdk//toolchain/{os}-{arch}/...",
"@zig_sdk//libc_aware/toolchain/{os}-{arch}/...",
```
2c79f8e to
1e3a563
Compare
We can, but this would be wrong choice. Having E.g. you can have: @zig_sdk//toolchain:zig # HOST execution platform
@zig_sdk//toolchain/macos-arm64:zig # macos-arm64 execution platformThis way rules/zig_binary can be called freely in every registered execution platform. When it comes to |
@zig_sdkrepository to hold all toolchain definitions.Simplify toolchain registering API.
MODULE.bazel:
toolchainmodule_extension now creates repositories of:@zig_sdk: holds all common platform, constraint and all supported toolchain definitions@zig_config-{os}-{arch}: contains toolchain config rules and all needed targets to register toolchains for particular platformWORKSPACE:
Comparing to above, the difference here is that by default (means no
exec_platformsattr passed tozig_toolchains()call) only one@zig_configrepository will be created for the host platform@zig_sdkis the same as forbzlmodcase.Possible toolchains registration with:
@zig_config*repo(s) is/are not visible to main repository.Resolves #204 & Closes #204