-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: make defs_$GOOS.go regeneratable #23341
Comments
I agree that this is unfortunate, but it would also be quite difficult to get these into a generatable state. I don't think it would be impossible. So, while this seems like a laudable goal, I'm not sure it's actually worth the engineering effort given how slowly and specially these files grow. IMO, it would be much more worth the time to auto-generate all the syscall definitions used by the runtime, since we already have most or all of the machine-readable definitions we need in the syscall package, most of the syscall code is very regular, we tend to need new syscalls across a large number of platforms, and the code is really annoying to write by hand. |
Automating the syscall package should be a matter of backporting the work that has been done in the x/sys/unix package. |
I think the std syscall package and x/sys/unix already use nearly the same code generators. I was thinking that these could be retargeted to produce the syscall assembly code used by the runtime, which is different code but can be derived from the same metadata. |
Sounds good, but x/sys/unix has diverged pretty far from syscall. For example, x/sys/unix now uses Docker images on GNU/Linux. Nobody has bothered to backport any of this work to syscall since syscall is frozen and there is no real need to regenerate the files. |
Thank you for your comments.
Are those changes not acceptable in theory? I know it's a hassle though.
OK, I'll start from there. |
If they were not significantly invasive to the rest of the runtime, then yes, that would be acceptable. I'm mostly worried about the differing field types. What might work well would be to have a runtime-specific generator that runs
That would be awesome. Note that some of the syscalls don't follow the boilerplate and that's totally fine. Those can be stay written by hand. But there are a ton of syscall definitions across all of the arch/OS combinations that are pure boilerplate and should be generated. (Just please don't write the generator in Perl like the one in the syscall package. Nothing against Perl, just that I don't know it so I wouldn't be able to modify the generator. :) |
I'd rather adjust other runtime code to use output of
I see, thanks.
no worries :) I also don't know Perl. I'll use the language we know. |
There are technical reasons not to do this for everything, particularly the mismatched field types. Transforming various pointer-typed fields into uintptr avoids having the garbage collector scan these and avoids potentially producing write barriers for these fields (it probably also avoids some ugly casts). Similarly, some of the fields are uintptr instead of uint32/uint64 to make them consistent across 64- and 32-bit arches so the runtime code can be portable. There may also be some fields where it's fine for the type to change. Making the fields exported probably doesn't matter as long as the types themselves aren't exported. Though if there are any transformations going on at all, this would be an easy one. Some of the field names are different in silly ways (like My broader point is that adjusting other runtime code is fine, but do no harm. Things where the code can be adjusted without affecting the complexity are fine, but I'd be very weary of things that make the runtime code more complex. |
Thank you for the detailed explanation. Now I understand how differing types corrupt the runtime.
Definitely. I'll consider that. |
Change https://golang.org/cl/87115 mentions this issue: |
It seems that
defs_$GOOS.go
used to generatedefs_$GOOS_$GOARCH.go
in the old days.go/src/runtime/defs_darwin.go
Lines 7 to 12 in 596e3d9
However,
-cdefs
is not a valid cgo option today and people started to add features ad hoc.I think making those regeneratable again have some worthy.
The text was updated successfully, but these errors were encountered: