2
3
Fork
You've already forked ncsu
0

update to Zig 0.14 #254

Closed
BratishkaErik wants to merge 0 commits from refs/pull/254/head into zig AGit
pull from: refs/pull/254/head
merge into: selfisekai:zig
selfisekai:zig
selfisekai:zig0.16
selfisekai:master
selfisekai:zig-threaded
selfisekai:openat
selfisekai:chdir
selfisekai:clear
selfisekai:compll
BratishkaErik commented 2025年02月09日 10:36:09 +01:00 (Migrated from code.blicky.net)
Copy link

Commits here fix compile errors when building with Zig 0.14.0-dev.3460+6d29ef0ba, release is expected to be very soon.

I have not migrated deprecations which are not hard errors for now, like in containers initializations (.{} vs decl literals) and build.zig, if you want I can migrate them too.

I'm not very proficient in atomics stuff, so I'd like your input on this. All other commits should be safe and easy to review:

Note: for fence deprecation I went with second option listed in Conditional Barries section of https://github.com/ziglang/zig/pull/21585:

Conditionally duplicate the desired store or load with the fence's ordering.
For example:

if(counter.rc.fetchSub(1,.release)==1){_=counter.rc.load(.acquire);

The Acquire will synchronize-with the longest release-sequence in rc's modification order, making all previous decrements happen-before the deinit().

Commits here fix compile errors when building with Zig `0.14.0-dev.3460+6d29ef0ba`, release is expected to be very soon. I have not migrated deprecations which are not hard errors for now, like in containers initializations (`.{}` vs decl literals) and `build.zig`, if you want I can migrate them too. I'm not very proficient in atomics stuff, so I'd like your input on this. All other commits should be safe and easy to review: > Note: for `fence` deprecation I went with second option listed in `Conditional Barries` section of https://github.com/ziglang/zig/pull/21585: > Conditionally duplicate the desired store or load with the fence's ordering. > For example: ```zig if (counter.rc.fetchSub(1, .release) == 1) { _ = counter.rc.load(.acquire); ``` > The Acquire will synchronize-with the longest release-sequence in rc's modification order, making all previous decrements happen-before the deinit().
BratishkaErik commented 2025年02月09日 11:55:31 +01:00 (Migrated from code.blicky.net)
Copy link

I played a little bit with non-LLVM x86_64 backend on current version, it works fine in ReleaseSmall and ReleaseFast but triggers crash on ReleaseSafe and Debug:

thread 52907 panic: integer cast truncated bits
Unwind error at address `:0x1091747` (error.AddressOutOfRange), trace may be incomplete
/home/bratishkaerik/ncdu/src/ui.zig:560:30: 0x10a5e79 in hline (main.zig)
 _ = c.hline(ch, @as(i32, @intCast(len)));
 ^
/home/bratishkaerik/ncdu/src/ui.zig:590:18: 0x10a9249 in create (main.zig)
 hline(if (i == 0 or i == height-1) acs_hline else ' ', width-2);
 ^
/home/bratishkaerik/ncdu/src/sink.zig:462:42: 0x1078714 in draw (main.zig)
 const box = ui.Box.create(4, ui.cols -| 5, "Finalizing");
 ^
/home/bratishkaerik/ncdu/src/main.zig:653:41: 0x106225b in handleEvent (main.zig)
 .scan, .refresh => sink.draw(),
 ^
/home/bratishkaerik/ncdu/src/mem_sink.zig:196:21: 0x10710ad in done (main.zig)
 main.handleEvent(false, true);
 ^
/home/bratishkaerik/ncdu/src/sink.zig:256:30: 0x105e690 in done (main.zig)
 .mem => mem_sink.done(),
 ^
/home/bratishkaerik/ncdu/src/scan.zig:289:20: 0x104e865 in scan (main.zig)
 defer sink.done();
 ^
/home/bratishkaerik/ncdu/src/main.zig:602:18: 0x10504fe in main (main.zig)
 scan.scan(path) catch |e| ui.die("Error opening directory: {s}.\n", .{ui.errorString(e)});
 ^
/usr/lib64/zig/9999/lib/std/start.zig:647:22: 0x1049a18 in main (std.zig)
 root.main();
 ^
???:?:?: 0x7f4ce43b3487 in ??? (libc.so.6)
???:?:?: 0x7f4ce43b354a in ??? (libc.so.6)
???:?:?: 0x11d33d4 in ??? (???)
[1] 52907 IOT instruction (core dumped) zig-out/bin/ncdu

No luck with C backend tho:

$ zig build -Dofmt=c
$ gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lncursesw -ltinfow -lzstd -lc -I /usr/lib64/zig/9999/lib/ ncdu.c
# same with clang
$ ./a.out
thread 57094 panic: switch on corrupt value
[1] 57093 segmentation fault (core dumped) ./a.out
I played a little bit with non-LLVM x86_64 backend on current version, it works fine in ReleaseSmall and ReleaseFast but triggers crash on ReleaseSafe and Debug: ``` thread 52907 panic: integer cast truncated bits Unwind error at address `:0x1091747` (error.AddressOutOfRange), trace may be incomplete /home/bratishkaerik/ncdu/src/ui.zig:560:30: 0x10a5e79 in hline (main.zig) _ = c.hline(ch, @as(i32, @intCast(len))); ^ /home/bratishkaerik/ncdu/src/ui.zig:590:18: 0x10a9249 in create (main.zig) hline(if (i == 0 or i == height-1) acs_hline else ' ', width-2); ^ /home/bratishkaerik/ncdu/src/sink.zig:462:42: 0x1078714 in draw (main.zig) const box = ui.Box.create(4, ui.cols -| 5, "Finalizing"); ^ /home/bratishkaerik/ncdu/src/main.zig:653:41: 0x106225b in handleEvent (main.zig) .scan, .refresh => sink.draw(), ^ /home/bratishkaerik/ncdu/src/mem_sink.zig:196:21: 0x10710ad in done (main.zig) main.handleEvent(false, true); ^ /home/bratishkaerik/ncdu/src/sink.zig:256:30: 0x105e690 in done (main.zig) .mem => mem_sink.done(), ^ /home/bratishkaerik/ncdu/src/scan.zig:289:20: 0x104e865 in scan (main.zig) defer sink.done(); ^ /home/bratishkaerik/ncdu/src/main.zig:602:18: 0x10504fe in main (main.zig) scan.scan(path) catch |e| ui.die("Error opening directory: {s}.\n", .{ui.errorString(e)}); ^ /usr/lib64/zig/9999/lib/std/start.zig:647:22: 0x1049a18 in main (std.zig) root.main(); ^ ???:?:?: 0x7f4ce43b3487 in ??? (libc.so.6) ???:?:?: 0x7f4ce43b354a in ??? (libc.so.6) ???:?:?: 0x11d33d4 in ??? (???) [1] 52907 IOT instruction (core dumped) zig-out/bin/ncdu ``` No luck with C backend tho: ```sh-session $ zig build -Dofmt=c $ gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -lncursesw -ltinfow -lzstd -lc -I /usr/lib64/zig/9999/lib/ ncdu.c # same with clang $ ./a.out thread 57094 panic: switch on corrupt value [1] 57093 segmentation fault (core dumped) ./a.out ```
yorhel commented 2025年03月01日 13:45:09 +01:00 (Migrated from code.blicky.net)
Copy link

4847a753adb69b54e2dc24e0b643f0ac6105e82c

Yup, that should be fine.

I played a little bit with non-LLVM x86_64 backend on current version, it works fine in ReleaseSmall and ReleaseFast but triggers crash on ReleaseSafe and Debug

Nice, that's amazing progress! Having a usable fully LLVM-free Zig build would simplify building and packaging a lot, I imagine. Not quite there yet, but I'm not in a hurry.

> 4847a753adb69b54e2dc24e0b643f0ac6105e82c Yup, that should be fine. > I played a little bit with non-LLVM x86_64 backend on current version, it works fine in ReleaseSmall and ReleaseFast but triggers crash on ReleaseSafe and Debug Nice, that's amazing progress! Having a usable fully LLVM-free Zig build would simplify building and packaging a lot, I imagine. Not quite there yet, but I'm not in a hurry.
yorhel commented 2025年03月02日 13:07:10 +01:00 (Migrated from code.blicky.net)
Copy link

0.14 is also slightly faster. 👍 https://p.blicky.net/l3EmgrHk6X4g

0.14 is also slightly faster. 👍 https://p.blicky.net/l3EmgrHk6X4g
BratishkaErik commented 2025年03月03日 18:54:13 +01:00 (Migrated from code.blicky.net)
Copy link

Rebased on latest zig branch and Zig 0.14.0-dev.3460+6d29ef0ba, I think it would not break now and just need to wait for 0.14 cutoff.

Rebased on latest `zig` branch and Zig `0.14.0-dev.3460+6d29ef0ba`, I think it would not break now and just need to wait for 0.14 cutoff.
BratishkaErik commented 2025年03月03日 19:02:37 +01:00 (Migrated from code.blicky.net)
Copy link

I think there is a test failure on zig branch:

$ zig-bin-0.13.0 build test 
test
└─ run test
 └─ zig test Debug native 1 errors
src/main.zig:728:36: error: expected optional type, found '@typeInfo(@typeInfo(@TypeOf(main.Args.next)).Fn.return_type.?).ErrorUnion.error_set!?main.Args.Option'
 const o = self.a.next().?;
 ~~~~~~~~~~~~~^~
src/main.zig:728:36: note: consider using 'try', 'catch', or 'if'
referenced by:
 test.argument parser: src/main.zig:738:10
 remaining reference traces hidden; use '-freference-trace' to see all reference traces
error: the following command failed with 1 compilation errors:
/opt/zig-bin-0.13.0/zig test -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw -lncursesw -ltinfow -lzstd -ODebug -Mroot=/home/bratishkaerik/code.blicky.net/ncdu/src/main.zig -lc --cache-dir /home/bratishkaerik/code.blicky.net/ncdu/.zig-cache --global-cache-dir /home/bratishkaerik/.cache/zig --name test -fno-PIE --listen=- 
Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none)
test transitive failure
└─ run test transitive failure
 └─ zig test Debug native 1 errors
error: the following build command failed with exit code 1:
/home/bratishkaerik/code.blicky.net/ncdu/.zig-cache/o/2d166ed6c372d13e21a642ba8cc83c9a/build /opt/zig-bin-0.13.0/zig /home/bratishkaerik/code.blicky.net/ncdu /home/bratishkaerik/code.blicky.net/ncdu/.zig-cache /home/bratishkaerik/.cache/zig --seed 0x5dc41318 -Z41f81ebf95b6ad7d test

Should I fix it or leave as is?

I think there is a test failure on `zig` branch: ```console $ zig-bin-0.13.0 build test test └─ run test └─ zig test Debug native 1 errors src/main.zig:728:36: error: expected optional type, found '@typeInfo(@typeInfo(@TypeOf(main.Args.next)).Fn.return_type.?).ErrorUnion.error_set!?main.Args.Option' const o = self.a.next().?; ~~~~~~~~~~~~~^~ src/main.zig:728:36: note: consider using 'try', 'catch', or 'if' referenced by: test.argument parser: src/main.zig:738:10 remaining reference traces hidden; use '-freference-trace' to see all reference traces error: the following command failed with 1 compilation errors: /opt/zig-bin-0.13.0/zig test -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -I/usr/include/ncursesw -lncursesw -ltinfow -lzstd -ODebug -Mroot=/home/bratishkaerik/code.blicky.net/ncdu/src/main.zig -lc --cache-dir /home/bratishkaerik/code.blicky.net/ncdu/.zig-cache --global-cache-dir /home/bratishkaerik/.cache/zig --name test -fno-PIE --listen=- Build Summary: 0/3 steps succeeded; 1 failed (disable with --summary none) test transitive failure └─ run test transitive failure └─ zig test Debug native 1 errors error: the following build command failed with exit code 1: /home/bratishkaerik/code.blicky.net/ncdu/.zig-cache/o/2d166ed6c372d13e21a642ba8cc83c9a/build /opt/zig-bin-0.13.0/zig /home/bratishkaerik/code.blicky.net/ncdu /home/bratishkaerik/code.blicky.net/ncdu/.zig-cache /home/bratishkaerik/.cache/zig --seed 0x5dc41318 -Z41f81ebf95b6ad7d test ``` Should I fix it or leave as is?
yorhel commented 2025年03月03日 19:23:56 +01:00 (Migrated from code.blicky.net)
Copy link

I think there is a test failure on zig branch

My bad, must have broken that in 5d5182ede3. Feel free to ignore, I'll fix that before release.

> I think there is a test failure on `zig` branch My bad, must have broken that in 5d5182ede39e5a68f977e284cc8d88bf66283192. Feel free to ignore, I'll fix that before release.
yorhel commented 2025年03月05日 11:39:01 +01:00 (Migrated from code.blicky.net)
Copy link

Merged and released, thanks!

I'll go over some of the non-breaking changes in Zig 0.14 later to see if there's other places in the code to improve. And migrate the deprecations while I'm at it, I guess.

Merged and released, thanks! I'll go over some of the non-breaking changes in Zig 0.14 later to see if there's other places in the code to improve. And migrate the deprecations while I'm at it, I guess.
BratishkaErik commented 2025年03月05日 14:20:01 +01:00 (Migrated from code.blicky.net)
Copy link

Thanks!

Thanks!

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
No labels
1.x
2.x
bug
feature
imported
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
selfisekai/ncsu!254
Reference in a new issue
selfisekai/ncsu
No description provided.
Delete branch "refs/pull/254/head"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?