Skip to content

Commit

Permalink
build: prevent go from linking libresolv dynamically. (#4394)
Browse files Browse the repository at this point in the history
This is default (https://pkg.go.dev/net@go1.21.1#hdr-Name_Resolution).
It creates an indirect dependency on a fresh version of glibc.
As a result, it prevents our binaries from running on not-so-fesh docker
images.
  • Loading branch information
jiceatscion authored Sep 25, 2023
1 parent e80afbf commit ae14b74
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### common options for all subcommands (help, query, build, ...)
common --show_timestamps
common --show_timestamps --enable_platform_specific_config

# connect to buchgr/bazel-remote cache
# These flags can unfortunately not be specified for `common`, as they are not accepted by all subcommands (help, version, dump)
Expand All @@ -17,7 +17,8 @@ build --incompatible_default_to_explicit_init_py

# include one of "--define gotags=sqlite_mattn" or "--define gotags=sqlite_modernc"
# cannot be in common, because query chokes on it.
build --define gotags=sqlite_modernc
build --define gotags=sqlite_modernc,netgo
build:osx --define gotags=sqlite_modernc

### options for test
test --build_tests_only --print_relative_test_log_paths --test_output=errors
Expand Down
46 changes: 42 additions & 4 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ load("@cgrindel_bazel_starlib//updatesrc:defs.bzl", "updatesrc_update_all")
#
# This is simplistic but the complete, by-the-everchanging-bazel-book, solution
# is ludicrously complicated. Go there if and when needed.
config_setting(
name = "sqlite_mattn_netgo",
define_values = {
"gotags": "sqlite_mattn,netgo",
},
)

config_setting(
name = "sqlite_modernc_netgo",
define_values = {
"gotags": "sqlite_modernc,netgo",
},
)

config_setting(
name = "sqlite_mattn",
define_values = {
Expand Down Expand Up @@ -61,8 +75,20 @@ config_setting(
gazelle(
name = "gazelle",
build_tags = select({
":sqlite_modernc": ["sqlite_modernc"],
":sqlite_mattn": ["sqlite_mattn"],
":sqlite_modernc_netgo": [
"sqlite_modernc",
"sqlite_modernc_netgo",
],
":sqlite_modernc": [
"sqlite_modernc",
],
":sqlite_mattn_netgo": [
"sqlite_mattn",
"netgo",
],
":sqlite_mattn": [
"sqlite_mattn",
],
}),
command = "update",
extra_args = [
Expand All @@ -76,8 +102,20 @@ gazelle(
gazelle(
name = "gazelle_diff",
build_tags = select({
":sqlite_modernc": ["sqlite_modernc"],
":sqlite_mattn": ["sqlite_mattn"],
":sqlite_modernc_netgo": [
"sqlite_modernc",
"netgo",
],
":sqlite_modernc": [
"sqlite_modernc",
],
":sqlite_mattn_netgo": [
"sqlite_mattn",
"netgo",
],
":sqlite_mattn": [
"sqlite_mattn",
],
}),
command = "update",
extra_args = [
Expand Down

0 comments on commit ae14b74

Please sign in to comment.