buck2: migrate linux binary to static musl build

A lot less work to support, and more reliable, too.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2023-07-18 07:47:33 -05:00
parent 7e7c8fc893
commit 5b86eecfab
3 changed files with 11 additions and 20 deletions

View File

@ -1,5 +1,4 @@
{ fetchurl, lib, stdenv, zstd
, autoPatchelfHook, gcc-unwrapped
, testers, buck2 # for passthru.tests
}:
@ -27,12 +26,8 @@ let
suffix = {
x86_64-darwin = "x86_64-apple-darwin";
aarch64-darwin = "aarch64-apple-darwin";
# TODO (aseipp): there's an aarch64-linux musl build of buck2, but not a
# x86_64-linux musl build. keep things consistent for now and use glibc
# builds for both; but we should fix this in the future to be less fragile;
# we can then remove autoPatchelfHook.
x86_64-linux = "x86_64-unknown-linux-gnu";
aarch64-linux = "aarch64-unknown-linux-gnu";
x86_64-linux = "x86_64-unknown-linux-musl";
aarch64-linux = "aarch64-unknown-linux-musl";
}."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
buck2-version = "2023-07-15";
@ -48,24 +43,20 @@ stdenv.mkDerivation {
version = "unstable-${buck2-version}"; # TODO (aseipp): kill 'unstable' once a non-prerelease is made
inherit src;
buildInputs = lib.optionals stdenv.isLinux [ gcc-unwrapped ]; # need libgcc_s.so.1 for patchelf
nativeBuildInputs = [ zstd ]
# TODO (aseipp): move to musl build and nuke this?
++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
nativeBuildInputs = [ zstd ];
doCheck = true;
dontConfigure = true;
dontStrip = true;
unpackPhase = "unzstd ${src} -o ./buck2";
buildPhase = "chmod +x ./buck2";
checkPhase = "./buck2 --version";
installPhase = ''
mkdir -p $out/bin
install -D buck2 $out/bin/buck2
'';
# NOTE (aseipp): use installCheckPhase instead of checkPhase so that
# autoPatchelfHook kicks in first.
doInstallCheck = true;
installCheckPhase = "$out/bin/buck2 --version";
passthru = {
updateScript = ./update.sh;
tests = testers.testVersion {

View File

@ -1,5 +1,5 @@
{ "x86_64-linux": "sha256-Nkx/GONX867kfU3pKhilIhbi71PRXFwjRVu/3GTpI1M="
{ "x86_64-linux": "sha256-xd8MZF1xpVYqEDoL3nUBptiFMn9UkgC+zIgfDkDxwfM="
, "x86_64-darwin": "sha256-d8GD7SwCM1gcWILkmSLRY7nq2w9+AMxgbGiWwAK0BAo="
, "aarch64-linux": "sha256-xSVYx6Go/hBL4fWi1LPkH8bSFVsTtSVfy1eEuaOvQd4="
, "aarch64-linux": "sha256-zBVgIgQ+tlBUuHwsZB5JmQJtWZ5soKP6//NxkU96xmo="
, "aarch64-darwin": "sha256-jswrwf37/0Rec551mORXYf+s45Nx16OeaRjRS9ROR4E="
}

View File

@ -12,9 +12,9 @@ VERSION=$(curl -s https://api.github.com/repos/facebook/buck2/releases \
echo "Latest buck2 prerelease: $VERSION"
ARCHS=(
"x86_64-linux:x86_64-unknown-linux-gnu"
"x86_64-linux:x86_64-unknown-linux-musl"
"x86_64-darwin:x86_64-apple-darwin"
"aarch64-linux:aarch64-unknown-linux-gnu"
"aarch64-linux:aarch64-unknown-linux-musl"
"aarch64-darwin:aarch64-apple-darwin"
)