-
Notifications
You must be signed in to change notification settings - Fork 28
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
Add arm/v6 cross-compiled build #523
Conversation
43e1064
to
f0c8178
Compare
Update bootstrap Go to 1.18 for strings.Cut. Add missing err checks in pack code.
f0c8178
to
a5fa7c1
Compare
# we need to be able to run the tool on the host, so we must always target the host OS/ARCH. Clear | ||
# out the GOOS/GOARCH values (empty string) to detect host OS/ARCH automatically for the tools. | ||
Invoke-CrossGoBlock "" "" { | ||
Write-Host "In '$tool_module', building '$module_local_script_path' -> $tool_output" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to be careful about is how block execution and variable scoping works in powershell. I've gotten burned by this in the past because I made bad assumptions about how name lookup works here. IIRC the variables are not actually captured, aka it's not a lambda, but instead the variable lookup occurs in the context where the block is evaluated.
Been many years since I got burned here so maybe I'm having bad memory but I would look into this a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right, no capturing.
In this particular case, capture vs. non-capture doesn't have any impact because Invoke-CrossGoBlock
doesn't set any variables that are being used in the block, the block is defined right here where it's being passed to the function, and the block doesn't escape. But definitely something to be aware of while modifying these scripts.
I could inline Invoke-CrossGoBlock
to avoid the weirdness, but we rely on blocks for Invoke-WithRetry
too, so it wouldn't really remove the need to know about this quirk.
I'm glad we're able to get out of this script and into the _core Go module relatively quickly. 😄
I ran an internal build on the latest commit: https://dev.azure.com/dnceng/internal/_build/results?buildId=1718680&view=results, and I tried ingesting it into go-images, but there are a couple things to fix: The build asset json lists the build as The |
Build asset JSON from new dev internal build looks good: https://dev.azure.com/dnceng/internal/_build/results?buildId=1727301&view=results. Generates expected armhf results in go-images with latest |
* Add arm/v6 cross-compiled build Update bootstrap Go to 1.18 for strings.Cut. Add missing err checks in pack code. * Use 'finally' in Invoke-CrossGoBlock * Explain getEnvOrDefault error case in doc comment * Update go-infra for build asset JSON arm/v6 fix (cherry picked from commit 41afc84)
Includes related changes:
strings.Cut
./
rather than\
for zips even though they're for Windows.To check the results, I cherry-picked to 1.18 and compared the file lists on the platforms we're currently building:
go/codereview.cfg
is normal.go/pkg/linux_arm/os/signal/internal/pty.a
is interesting. According to the source, it's only used to run tests.go/pkg/linux_arm/runtime/cgo.a
is probably missing because of the cross-compile: something like not being able to build cgo without running a C compiler that targets arm/v6. This might not be an issue, because when someone needs cgo their copy of Go might automatically build cgo if this.a
prebuilt file is missing.go tool dist test
, this file is built.go/pkg/tool/windows_amd64/api.exe
is an existing diff. I think it's actually an upstream bug--filed x/build/cmd/release: Windows zip/installer includes unnecessarypkg/tool/windows_amd64/api.exe
golang/go#52335go/test/fixedbugs/issue27836.dir/├Дfoo.go
is an existing diff, not new to this change. However, it seems to only be a problem withunzip -Z1
. When I extract the file on Windows, it ends up beingÄ
, not├Д
.As a very basic check that the cross-compiled Go works, I installed Debian Bullseye armhf (arm/v7) onto my RPi 4 (arm64 chip), and on there, the armv6l build from CI works to:
go tool dist test
.Our partners are going to be using armhf, so this is probably good enough for now.