From ae14b74ec94fbc83588ba4258ee4493d1d09e898 Mon Sep 17 00:00:00 2001 From: jiceatscion <139873336+jiceatscion@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:24:08 +0200 Subject: [PATCH] build: prevent go from linking libresolv dynamically. (#4394) 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. --- .bazelrc | 5 +++-- BUILD.bazel | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/.bazelrc b/.bazelrc index 0b4fa25f90..3dbfc2dbc4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -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) @@ -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 diff --git a/BUILD.bazel b/BUILD.bazel index e70dded2ae..be76b0e6c1 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -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 = { @@ -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 = [ @@ -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 = [