Skip to content

contrib: Add bootstrap-go-toolchain.sh#380

Merged
Peter0x44 merged 1 commit into
skeeto:masterfrom
Peter0x44:go_building_script
May 10, 2026
Merged

contrib: Add bootstrap-go-toolchain.sh#380
Peter0x44 merged 1 commit into
skeeto:masterfrom
Peter0x44:go_building_script

Conversation

@Peter0x44
Copy link
Copy Markdown
Collaborator

Ever since w64devkit began forcing bigobj by default, it has been incompatible with cgo. I patched go to support bigobj, but unfortunately upstream the patch ran in to bureaucracy/difficulties and I ran out of patience to get it through. So that means it's not really an option to use upstream go binaries, it must build from source. Bootstrapping go is not difficult, but it has grown more tedious as more required stages have been added to the bootstrap chain.

So, to spare myself some tedium, I have created
bootstrap-go-toolchain.sh. It builds the latest version of go, from source, using only w64devkit's gcc compiler. It also adds my bigobj patches to the toolchain, so cgo works properly.

It might deserve a mention on:
https://nullprogram.com/blog/2020/01/21/

@skeeto
Copy link
Copy Markdown
Owner

skeeto commented May 10, 2026

Tried it out and it worked, thanks! It's nice to have cgo working again. I like that it caches the downloads. If it didn't I was going to suggest it.

Except a small hiccup: I had to unset GOBIN. There's a long-standing bug in the Go Windows bootstrap such that it breaks when this variable is present. I suggest unsetting it in the script. Other than that I'm happy with this.

@Peter0x44 Peter0x44 force-pushed the go_building_script branch from b4ecc24 to 88b8d7f Compare May 10, 2026 01:45
Ever since w64devkit began forcing bigobj by default, it has been
incompatible with cgo. I patched go to support bigobj, but unfortunately
upstream the patch ran in to bureaucracy/difficulties and I ran out of
patience to get it through. So that means it's not really an option to
use upstream go binaries, it must build from source. Bootstrapping go is
not difficult, but it has grown more tedious as more required stages
have been added to the bootstrap chain.

So, to spare myself some tedium, I have created
bootstrap-go-toolchain.sh. It builds the latest version of go, from
source, using only w64devkit's gcc compiler. It also adds my bigobj
patches to the toolchain, so cgo works properly.
@Peter0x44 Peter0x44 force-pushed the go_building_script branch from 88b8d7f to 8e557fe Compare May 10, 2026 02:05
@Peter0x44
Copy link
Copy Markdown
Collaborator Author

Except a small hiccup: I had to unset GOBIN. There's a long-standing bug in the Go Windows bootstrap such that it breaks when this variable is present. I suggest unsetting it in the script. Other than that I'm happy with this.

Done.

@Peter0x44 Peter0x44 merged commit 8e557fe into skeeto:master May 10, 2026
3 checks passed
@Peter0x44 Peter0x44 deleted the go_building_script branch May 10, 2026 09:51
@skeeto
Copy link
Copy Markdown
Owner

skeeto commented May 11, 2026

It might deserve a mention on:
https://nullprogram.com/blog/2020/01/21/

What mention did you have in mind? I thought it would be something about w64dk requiring this bootstrap, but on revisit I remember now that this article predates w64dk.

@Peter0x44
Copy link
Copy Markdown
Collaborator Author

I can extend it to support Linux too. Then mention that this script can build a toolchain for you.

@Peter0x44
Copy link
Copy Markdown
Collaborator Author

It doesn't really mention that now go has added extra stages to the bootstrap as well, so you have to go through several versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants