Skip to content
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

[proposal] build inspector #18688

Open
1 of 3 tasks
RossComputerGuy opened this issue Jan 26, 2024 · 4 comments
Open
1 of 3 tasks

[proposal] build inspector #18688

RossComputerGuy opened this issue Jan 26, 2024 · 4 comments

Comments

@RossComputerGuy
Copy link
Contributor

RossComputerGuy commented Jan 26, 2024

The motivation behind this proposal is to make it easier to determine what a step does in large build.zig's. A good example of this is with zig itself. It can be difficult to catch a specific command which is executed for a particular step. With this proposal, it would be a matter of pointing the "build inspector" to the specific step via some sort of "path" and zig would dump some metadata on that step. This would simplify debugging build.zig and could make compiler development a little easier.

Possible example usage:

$ zig build --inspect install/xcb-util
Id: compile
Depends:
  - xcb
Dependants:
  - xcb-image
  - ../install
Command: /home/ross/zig/bin/zig build-lib /home/ross/.cache/zig/p/1220096cb9b583a14b307609801d8a018a3babc9e608170afc521a0db4e437165c15/src/atoms.c /home/ross/.cache/zig/p/1220096cb9b583a14b307609801d8a018a3babc9e608170afc521a0db4e437165c15/src/event.c /home/ross/.cache/zig/p/1220096cb9b583a14b307609801d8a018a3babc9e608170afc521a0db4e437165c15/src/xcb_aux.c -ODebug -I /home/ross/MidstallSoftware/xcb.zig/zig-cache/o/cac237db28f5e81076ba1cd591d8db88 -lc --cache-dir /home/ross/MidstallSoftware/xcb.zig/zig-cache --global-cache-dir /home/ross/.cache/zig --name xcb-util -dynamic

The changes wouldn't be too much in std.Build, formatting could be done by adding a new method to the Step VTable but it would require an AnyWriter type.

Requires:

@rohlem
Copy link
Contributor

rohlem commented Jan 26, 2024

@nektro It would be helpful if you would explain the reasoning behind your thumbs-down.
Do you foresee a negative consequence of adding this feature, or do you just not anticipate personally using it?

@RossComputerGuy
Copy link
Contributor Author

RossComputerGuy commented Jan 30, 2024

https://github.com/ExpidusOS/zig/tree/poc/build-inspector I've come up with a bit of a POC version of this proposal.

@RossComputerGuy
Copy link
Contributor Author

After making the POC implementation, I've noticed there's a bit of an issue. It's impossible to print generated paths until the step is executed but there doesn't seem to be a way to know the step was done until the cache hit occurs. Maybe I am missing something and there is a way to know if the step will only use the cache but until then, pretty printing the cache paths won't be possible.

@RossComputerGuy
Copy link
Contributor Author

I added the ability to see the command in a compile step in the POC implementation. This looks great and is working well.

$ zig build --inspect="test-std/run test std-aarch64-linux.6.6...6.6-gnu.2.38-apple_m1-Debug/zig test Debug native"
Id: compile
Name: zig test Debug native
Dependencies: None
Dependants: None
Command: /home/ross/zig/bin/zig test -ODebug -I /home/ross/ExpidusOS/zig/test -Mroot=/home/ross/ExpidusOS/zig/lib/std/std.zig --cache-dir /home/ross/ExpidusOS/zig/zig-cache --global-cache-dir /home/ross/.cache/zig --name test --zig-lib-dir /home/ross/ExpidusOS/zig/lib --listen=-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants