Rename the packed keyword to bitpack #30875
Labels
No labels
abi/f32
abi/ilp32
abi/sf
accepted
arch/21k
arch/6502
arch/aarch64
arch/alpha
arch/amdgcn
arch/arc
arch/arc32
arch/arc64
arch/arm
arch/avr
arch/bfin
arch/bpf
arch/colossus
arch/cris
arch/csky
arch/dlx
arch/epiphany
arch/fr30
arch/frv
arch/hexagon
arch/hppa
arch/hppa64
arch/ia64
arch/kalimba
arch/kvx
arch/lanai
arch/lm32
arch/loongarch32
arch/loongarch64
arch/m32r
arch/m68k
arch/m88k
arch/mcore
arch/microblaze
arch/mips
arch/mips64
arch/mmix
arch/moxie
arch/mrisc32
arch/msp430
arch/nds32
arch/ns32k
arch/nvptx
arch/or1k
arch/powerpc
arch/powerpc64
arch/propeller
arch/riscv32
arch/riscv64
arch/rl78
arch/rx
arch/s390x
arch/sh
arch/sparc
arch/sparc64
arch/spirv
arch/spu
arch/tricore
arch/v850
arch/vax
arch/vc4
arch/ve
arch/wasm
arch/x86
arch/x86_64
arch/xcore
arch/xtensa
autodoc
backend/c
backend/llvm
backend/self-hosted
binutils
breaking
build system
debug info
docs
error message
frontend
fuzzing
incremental
lib/c
lib/compiler-rt
lib/cxx
lib/std
lib/tsan
lib/ubsan-rt
lib/unwind
linking
miscompilation
os/android
os/dragonfly
os/driverkit
os/emscripten
os/freebsd
os/fuchsia
os/haiku
os/hurd
os/illumos
os/ios
os/linux
os/maccatalyst
os/macos
os/managarm
os/netbsd
os/ohos
os/openbsd
os/plan9
os/redox
os/rtems
os/serenity
os/tvos
os/uefi
os/visionos
os/wasi
os/watchos
os/windows
proposal
release notes
testing
zig cc
zig fmt
zig reduce
bounty
bug
contributor-friendly
downstream
enhancement
infra
optimization
question
regression
upstream
use case
No assignees
7 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ziglang/zig!30875
Loading…
Reference in a new issue
No description provided.
Delete branch "ennui/zig:feature/bitpacked"
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?
Release notes
This PR implements #12852 by adding
bitpackas an alias topackedwhile making all usages ofpackeda compiler error. Thepackedkeyword can't be removed yet since its continued existence is necessary in order for automated migration to be possible.Running
zig fmtallows to automatically migrate frompackedtobitpackwith no issues.While this PR covers all the
packedusage as well as some references topacked, it doesn't necessarily cover everything, and therefore follow-up PRs will be needed here.This is my second attempt to understand Zig's codebase, and I felt like this was a good starting point once I figured out how to pull it off. Feedback is greatly appreciated.
FYI it's perfectly valid to make changes to aro/resinator here. A matching upstream PR would also be appreciated but is not necessary (any changes are synced back and forth periodically).
@ core team, could we refrain from merging this for now? I'd prefer to avoid heavy conflicts with my type resolution branch
c71c0ce0a254ed3bd9c1I see, I might as well cover them as well
Speaking of heavy conflicts, should I stay on my approach of doing separate PRs for documentation and breaking
packedor is one gigantic PR fine?I'd say one PR is preferable for this.
I actually doubt we'll want to go with the strategy you've tried of temporarily keeping both keywords around; when doing this sort of thing we typically just break the old usage immediately (e.g. when addingThat said, I would personally recommend against updating this PR (to change strategies or anything) right now, because this diff will be quite heavy on conflicts with my branch, so time spent on updating right now just adds conflicts for you down the line!@Intand friends, we removed@Typein the same PR).(EDIT: I originally made a bad suggestion here, sorry!)
Gotcha, I'll mark this PR as WIP for now
Start migrating fromto WIP: Start migrating frompackedtobitpackedpackedtobitpackedWIP: Start migrating fromto WIP: Start migrating frompackedtobitpackedpackedtobitpackSpeaking as a former technical editor. Regarding doc usage, when using the term as a verb in prose, such as describing how the compiler bit-packs a
structuse the hyphenated form (like I did here). When referencing the construct as a noun, use the keyword, preferably formatted as code: " when passing abitpacked structto C". If you are talking about a "structure" (prose, not code), use the hyphenated form: "when passing a bit-packed structure to C...", but the previous example would be preferred as more precise.The principle here is that the informal blending of code with English that we do in chat can lead to confusion and ambiguity, and one should clearly separate prose form code fragments, with the appropriate formatting. The programming language reference should generally be written in a more formal style of prose, as one would write a specification. Code should be clearly separated from prose. When writing something more expository such as an example, tutorial, or blog, the informal mixing of code can be ok.
54ed3bd9c1200dd4b842Due to recent lack of time, I unfortunately will have to relinquish this PR myself.
Hopefully someone else can take on this massive change, I welcome the recycling of this PR.
Now that Zig 0.16.0 has been released and breaking changes have calmed down for now, I'm reopening this PR with new progress.
Documentation, error messages and internal naming haven't been affected by this PR yet considering the massive churn from just having to rebase on top of big codebase changes.
I will be updating the PR's description tomorrow
d833eb5fda4e204dac03WIP: Start migrating fromto Start migration frompackedtobitpackpackedtobitpackThis PR should finally be ready to review. While I would like to have this PR be 100% complete and rename every single internal (and external) usage of
packed, I also fear about causing major regressions here, so I'd like to limit the scope here, especially since thepackedkeyword cannot be removed from parsing until the release cycle after the release containing this change (otherwisezig fmtwon't be able to automatically migrate them tobitpack).706edea470c4f6353e4fI redid this whole PR (again) using Jujutsu, which should help working on this PR a lot, which is nice because doing this stuff on Git was getting way too fiddly.
Feedback on this PR's scope is heavily appreciated.
c4f6353e4f0a7523b7afI'm marking this PR as a draft again, so that I can make it adequately do everything in a single shot.
Sorry for flip-flopping too much here! I'm still trying to figure the process out.
EDIT: It's ready for review again, I'll be rebasing this PR whenever possible (oh and of course, only push it when needed).
Start migration fromto WIP: Rename thepackedtobitpackpackedkeyword tobitpackf26e0210f2c5850f01cfWIP: Rename theto Rename thepackedkeyword tobitpackpackedkeyword tobitpackc5850f01cf53ae867caa53ae867caa23c54fb6d523c54fb6d5f551687a4ef551687a4e2099d6dca9packed->bitpack#354542099d6dca9621c802243621c8022437463a0fbec7463a0fbec6fe2350e7a6fe2350e7aebd8f7853cSorry for the constant failing pushes, I haven't noticed the formatting error happening before all the Wine tests while testing locally;
Considering that there appears to be some active churn right now that keeps breaking this PR, I wonder if there's a way to pause CI for each push so that I don't flood the CI machines with my stuff
You can prefix the PR title with
[skip ci]temporarily.Rename theto [skip ci] Rename thepackedkeyword tobitpackpackedkeyword tobitpackebd8f7853cd40a8ae101@linus wrote in #30875 (comment):
Gotcha, thanks
@mlugg wrote in #30875 (comment):
Why do you say that? To me it seems like the obvious move is having
zig fmtautomatically perform this particular upgrade. Plus it would be useful to allow packages to checkbuiltin.zig_versionat least across two releases.@ennui thank you for your efforts. I actually prefer for nobody to use this
[skip ci]feature, because the PR queue is supposed to be for stuff that is ready to be merged. If your push is not expected to pass the CI, then simply don't push it! If your PR is not ready to be merged, then please work on it locally or in a fork, and then open a PR when it is ready. I don't think there is ever a reason to use[skip ci]. I would disable that feature on forgejo if I could.Hm, yeah, I guess you're right. Sorry, I'm not sure where my suggestion there came from to be honest---disregard my earlier comment!
[skip ci] Rename theto Rename thepackedkeyword tobitpackpackedkeyword tobitpack@andrewrk wrote in #30875 (comment):
Ah, I understand; I tagged this PR as
[skip ci]because of churn concerns that did materialize, so when I had my rebase tested and ready to push, more upstream changes were already done that broke the PR mergability once more, making the latest push kinda pointless to run CI on (my justification for not rebasing again was that it was 3 AM when I pushed!)You are right though that CI shouldn't be disabled if a PR is supposed to be ready-to-merge, so I apologize for doing that
d40a8ae101tod4ad2c8350d4ad2c835060b4ada974f32ea83196d226b7ee56d226b7ee563806f2bf0e3806f2bf0e218c60fceaI suggest to also handle this TODO from
src/main.zig:@K4 wrote in #30875 (comment):
Good catch, if nothing else pops up that tackles this before I update this PR, I'll do it
Well, it looks like this next rebase will be massive; unfortunately I won't have time to tackle this until mid-July. Just letting it be known.
@ennui I sugested this TODO elsewhere: #36043 (comment). You don't need to handle this anymore.
I didn't have a way to know if there would be any other PR that updates
zig1.wasmsooner than this PR (that PR isn't merged yet, but probably it will be pretty soon).@K4 wrote in #30875 (comment):
Good call! The PR you mentioned was merged after all :p
I do think this PR will eventually be merged, but considering it's a mega-breaking change (a 'gate maybe?), it makes sense to take time with it and not try to rush things out
218c60fcea50f840326750f8403267e35703afe4Oh, this is an interesting CI failure: Zed had automatically formatted stuff even though I had already disabled that.. Considering other fun™ issues such as a horrendous memory leak and a broken project-wide search, I honestly should consider using Gram instead.
There was still superfluous spacing in
lib/compiler/objdump.zigthough, so I manually edited that out in thezig fmtcommit if that's not a probleme35703afe46cff21b1116cff21b1117faa4e2dd9@ -0,0 +122,4 @@if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODOif (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODOconst PStruct = bitpack struct(u32) {While rebasing, I noticed this variable name. Is it a shorthand for "Packed Struct"?
If so, I'll correct it to be
BStructinstead.I addressed this in the latest rebase
7faa4e2dd950e4d9c19c50e4d9c19cc207d5aa47c207d5aa47d127ea9bd4d127ea9bd485644a66cc85644a66cc1be1f44d471be1f44d470bca5d5c340bca5d5c34aff3240c9faff3240c9fc83a4dd8e3c83a4dd8e35e2e5338165e2e5338168e561c0e9d8e561c0e9dd4c6523958d4c6523958e0caef3b89e0caef3b89080a230faaPS: In order to fix the
spirv/spec.zigconflicts, I decided to generate a new one on my own side using a clone of SPIRV-Header'smainbranch080a230faae654df08a3e654df08a3d6c4cc6fa9Thanks for maintaining this for so long, sorry for the delay in getting it merged.
To keep you in the loop, I'd like to help get this merged, but want to wait until 0.17.1 is ready (should be fairly soon). After that, this'll need one last rebase and then I'll try to get it merged before any more conflicts appear.
Oh, sounds pretty good, I'll already prepare a penultimate rebase. Good luck with Zig 0.17.1!
d6c4cc6fa9f9b9fc9c64I've rebased this branch and pushed it to my fork: https://codeberg.org/squeek502/zig/src/branch/ennui-feature/bitpacked
Changes I made beyond resolving conflicts:
Apply zig fmt before adding bitpackcommitzig1.wasmupdates to just one; it only needs to be updated after theSupport bitpack as an alias of packedcommit. The rest of the commits don't affect bootstrapping (confirmed by going through the CMake bootstrap process on the HEAD commit)packedfrom the grammar. With it included in the grammar, the generated parser oracle will acceptpackedwhileParse.zigwill reject it (we want them to agree)Let me know if you'd like me to force push that branch here, or if you'd like a chance to resolve the conflicts yourself and compare.
Thank you for your effort, I really appreciate it.
Oh, this is interesting. The extra two updates were there because I needed to regenerate the zig1.wasm or else it wouldn't have been possible to compile the compiler. I guess I was wrong?
My rationale for keeping it in the generated parser oracle was to avoid a
packedkeyword from completely invalidating the parsing process, although I assume that it wouldn't be a problem here since it's the manually-written parser that is supposed to be error-resilient.Go ahead! While I managed to streamline the process of rebasing everything using Jujustu, I see that rebasing again would have been extremely painful and I would have needed to wait for the weekend to do so.
f9b9fc9c64e6ee887c07Do you mean
zig buildwith an existing zig binary, or the full CMake bootstrap process?We only really care about whether or not there was an error. The hand-written parser getting further is fine, but note that during fuzzing against the oracle, recovery is disabled.
e6ee887c079e6534ed0e9e6534ed0ebdce08cbbeThanks for sticking with this! Really nice work; while reviewing this I was consistently impressed with how well targeted the changes were (i.e. not accidentally messing with Aro's separate
packedconcept, etc).Note: I looked through the full diff, and as an additional sanity check, I took the diff of this branch and wrote a script to remove all the diffs for files that have a balanced number of lines removed/added, and all lines removed/added are contiguous (i.e. any that just have
packed->bitpackreplacement). The remaining diff can be found here and it's quite short/easy to review.The full CMake process, running
ninjaAh, if you'd like to double check that it works for you with this branch, that'd be appreciated.
I double-checked (and ran
zig build test), and it looks like the other two zig1.wasm generations are no longer needed for the bootstrapping process to work.Release notes please!
Yeah, my bad for not catching that; fixing it now.
Release notes (with #37582 included to make
zig fmtwork as expected)packedkeyword renamed tobitpackIn order to clarify the effect of the
packedkeyword on astruct/union, it has been renamed tobitpack.Upgrade guide (
zig fmtwill automatically make this change for you):⬇️
std.lang:@"packed"renamed to@"bitpack"Consequently,
@"packed"has been renamed to@"bitpack"instd.lang.Type.ContainerLayoutUpgrade guide:
Oh no, I guess this broke during one of the many rebases. It didn't help that I didn't trust
zig fmtfor fixing the Zig codebase so I opted for manually fixing up everything.Oh well, I don't think I could have made #37582 so I heavily appreciate the help.
Nice work getting this landed, both of you.