From 36ee7d238da29b25eeceeaeeb3d313e909902140 Mon Sep 17 00:00:00 2001 From: alufers Date: Tue, 23 Aug 2022 21:43:17 +0200 Subject: [PATCH] tools: change zig to install from a tarball (fixes: #1085) (#1089) * tools: change zig to install from a tarball Migrate from using snap, we install from a cheksumed tarball * fix: add sudo * fix: install zig to .zig in PWD Co-authored-by: Albert Koczy --- .gitignore | 4 ++++ setup-test-tools.sh | 29 ++++++++++++++++++++++++++--- tests/binaries/makefile | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 39408dd1..bda2340b 100644 --- a/.gitignore +++ b/.gitignore @@ -70,6 +70,10 @@ tests/.pytest_cache/ tests/binaries/*.o tests/binaries/*.out tests/binaries/gosample.x* +/tests/binaries/div_zero_binary/core +/tests/binaries/div_zero_binary/binary # VS Code files .vscode/ + +.zig/ diff --git a/setup-test-tools.sh b/setup-test-tools.sh index c02bdb0f..ea7a829f 100755 --- a/setup-test-tools.sh +++ b/setup-test-tools.sh @@ -23,10 +23,33 @@ install_apt() { sudo apt-get install -y \ nasm \ gcc \ - libc6-dev - test -f /usr/bin/go || sudo apt-get install -y golang + libc6-dev \ + curl \ + build-essential \ + gdb + test -f /usr/bin/go || sudo apt-ge\t install -y golang + + # Install zig to current directory # We use zig to compile some test binaries as it is much easier than with gcc - sudo snap install zig --classic --edge + if ! command -v zig &> /dev/null + then + ZIG_TAR_URL="https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.3685+dae7aeb33.tar.xz" + ZIG_TAR_SHA256="dfc8f5ecb651342f1fc2b2828362b62f74fadac9931bda785b80bf7ecfcfabb2" + curl --output /tmp/zig.tar.xz "${ZIG_TAR_URL}" + ACTUAL_SHA256=$(sha256sum /tmp/zig.tar.xz | cut -d' ' -f1) + if [ "${ACTUAL_SHA256}" != "${ZIG_TAR_SHA256}" ]; then + echo "Zig binary checksum mismatch" + echo "Expected: ${ZIG_TAR_SHA256}" + echo "Actual: ${ACTUAL_SHA256}" + exit 1 + fi + + tar -C /tmp -xJf /tmp/zig.tar.xz + + mv /tmp/zig-linux-x86_64-* "$(pwd)/.zig" 2>/dev/null >/dev/null || true + echo "Zig installed to $(pwd)/.zig" + fi + } if linux; then diff --git a/tests/binaries/makefile b/tests/binaries/makefile index 9df0733f..5ed33066 100644 --- a/tests/binaries/makefile +++ b/tests/binaries/makefile @@ -1,4 +1,4 @@ -ZIGCC = zig cc +ZIGCC = $(shell pwd)/../../.zig/zig cc CC = gcc DEBUG = 1