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
cmd/cgo: use C exact-width integer types to represent Go types #29907
Conversation
This PR (HEAD: f243e24) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/159258 to see it. Tip: You can toggle comments from me using the |
Message from Ian Lance Taylor: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
This PR (HEAD: 1c1ebe3) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/159258 to see it. Tip: You can toggle comments from me using the |
Message from Philipp Stephani: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Ian Lance Taylor: Patch Set 2: R=go1.13 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Emmanuel Odeke: Patch Set 2: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 2: TryBots beginning. Status page: https://farmer.golang.org/try?commit=eec656d3 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 2: Build is still in progress... Consult https://build.golang.org/ to see whether it's a new failure. Other builds still in progress; subsequent failure notices suppressed until final report. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
This PR (HEAD: 71dac4a) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/159258 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: d8a401b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/159258 to see it. Tip: You can toggle comments from me using the |
Message from Philipp Stephani: Patch Set 4: I've moved the test to the misc/cgo directory, I hope they now pass. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Tobias Klauser: Patch Set 4: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 4: TryBots beginning. Status page: https://farmer.golang.org/try?commit=50991e3d Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 4: Build is still in progress... Consult https://build.golang.org/ to see whether it's a new failure. Other builds still in progress; subsequent failure notices suppressed until final report. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 4: TryBot-Result-1 2 of 19 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Ian Lance Taylor: Patch Set 4: Trybot failures look real. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Philipp Stephani: Patch Set 4:
Yes, agreed. This is because C and Go disagree about the alignment of (u)int64 on 32-bit x86. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Ian Lance Taylor: Patch Set 4:
How are you deciding what go/types uses for the alignment (I didn't look at your code)? When I run this:
it prints 4 as I expect. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Philipp Stephani: Patch Set 4:
What I mean are the alignment settings in the goTypes map in https://go.googlesource.com/go/+/refs/tags/go1.12.1/src/cmd/cgo/out.go#1375. They set the alignment to 8 unconditionally for the 64-bit types. I'm not quite sure what the Size and Align members of these map values refer to; should they match the actual size and alignment on the target architecture? Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Ian Lance Taylor: Patch Set 4:
The only place where that table is used, (*Package).cgoType, adjusts the alignment so that it does not exceed the target pointer size. That is supposed to make the result match what the compiler does. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
The exact-width integer types are required to use two’s complement representation and may not have padding bits, cf. §7.20.1.1/1 in the C11 standard or https://en.cppreference.com/w/c/types/integer. This ensures that they have the same domain and representation as the corresponding Go types. Fixes golang#29878
This PR (HEAD: 546a2cc) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/159258 to see it. Tip: You can toggle comments from me using the |
Message from Philipp Stephani: Patch Set 4:
OK, I've pushed a change making a similar adjustment. (Though I guess in the long run it'd be better to use the go/types package to reduce duplication.) Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Ian Lance Taylor: Patch Set 5: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 5: TryBots beginning. Status page: https://farmer.golang.org/try?commit=977bd5d7 Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
Message from Gobot Gobot: Patch Set 5: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
The exact-width integer types are required to use two’s complement representation and may not have padding bits, cf. §7.20.1.1/1 in the C11 standard or https://en.cppreference.com/w/c/types/integer. This ensures that they have the same domain and representation as the corresponding Go types. Fixes #29878 Change-Id: Ie8a51e91666dfd89731c7859abe47356c94ca1be GitHub-Last-Rev: 546a2cc GitHub-Pull-Request: #29907 Reviewed-on: https://go-review.googlesource.com/c/go/+/159258 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Message from Ian Lance Taylor: Patch Set 5: Code-Review+2 Thanks. RELNOTES=yes Please don’t reply on this GitHub thread. Visit golang.org/cl/159258. |
This PR is being closed because golang.org/cl/159258 has been merged. |
The exact-width integer types are required to use two’s complement
representation and may not have padding bits, cf. §7.20.1.1/1 in the C11
standard or https://en.cppreference.com/w/c/types/integer. This ensures that
they have the same domain and representation as the corresponding Go types.
Fixes #29878