Skip to content

Commit

Permalink
script/release.sh: add -a to force rebuild
Browse files Browse the repository at this point in the history
https://golang.org/cmd/go/#hdr-Build_and_test_caching says:

> If you have made changes to the C libraries on your system, you will
> need to clean the cache explicitly or else use the -a build flag
> (see 'go help build') to force rebuilding of packages that depend
> on the updated C libraries.

This means that:

1. We need to either 'go clean -cache' or 'go build -a' when building
   the release binary. Adding '-a' seems less intrusive / more focused.

2. The check for existing libseccomp.a (added by commit d748280)
   is no longer needed.

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed May 3, 2021
1 parent c2c35ae commit 06a9ea3
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions script/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@ function build_project() {
# Due to libseccomp being LGPL we must include its sources,
# so download, install and build against it.

# Sanity check: check that the build won't use distro-provided
# libseccomp.a. If this is the case, explain and abort.
#
# Note go is not used here as it caches the build heavily,
# including, apparently, the results of pkg-config.
# shellcheck disable=SC2046
if read -ra flags < <(pkg-config --libs --cflags libseccomp 2>/dev/null) &&
cat <<EOF | gcc -static -x c -o /dev/null - "${flags[@]}"; then
#include <seccomp.h>
int main(void) { seccomp_version(); return 0; }
EOF
set +x
echo >&2
echo "Distro-provided libseccomp static library is installed." >&2
echo "Unable to build a static binary against own libsecomp." >&2
echo "Please uninstall libseccomp-static to fix." >&2
exit 1
fi

local libseccomp_ver='2.5.1'
local tarball="libseccomp-${libseccomp_ver}.tar.gz"
local prefix
Expand All @@ -62,7 +43,10 @@ EOF
)
mv "$tarball"{,.asc} "$builddir"

make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= static
# Add -a to go build flags to make sure it links against
# the provided libseccomp, not the system one (otherwise
# it can reuse cached pkg-config results).
make -C "$root" PKG_CONFIG_PATH="${prefix}/lib/pkgconfig" COMMIT_NO= EXTRA_FLAGS="-a" static
rm -rf "$prefix"
mv "$root/$project" "$1"
}
Expand Down

0 comments on commit 06a9ea3

Please sign in to comment.