I have two branches in my project, main and 0.16. main is written for 0.15.2 and 0.16 is written for latest dev, which uses new Io interface. Only usage of std.posix is for exiting on error in 0.16.
Function differences from main branch are:
std.Thread.sleep() → std.Io.sleep() – I’m using std.Io.Threaded.init_single_threaded.io() as the io interface.
Everything else is pretty much the same. Removed some unnecessary vars from main and changed some variable types. Options for comiling I was using -Doptimize=ReleaseFast and binary sizes are:
174416 Nov 16 12:59 wg_forwarder-0.15.2
361104 Nov 17 09:37 wg_forwarder-master
Add the last two lines below to your 0.16 branch’s build.zig and you’ll get close in terms of binary sizes (at the cost of stripping/no unwind tables):
THANK YOU for posting this. I’ve been seeing crashes in my coroutine engine in macOS in release mode on Zig 0.16 and now I’m fairly certain it’s because of this. There is either a conflict in the SIGSEGV handlers or something else related to the stack trace extraction. I was getting hopeless and this pointed me to the right direction.
Thanks, this did lower the size but I don’t know if that’s related in the first place. Because that merge happened on 30th of September, one month prior to Io merge. Size compared from 0.16dev prior to Io merge is close to current 0.15.2 size.
Let me explain a bit.
I had a single main branch at first, and wrote everything in 0.16dev. Then after Io merge I created additional branch, 0.16 and decided to refactor the code to use the new Io interface in that new branch. I wanted to rewrite my main branch to work with the stable zig version as well, but when I just tried to compile existing code with posix functions with 0.15.2 zig, it worked with out any changes. So I ended up just updating readme and .zon on the main branch to use 0.15.2.
I see, my guess was based on the nm output differences between your two branches using 0.15.2 and master, respectively (noticed lots of new dward/debug entries) and the huge effect of flipping unwind_tables and strip. Maybe it’s a combination of things; I might try a bisect.
fwiw, here’s a cleaned up side by side of the symbol dump of your two branches. The 0.16 version brings in quite a few Io.Threaded and dwarf related functions.