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

Add Go build tags to stdlib #3252

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/BUILD.plz
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ filegroup(
binary = True,
visibility = ["//:install"],
)

# On Linux, we should produce statically linked binaries. Emit a test to verify this is the case.
if is_platform(os = "linux"):
gentest(
name = "static_test",
test_cmd = "ldd $DATA && exit 1 || exit 0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever! Perhaps we should be more explicit though (file $DATA | grep 'statically linked')?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that first out :) It failed on most of our Docker images that don't have file in them, this seems like a slightly more common denominator.

data = [":please"],
no_test_output = True,
)
19 changes: 0 additions & 19 deletions test/stamp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,3 @@ sh_test(
src = "stamp_test.sh",
data = [":stamp"],
)

if is_platform(os = "linux"):
go_binary(
name = "stamp_static",
srcs = ["main.go"],
definitions = {
"github.com/thought-machine/please/test/stamp/lib.GitRevision": "$SCM_REVISION",
"github.com/thought-machine/please/test/stamp/lib.GitDescribe": "$SCM_DESCRIBE",
},
stamp = True,
static = True,
deps = ["//test/stamp/lib"],
)

sh_test(
name = "stamp_test_static",
src = "stamp_test.sh",
data = [":stamp_static"],
)
4 changes: 4 additions & 0 deletions third_party/go/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ go_toolchain(

go_stdlib(
name = "std",
tags = [
"netgo",
"osusergo",
],
)

go_repo(
Expand Down
1 change: 0 additions & 1 deletion tools/release_signer/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
go_binary(
name = "release_signer",
srcs = ["main.go"],
static = CONFIG.OS == "linux",
visibility = [
"//package/...",
"//tools/javac_worker:all",
Expand Down
Loading