Commit Graph

29519 Commits

Author SHA1 Message Date
Andrew Kelley
d3b03ed64b frontend: fix use of undefined progress node
This was causing a crash when running `zig test`.
2024-05-27 20:56:48 -07:00
Andrew Kelley
eb718ceffa std.process: fix compilation on 32-bit targets 2024-05-27 20:56:48 -07:00
Andrew Kelley
e820173467 Compilation: fix sub-compilations given wrong progress node 2024-05-27 20:56:48 -07:00
Andrew Kelley
e2e61f3296 std.process.Child: comptime assert to protect prog_fileno
documenting my assumptions via comptime assertion
2024-05-27 20:56:48 -07:00
Andrew Kelley
e8907f9e9c std.Progress: correct the top level doc comments 2024-05-27 20:56:48 -07:00
Jacob Young
d77f5e7aaa Progress: fix compile errors on windows
Works for `zig build-exe`, IPC still not implemented yet.
2024-05-27 20:56:48 -07:00
mlugg
d403d8cb7a Module: fix and improve progress reporting
* correctly report time spent analyzing function bodies
* print fully qualified decl names
* also have a progress node for codegen

The downside of these changes is that it's a bit flickerey, but the
upside is that it's accurate; you can see what the compiler's doing!
2024-05-27 20:56:48 -07:00
mlugg
acdf988c24 std.process.Child: prevent racing children from inheriting progress pipes
This fix is already in master branch for stdin, stdout, and stderr; this
commit solves the same problem but for the progress pipe.

Both fixes were originally included in one commit on this branch,
however it was split it into two so that master branch could receive the
fix before the progress branch is merged.
2024-05-27 20:56:48 -07:00
Andrew Kelley
9331da8fe3 std.Build.Step.Run: don't create empty progress node 2024-05-27 20:56:48 -07:00
Andrew Kelley
ca03c9c512 std.Progress: fix race condition with IPC nodes
It stored some metadata into the canonical node storage data but that is
a race condition because another thread recycles those nodes.

Also, keep the parent name for empty child root node names.
2024-05-27 20:56:48 -07:00
Andrew Kelley
516366f78f std.Progress: skip printing root node when it is empty 2024-05-27 20:56:48 -07:00
Andrew Kelley
2759173452 zig build: lock stderr while executing the build runner 2024-05-27 20:56:48 -07:00
Andrew Kelley
352dc2c06a compiler: show decl name in progress node 2024-05-27 20:56:48 -07:00
Andrew Kelley
70e39c1a20 std.Progress: fixes
* bump default statically allocated resources
* debug help when multiple instances of std.Progress are initialized
* only handle sigwinch on supported operating systems
* handle when reading from the pipe returns 0 bytes
* avoid printing more lines than rows
2024-05-27 20:56:48 -07:00
Andrew Kelley
2233d95b0f main: avoid creating multiple std.Progress instances 2024-05-27 20:56:48 -07:00
Andrew Kelley
b27fdf92fb Compilation: only create progress nodes for work actually being done 2024-05-27 20:56:48 -07:00
Andrew Kelley
1cf1cb6ae0 std.debug.Trace: follow the struct default field guidance 2024-05-27 20:56:48 -07:00
Andrew Kelley
a486392ee4 std.Build.Step: don't create an empty progress node 2024-05-27 20:56:48 -07:00
Andrew Kelley
795c5791a9 test runner: update to new std.Progress API 2024-05-27 20:56:48 -07:00
Andrew Kelley
f97c2f28fd update the codebase for the new std.Progress API 2024-05-27 20:56:48 -07:00
Andrew Kelley
f6873c6b00 std.Progress: fix using saved IPC data
also fix handling of BrokenPipe

also fix continuing wrong loop in error conditions
2024-05-27 20:56:48 -07:00
Andrew Kelley
c01cfde688 std.process.Child: fix ZIG_PROGRESS env var handling
and properly dup2 the file descriptor to make it handle the case when
other files are already open
2024-05-27 20:56:48 -07:00
Andrew Kelley
3a768bd6ce std.Progress: save a copy of IPC data
so that the previous message can be used when the pipe is empty.

prevents flickering
2024-05-27 20:56:48 -07:00
Andrew Kelley
df46f5af69 std.Progress: include subtrees from child processes 2024-05-27 20:56:48 -07:00
Andrew Kelley
f07116404a std.Progress: child process sends updates via IPC 2024-05-27 20:56:48 -07:00
Andrew Kelley
ed36470af1 std.Progress: truncate trailing newline 2024-05-27 20:56:48 -07:00
Andrew Kelley
67e08e7b3c fix clearing and sibling iteration 2024-05-27 20:56:48 -07:00
Andrew Kelley
582acdf721 keep the cursor at the end instead of beginning 2024-05-27 20:56:48 -07:00
Andrew Kelley
66c3b6ac65 fix terminal repainting
the clear, save, restore thing doesn't work when the terminal is at the
bottom
2024-05-27 20:56:48 -07:00
Andrew Kelley
a3c9511ab9 rework std.Progress again
This time, we preallocate a fixed set of nodes and have the user-visible
Node only be an index into them. This allows for lock-free management of
the node storage.

Only the parent indexes are stored, and the update thread makes a
serialized copy of the state before trying to compute children lists.

The update thread then walks the tree and outputs an entire tree of
progress rather than only one line.

There is a problem with clearing from the cursor to the end of the
screen when the cursor is at the bottom of the terminal.
2024-05-27 20:56:48 -07:00
Andrew Kelley
e1e4de2776 progress progress
Move the mutex into the nodes

Track the whole tree instead of only recently activated node
2024-05-27 20:56:48 -07:00
Andrew Kelley
d6e8ba3f97 start reworking std.Progress
New design ideas:
* One global instance, don't try to play nicely with other instances
  except via IPC.
* One process owns the terminal and the other processes communicate via
  IPC.
* Clear the whole terminal and use multiple lines.

What's implemented so far:
* Query the terminal for size.
* Register a SIGWINCH handler.
* Use a thread for redraws.

To be done:
* IPC
* Handling single threaded targets
* Porting to Windows
* More intelligent display of the progress tree rather than only using
  one line.
2024-05-27 20:56:48 -07:00
Andrew Kelley
759c2211c2 test cases: try running foreign binaries
You don't know if it's possible to run a binary until you try. The build
system already integrates with executors and has the
`skip_foreign_checks` for exactly this use case.
2024-05-27 19:15:40 -04:00
Sean
c0da92f714 hash_map.zig: Pass self by value and less pointer-int conversion
- Used `Self` instead of `*const Self` where appropriate (orignally proposed in #19770)
 - Replaced `@intFromPtr` and `@ptrFromInt` with `@ptrCast`, `@alignCast`, and pointer arithmetic where appropriate

With this, the only remaining instance on pointer-int conversion in hash_map.zig is in `HashMapUnmanaged.removeByPtr`, which easily be able to be eliminated once pointer subtraction is supported.
2024-05-27 13:22:50 +03:00
Matthew Lugg
389181f6be std.process.Child: prevent racing children from inheriting one another's pipes
The added comment explains the issue here relatively well. The new
progress API made this bug obvious because it became visibly clear that
certain Compile steps were seemingly "hanging" until other steps
completed. As it turned out, these child processes had raced to spawn,
and hence one had inherited the other's stdio pipes, meaning the `poll`
call in `std.Build.Step.evalZigProcess` was not identifying the child
stdout as closed until an unrelated process terminated.
2024-05-26 16:44:14 -04:00
Andrew Kelley
591bbafee3
Merge pull request #20049 from ziglang/std.process.Child
std: restructure child process namespace
2024-05-26 16:20:07 -04:00
Jacob Young
b9b7f18523 EnumMap: fix init 2024-05-26 16:13:54 -04:00
Jacob Young
6e5e7e7b19 Compilation: fix regressed assembly diagnostics
Regressed by #17947
2024-05-26 12:38:31 -04:00
Ryan Liptak
aa463adc91 std.process.Child: Improve doc comments of Windows argv -> command line functions 2024-05-26 09:37:14 -07:00
Andrew Kelley
f47824f24d std: restructure child process namespace 2024-05-26 09:31:55 -07:00
Andrew Kelley
793f820b39 Revert "cmake/llvm: Don't unset LLVM_CONFIG_EXE"
This reverts commit 28476a5ee9.

It also adds a comment to explain the purpose of this line, to prevent
this mistake from being repeated.
2024-05-25 09:04:52 -07:00
Jakub Konka
0b0625ccf4
Merge pull request #20062 from ziglang/macho-perf-bug
link/macho: fix perf bug in DWARF parsing
2024-05-25 06:25:46 +02:00
Jakub Konka
42c058575e link/macho: fix 32bit build 2024-05-24 23:06:27 +02:00
Jakub Konka
19f41d390f test/link/macho: add symbol stabs smoke test 2024-05-24 22:43:23 +02:00
Jakub Konka
8e52d54c25 Step/CheckObject: handle stab entries when dumping MachO symtab 2024-05-24 22:32:14 +02:00
kcbanner
710d745a54 cmake: add /Zc:preprocessor to handle new OptTable macros
See: 12d8e7c6ad
See: 3f092f37b7

cmake: set MSVC_RUNTIME_LIBRARY for zigcpp
2024-05-24 10:58:05 -04:00
Jakub Konka
ed7073c630 link/macho: fix perf bug in DWARF parsing 2024-05-24 15:34:48 +02:00
Jakub Konka
fb88cfdf6a
Merge pull request #20032 from ziglang/macho-literals
link/macho: implement logic for merging literals
2024-05-23 14:21:31 +02:00
Jakub Konka
d31eb744ce link/macho: fix 32bit build 2024-05-23 12:04:17 +02:00
Jakub Konka
f3a503eca2 link/macho: ensure we set alignment of literals to max alignment 2024-05-23 12:04:17 +02:00