r/Zig • • 11d ago

Migrating my codebase from Zig 0.16.0 to 0.17.1, any advice?

I’m about to start the process of upgrading my kernel written in Zig—from 0.16.0 to the 0.17.1, and I'd love some advice from others who have gone through a similar process, especially on bare-metal or systems migrations.

What was your strategy for tackling the task? What sort of problems did you encounter and how did you overcome them?

Appreciate any insights or approaches you've found effective!

22 Upvotes

7 comments sorted by

24

u/lipfang-moe 11d ago

I didn't have much issue. Just upgrade your zig version and fix compiler errors, referencing the release notes, until you don't have compiler errors anymore. the only change that won't cause a compiler error is the @bitCast changes, so I'd manually check your usages of @bitCast to make sure you're not affected

https://ziglang.org/download/0.17.0/release-notes.html

6

u/Impossible_Cod9831 11d ago

Thanks for the response, knowing other people have done this and not had too much of an issue is very comforting.

6

u/SilvernClaws 11d ago

Just migrated one of my smaller projects a few days ago and I only had two places I had to change. Took about ten minutes. Unless you've been using some specific features that have changed, I'd say just try and see what the compiler complains about. Could be done faster than figuring out an elaborate strategy would have taken.

2

u/Impossible_Cod9831 11d ago

Thanks, that is really helpful and gives me a bit of confidence that this may not be such a big job.

3

u/Highborn_Hellest 11d ago

Upgrade your zig version and if you get comp errors, fix. If you don't that was it.

1

u/Impossible_Cod9831 10d ago

Thank you very much. I believe I can have more than one version of Zig on my system at any time, so my plan is to download Zig 0.17.1, create a branch on git, and point the build script to Zig 0.17.1.

1

u/Impossible_Cod9831 8d ago

Update: I have successfully migrated to Zig 0.17.1

Thanks to everyone who replied about the 0.16 to 0.17.1 migration. You were right, the Zig side was easy. It came down to a handful of changes: ** array repetition became u/splat, ArrayListUnmanaged initialisers needed pointer_stability, std.meta.fields became u/typeInfo reflection, and u/intFromEnum became u/backingInt.

The fiddlier part was my own environment: an old shell file kept re-exporting the 0.16 path after reboots, and my build script had a hard-coded home directory that broke CI.

Thanks again for the pointers.