Skip to content

Commit

Permalink
tool/gocross: add debug data to CGO builds
Browse files Browse the repository at this point in the history
We don't build a lot of tools with CGO, but we do build some, and it's
extremely valuable for production services in particular to have symbols
included - for perf and so on.

I tested various other builds that could be affected negatively, in
particular macOS/iOS, but those use split-dwarf already as part of their
build path, and Android which does not currently use gocross.

One binary which is normally 120mb only grew to 123mb, so the trade-off
is definitely worthwhile in context.

Updates tailscale/corp#20296

Signed-off-by: James Tucker <james@tailscale.com>
  • Loading branch information
raggi committed May 23, 2024
1 parent 3c9be07 commit 538c2e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tool/gocross/autoflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func autoflagsForTest(argv []string, env *Environment, goroot, nativeGOOS, nativ
targetOS = cmp.Or(env.Get("GOOS", ""), nativeGOOS)
targetArch = cmp.Or(env.Get("GOARCH", ""), nativeGOARCH)
buildFlags = []string{"-trimpath"}
cgoCflags = []string{"-O3", "-std=gnu11"}
cgoCflags = []string{"-O3", "-std=gnu11", "-g"}
cgoLdflags []string
ldflags []string
tags = []string{"tailscale_go"}
Expand Down
40 changes: 20 additions & 20 deletions tool/gocross/autoflags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestAutoflags(t *testing.T) {
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand All @@ -67,7 +67,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -96,7 +96,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=0 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=riscv64 (was riscv64)
Expand Down Expand Up @@ -125,7 +125,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=0 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand All @@ -151,7 +151,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -181,7 +181,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=0 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -210,7 +210,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=0 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -240,7 +240,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was 1)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand All @@ -266,7 +266,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=arm64 (was <nil>)
Expand Down Expand Up @@ -295,7 +295,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=arm64 (was <nil>)
Expand Down Expand Up @@ -324,7 +324,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=arm64 (was )
Expand Down Expand Up @@ -353,7 +353,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was amd64)
Expand Down Expand Up @@ -382,7 +382,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=arm64 (was <nil>)
Expand Down Expand Up @@ -415,7 +415,7 @@ TS_LINK_FAIL_REFLECT=1 (was <nil>)`,
nativeGOARCH: "arm64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -mmacosx-version-min=11.3 -isysroot /my/sdk/root -arch x86_64 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g -mmacosx-version-min=11.3 -isysroot /my/sdk/root -arch x86_64 (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS=-mmacosx-version-min=11.3 -isysroot /my/sdk/root -arch x86_64 (was <nil>)
GOARCH=amd64 (was amd64)
Expand Down Expand Up @@ -448,7 +448,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -miphoneos-version-min=15.0 -isysroot /my/sdk/root -arch arm64 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g -miphoneos-version-min=15.0 -isysroot /my/sdk/root -arch arm64 (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS=-miphoneos-version-min=15.0 -isysroot /my/sdk/root -arch arm64 (was <nil>)
GOARCH=arm64 (was arm64)
Expand All @@ -474,7 +474,7 @@ TS_LINK_FAIL_REFLECT=1 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand All @@ -500,7 +500,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -529,7 +529,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand All @@ -556,7 +556,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down Expand Up @@ -586,7 +586,7 @@ TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
nativeGOARCH: "amd64",

envDiff: `CC=cc (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
CGO_CFLAGS=-O3 -std=gnu11 -g (was <nil>)
CGO_ENABLED=1 (was <nil>)
CGO_LDFLAGS= (was <nil>)
GOARCH=amd64 (was <nil>)
Expand Down

0 comments on commit 538c2e8

Please sign in to comment.