Skip to content
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

patch: let cmd/go be built statically and still make cgo binaries from that static binary #52

Open
bradfitz opened this issue Feb 9, 2023 · 3 comments

Comments

@bradfitz
Copy link
Member

bradfitz commented Feb 9, 2023

Summary: let us build tailscale/go's cmd/go as a static binary so it runs on NixOS, but then still be able to build cgo binaries with it.
Upstream status: should but haven't.
Importance: required for NixOS users inside the company, including some of our builders
Example prior commit: a2f29de

(Then used in 26292c0, 178d6bc, etc)

cc @danderson

@bradfitz
Copy link
Member Author

bradfitz commented Feb 13, 2025

ts1.23: 1e42045
ts.124: d186334

@bradfitz bradfitz added the ts24 label Feb 13, 2025
bradfitz added a commit that referenced this issue Feb 20, 2025
This reverts commit a4256bc.

This now breaks x/tools/go/packages (and thus depaware) for some reason, but
this also doesn't seem necessary anymore--- the Go 1.24.0 binaries (cmd/go)
are already statically linked.

So I'm going to revert this and run it through our CI and verify this
is truly not needed anymore. I haven't dug into when/why Go changed
its behavior yet.

Updates #52
bradfitz added a commit to tailscale/tailscale that referenced this issue Feb 20, 2025
…tream bump

Diff:
tailscale/go@7c08383

This reverts our previous CGO_ENABLED change: tailscale/go@c1d3e9e

It was causing depaware problems and is no longer necessary it seems? Upstream cmd/go is static nowadays.

And pulls in:

    [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
    [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
    [release-branch.go1.24] syscall: don't truncate newly created files on Windows
    [release-branch.go1.24] runtime: fix usleep on s390x/linux
    [release-branch.go1.24] runtime: add some linknames back for `github.com/bytedance/sonic`

Of those, really the only the 2nd and 3rd might affect us.

Updates #15015
Updates tailscale/go#52

Change-Id: I0fa479f8b2d39f43f2dcdff6c28289dbe50b0773
Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit that referenced this issue Feb 20, 2025
Build with CGO_ENABLED="" to match how upstream (golang.org/x/build/cmd/gorebuild)
makes the official Go releases. Our go/build/zcgo.go had CGO_ENABLED="0" vs
upstream's "".

See c1d3e9e for some background. That revert
didn't work by itself.

Updates #52

Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit to tailscale/tailscale that referenced this issue Feb 20, 2025
…tream bump

Diff:
tailscale/go@7c08383

This reverts our previous CGO_ENABLED change: tailscale/go@c1d3e9e

It was causing depaware problems and is no longer necessary it seems? Upstream cmd/go is static nowadays.

And pulls in:

    [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
    [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
    [release-branch.go1.24] syscall: don't truncate newly created files on Windows
    [release-branch.go1.24] runtime: fix usleep on s390x/linux
    [release-branch.go1.24] runtime: add some linknames back for `github.com/bytedance/sonic`

Of those, really the only the 2nd and 3rd might affect us.

Updates #15015
Updates tailscale/go#52

Change-Id: I0fa479f8b2d39f43f2dcdff6c28289dbe50b0773
Signed-off-by: Brad Fitzpatrick <[email protected]>
@bradfitz
Copy link
Member Author

This patch hasn't been relevant since Go 1.21 which did golang@8a27154 ("Build cmd with CGO_ENABLED=0. ... In particular the Linux versions will run on Alpine and NixOS without needing a simulation of libc.so.6.")

But in Go 1.24 something else changed (TBD) which makes this change actually harmful and break depaware (by breaking x/tools/go/packages) which sets CGO_ENABLED=1 on GOOS=cross-compiled-values. But we only see that breakage when using gocross now, so something in gocross needs adjusting.

/cc @danderson @raggi @awly @icio

@bradfitz
Copy link
Member Author

(label "upstreamed" is a bit of a stretch because we didn't do it, but it's the closest label we've got)

bradfitz added a commit to tailscale/tailscale that referenced this issue Feb 21, 2025
…tream bump

Diff:
tailscale/go@7c08383

This reverts our previous CGO_ENABLED change: tailscale/go@c1d3e9e

It was causing depaware problems and is no longer necessary it seems? Upstream cmd/go is static nowadays.

And pulls in:

    [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
    [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
    [release-branch.go1.24] syscall: don't truncate newly created files on Windows
    [release-branch.go1.24] runtime: fix usleep on s390x/linux
    [release-branch.go1.24] runtime: add some linknames back for `github.com/bytedance/sonic`

Of those, really the only the 2nd and 3rd might affect us.

Updates #15015
Updates tailscale/go#52

Change-Id: I0fa479f8b2d39f43f2dcdff6c28289dbe50b0773
Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit to tailscale/tailscale that referenced this issue Feb 21, 2025
…tream bump

Diff:
tailscale/go@7c08383

This reverts our previous CGO_ENABLED change: tailscale/go@c1d3e9e

It was causing depaware problems and is no longer necessary it seems? Upstream cmd/go is static nowadays.

And pulls in:

    [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
    [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
    [release-branch.go1.24] syscall: don't truncate newly created files on Windows
    [release-branch.go1.24] runtime: fix usleep on s390x/linux
    [release-branch.go1.24] runtime: add some linknames back for `github.com/bytedance/sonic`

Of those, really the only the 2nd and 3rd might affect us.

Updates #15015
Updates tailscale/go#52

Change-Id: I0fa479f8b2d39f43f2dcdff6c28289dbe50b0773
Signed-off-by: Brad Fitzpatrick <[email protected]>
bradfitz added a commit to tailscale/tailscale that referenced this issue Feb 21, 2025
…tream bump

Diff:
tailscale/go@7c08383

This reverts our previous CGO_ENABLED change: tailscale/go@c1d3e9e

It was causing depaware problems and is no longer necessary it seems? Upstream cmd/go is static nowadays.

And pulls in:

    [release-branch.go1.24] doc/godebug: mention GODEBUG=fips140
    [release-branch.go1.24] cmd/compile: avoid infinite recursion when inlining closures
    [release-branch.go1.24] syscall: don't truncate newly created files on Windows
    [release-branch.go1.24] runtime: fix usleep on s390x/linux
    [release-branch.go1.24] runtime: add some linknames back for `github.com/bytedance/sonic`

Of those, really the only the 2nd and 3rd might affect us.

Updates #15015
Updates tailscale/go#52

Change-Id: I0fa479f8b2d39f43f2dcdff6c28289dbe50b0773
Signed-off-by: Brad Fitzpatrick <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant