-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Lazily compile the zig rc
subcommand and use it during zig build-exe
, etc
#19174
Conversation
For error messages, one option is std.zig.ErrorBundle. If you use this API to build your errors then it offers both a way to render to stderr as well as a trivially serializable representation which could be used to communicate with a parent process. Perhaps the parent process would set a flag and then receive that format on stdout. Or, for more flexibility, use std.zig.Server over stdout/stdin just like the test runner and some other components do. |
If the lazily compiled It's the (potential) lazy compiliation of the |
Commit |
That affects all the lazily built commands right? I can add a commit to address that for you. I'm generally displeased with std.Progress currently. I think it leaves a lot of room for improvement. |
Yes, that'd be great.
Thanks for the heads up. I should have seen this coming, really--this is what I did when using clang as the preprocessor: zig/src/resinator/preprocess.zig Lines 56 to 68 in 0b744da
|
3545808
to
76e019e
Compare
Got error messages working ~nicely using Some fairly nice examples: And some that might still need some work since they don't give enough context: @Vexu you might want to take a look at aroDiagnosticsToErrorBundle on the off-chance that's something that Aro might want to provide itself--it's entirely possible there'd be little use-case for it outside of |
Maybe not Aro itself should provide it but the Aro based translate-c is going to need it. |
5f690d6
to
37d24c2
Compare
Got progress working when the resinator binary is not in the cache: zig-rc-progress2-crop.mp4but there are some potential issues that I'm not sure about:
One thing I can think of that might fix both of these would be to:
I'm not sure if that's a good idea, though, or where exactly the initial check would go. |
It's fine actually - Zig's cache system ensures that two processes executed at the same time coordinate when they would produce the same cache artifacts. One of them will win the race and start working on the compilation while the other one waits patiently to reuse the results. As for the other issue, I think it would be OK to accept that tradeoff, but also your solution seems reasonable too. |
Some data points on this branch: A ReleaseSmall build of zig goes from 9.9M to 9.7M (-3%). Similar reduction in time to build the compiler:
|
Thanks for the benchmark, I was planning on doing that as well. Note that this PR also switches resinator to use Aro instead of clang, meaning the benchmark is not necessarily a complete comparison. In other words, instead of going from "built-in resinator with clang" -> "built-in resinator with aro" -> "lazily compiled resinator with aro", we're going from (1) to (3), whereas the transition from (2) to (3) might have shown larger savings. |
EDIT: You can ignore the text below if you'd like, fixed the progress bar in @andrewrk could you briefly explain how the two I'm wondering why that is the case, and whether or not it would make sense to do something like: if (progress_string.len > 0) {
server.serveMessage(.{
.tag = .progress,
.bytes_len = @as(u32, @intCast(progress_string.len)),
}, &.{
progress_string,
}) catch |err| {
fatal("unable to write to client: {s}", .{@errorName(err)});
};
} That'd solve my particular problem but unsure if it'd cause other problems elsewhere. |
Marking this as ready for review. Some testing done:
I also tried confirming that |
This moves .rc/.manifest compilation out of the main Zig binary, contributing towards ziglang#19063 Also: - Make resinator use Aro as its preprocessor instead of clang - Sync resinator with upstream
This takes the code that was previously in src/Compilation.zig to turn resinator diagnostics into Zig error bundles and puts it in resinator/main.zig, and then makes resinator emit the resulting error bundles via std.zig.Server (which is used by the build runner, etc). Also adds support for turning Aro diagnostics into ErrorBundles.
Also adds a test for addBundleAsRoots, which uses addOtherSourceLocation.
jitCmd now takes a `server` option that will emit progress/errors via std.zig.Server when enabled.
…ssing Also need to pass them to the .res compilation step, since files (cursors, icons, etc) can be found in the system include directories.
e458558
to
3f92cbe
Compare
Thanks for putting this together! |
The resinator files were moved during ziglang#19174
The resinator files were moved during #19174
…yPath Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`. This fixes an accidental regression from ziglang#19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case. However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience). Closes ziglang#19605
…yPath Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`. This fixes an accidental regression from #19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case. However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience). Closes #19605
…yPath Adds an `include_paths` field to RcSourceFile that takes a slice of LazyPaths. The paths are resolved and subsequently appended to the -rcflags as `/I <resolved path>`. This fixes an accidental regression from #19174. Before that PR, all Win32 resource compilation would inherit the CC flags (via `addCCArgs`), which included things like include directories. After that PR, though, that is no longer the case. However, this commit intentionally does not restore the previous behavior (inheriting the C include paths). Instead, each .rc file will need to have its include paths specified directly and the include paths only apply to one particular resource script. This allows more fine-grained control and has less potentially surprising behavior (at the cost of some convenience). Closes #19605
This moves .rc/.manifest compilation out of the main Zig binary, contributing towards #19063
Also:
TODO
zig rc
has to be lazily built duringzig build-exe
, etc. Right now it produces misleading output where it looks like some other operation is taking a long time (compiler_rt...
, LLVM emit, etc)__GNUC__
or_MSC_VER
during preprocessing or something lame like that):