-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
improve detection of how to execute binaries on the host #10265
Merged
Merged
Conversation
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
from zig-specific options to generally recognized zig build options that any project can take advantage of. See the updated usage text for more details.
demo of 4f40d8e:
|
andrewrk
force-pushed
the
zig-build-executors
branch
from
December 3, 2021 00:34
4f40d8e
to
0522713
Compare
Previously when using `zig run` or `zig test`, zig would try to guess whether the host system was capable of running the target binaries. Now, it will always try. If it fails, then Zig emits a helpful warning to explain the probable cause.
andrewrk
force-pushed
the
zig-build-executors
branch
from
December 3, 2021 00:40
0522713
to
0cd8710
Compare
I think the next step is going to be moving /// Note that even a `CrossTarget` which returns `false` for `isNative` could still be natively executed.
/// For example `-target arm-native` running on an aarch64 host.
pub fn getExternalExecutor(self: CrossTarget) Executor { to const NativeTargetInfo = std.zig.system.NativeTargetInfo;
pub fn detect(host: NativeTargetInfo, target: NativeTargetInfo) Executor { This will make it correctly attempt to execute, e.g. 32-bit arm binaries on 64-bit arm hosts. It will also make it aware of dynamic linker incompatibilities. |
`getExternalExecutor` is moved from `std.zig.CrossTarget` to `std.zig.system.NativeTargetInfo.getExternalExecutor`. The function also now communicates a bit more information about *why* the host is unable to execute a binary. The CLI is updated to report this information in a useful manner. `getExternalExecutor` is also improved to detect such patterns as: * x86_64 is able to execute x86 binaries * aarch64 is able to execute arm binaries * etc. Added qemu-hexagon support to `getExternalExecutor`. `std.Target.canExecBinaries` of is removed; callers should use the more powerful `getExternalExecutor` instead. Now that `zig test` tries to run the resulting binary no matter what, this commit has a follow-up change to the build system and docgen to utilize the `getExternalExecutor` function and pass `--test-no-exec` in some cases to avoid getting the error. Additionally: * refactor: extract NativePaths and NativeTargetInfo into their own files named after the structs. * small improvement to langref to reduce the complexity of the `callconv` expression in a couple examples.
Observed on aarch64-macos when trying to execute an x86_64-macos binary.
andrewrk
changed the title
zig build: promote qemu, wine, wasmtime, darling, and rosetta
improve detection of how to execute binaries on the host
Dec 3, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
from zig-specific options to generally recognized zig build options that any project can take advantage of. See the updated usage text for more details.
Prerequisite to #10143 (cc @nuald)
Next I want to look at
getExternalExecutor
and consider moving it fromCrossTarget
toTarget
, or otherwise resolve those TODO comments. There is also this:I think this should probably be removed and
zig test
would unconditionally try to execute the test binary. You'd have to pass--test-no-exec
to disable this. As long as the error message is nice and clear this should be OK. Reasoning for this is that we want to keep awareness of qemu, wine, etc. in the zig build system and out of the zig compiler itself.Also the code that calls
getExternalExecutor
is duplicated in std/build.zig and src/test.zig and I want to resolve that.End goal here is that in a build.zig you could declaratively use a RunStep, without putting any logic inside build.zig to disable it. The RunStep itself would potentially emit an error if the build graph required it to be run, and there were no executors available to run it.