bump(main/tinygo): 0.29.0 (#17740)

Add custom auto update
This commit is contained in:
Jia Yuan Lo 2023-09-02 09:59:12 +08:00 committed by GitHub
parent e8dde8789a
commit 2e14ee3df7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 15 deletions

View File

@ -154,7 +154,7 @@ jobs:
- name: Free additional disk space (if necessary)
run: |
if grep -q '^clvk$\|^dart$\|^rust$\|^rustc-nightly$\|^zig$' ./built_termux-main_packages.txt || \
if grep -q '^clvk$\|^dart$\|^rust$\|^rustc-nightly$\|^tinygo$\|^zig$' ./built_termux-main_packages.txt || \
grep -q '^firefox$' ./built_termux-x11_packages.txt; then
echo "Free additional disk space on host"
sudo apt purge -yq $(dpkg -l | grep '^ii' | awk '{ print $2 }' | grep -P '(cabal-|dotnet-|ghc-|libmono|php|aspnetcore)') \

View File

@ -1,6 +1,8 @@
diff --git a/Makefile b/Makefile
index f6c0527..4834f3c 100644
--- a/Makefile
+++ b/Makefile
@@ -246,7 +246,7 @@ $(LLVM_BUILDDIR)/build.ninja:
@@ -248,7 +248,7 @@ $(LLVM_BUILDDIR)/build.ninja:
# Build LLVM.
$(LLVM_BUILDDIR): $(LLVM_BUILDDIR)/build.ninja
@ -9,26 +11,28 @@
ifneq ($(USE_SYSTEM_BINARYEN),1)
# Build Binaryen
@@ -263,15 +263,15 @@ endif
@@ -265,7 +265,7 @@ endif
wasi-libc: lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a
lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a:
@if [ ! -e lib/wasi-libc/Makefile ]; then echo "Submodules have not been downloaded. Please download them using:\n git submodule update --init"; exit 1; fi
- cd lib/wasi-libc && make -j4 EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC=$(CLANG) AR=$(LLVM_AR) NM=$(LLVM_NM)
+ cd lib/wasi-libc && make -j`nproc` EXTRA_CFLAGS="-O2 -g -DNDEBUG -mnontrapping-fptoint -msign-ext" MALLOC_IMPL=none CC=$(CLANG) AR=$(LLVM_AR) NM=$(LLVM_NM)
# Check for Node.js used during WASM tests.
NODEJS_VERSION := $(word 1,$(subst ., ,$(shell node -v | cut -c 2-)))
@@ -281,9 +281,9 @@ endif
# Build the Go compiler.
tinygo:
@if [ ! -f "$(LLVM_BUILDDIR)/bin/llvm-config" ]; then echo "Fetch and build LLVM first by running:"; echo " make llvm-source"; echo " make $(LLVM_BUILDDIR)"; exit 1; fi
- CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode exe -o build/tinygo$(EXE) -tags "byollvm osusergo" -ldflags="-X github.com/tinygo-org/tinygo/goenv.GitSha1=`git rev-parse --short HEAD`" .
+ CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GOENVFLAGS) $(GO) build -buildmode pie -o build/tinygo$(EXE) -tags "byollvm osusergo" -ldflags="-X github.com/tinygo-org/tinygo/goenv.GitSha1=`git rev-parse --short HEAD`" .
test: wasi-libc
test: wasi-libc check-nodejs-version
- CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=20m -buildmode exe -tags "byollvm osusergo" ./builder ./cgo ./compileopts ./compiler ./interp ./transform .
+ CGO_CPPFLAGS="$(CGO_CPPFLAGS)" CGO_CXXFLAGS="$(CGO_CXXFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) test $(GOTESTFLAGS) -timeout=20m -buildmode pie -tags "byollvm osusergo" ./builder ./cgo ./compileopts ./compiler ./interp ./transform .
# Standard library packages that pass tests on darwin, linux, wasi, and windows, but take over a minute in wasi
TEST_PACKAGES_SLOW = \
@@ -417,11 +417,11 @@ tinygo-bench-wasi-fast:
@@ -440,11 +440,11 @@ tinygo-bench-wasi-fast:
# Test external packages in a large corpus.
test-corpus:

View File

@ -3,16 +3,16 @@ TERMUX_PKG_DESCRIPTION="Go compiler for microcontrollers, WASM, CLI tools"
TERMUX_PKG_LICENSE="custom"
TERMUX_PKG_LICENSE_FILE="LICENSE"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="0.28.1"
TERMUX_PKG_REVISION=3
TERMUX_PKG_VERSION="0.29.0"
TERMUX_PKG_SRCURL=git+https://github.com/tinygo-org/tinygo
TERMUX_PKG_GIT_BRANCH="v${TERMUX_PKG_VERSION}"
TERMUX_PKG_SHA256=fbf83a67f5b0d57742616b7591b8de26cabd234cee3d27c800440f1b22f868ab
TERMUX_PKG_SHA256=1a0dc330f08c28b9adb3e06ef42c586f1257b979618ea0f5f5a0467588743bba
TERMUX_PKG_DEPENDS="libc++, tinygo-common"
TERMUX_PKG_RECOMMENDS="binaryen"
TERMUX_PKG_NO_STATICSPLIT=true
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_HOSTBUILD=true
TERMUX_PKG_AUTO_UPDATE=true
_LLVM_OPTION="
-DCMAKE_BUILD_TYPE=MinSizeRel
@ -40,6 +40,57 @@ lib/libLLVMLineEditor.a
lib/libLLVMXRay.a
"
termux_pkg_auto_update() {
local latest_tag
latest_tag=$(termux_github_api_get_tag "${TERMUX_PKG_SRCURL}" "${TERMUX_PKG_UPDATE_TAG_TYPE}")
if [[ -z "${latest_tag}" ]]; then
termux_error_exit "ERROR: Unable to get tag from ${TERMUX_PKG_SRCURL}"
fi
if [[ "${latest_tag}" == "${TERMUX_PKG_VERSION}" ]]; then
echo "INFO: No update needed. Already at version '${TERMUX_PKG_VERSION}'."
return
fi
local uptime_now=$(uptime -p)
local uptime_y=$(echo "${uptime_now}" | sed -nE "s|.* ([0-9]+) year.*|\1|p")
local uptime_w=$(echo "${uptime_now}" | sed -nE "s|.* ([0-9]+) week.*|\1|p")
local uptime_d=$(echo "${uptime_now}" | sed -nE "s|.* ([0-9]+) day.*|\1|p")
local uptime_h=$(echo "${uptime_now}" | sed -nE "s|.* ([0-9]+) hour.*|\1|p")
local uptime_m=$(echo "${uptime_now}" | sed -nE "s|.* ([0-9]+) minute.*|\1|p")
[[ -z "${uptime_y}" ]] && uptime_y=0
[[ -z "${uptime_w}" ]] && uptime_w=0
[[ -z "${uptime_d}" ]] && uptime_d=0
[[ -z "${uptime_h}" ]] && uptime_h=0
[[ -z "${uptime_m}" ]] && uptime_m=0
local uptime_m_sum=$((uptime_y*365*24*60+uptime_w*7*24*60+uptime_d*24*60+uptime_h*60+uptime_m))
local uptime_h_limit=1
local uptime_m_limit=$((uptime_h_limit*60))
if [[ "${uptime_m_sum}" -gt "${uptime_m_limit}" ]]; then
cat <<- EOL >&2
WARN: Uptime exceeds time limit! Deferring update.
Current uptime: ${uptime_now}
Limit (hour): ${uptime_h_limit}
EOL
return
fi
local tmpdir=$(mktemp -d)
git clone --branch "${latest_tag}" --depth=1 --recursive \
"${TERMUX_PKG_SRCDIR#git+}" "${tmpdir}"
make -C "${tmpdir}" llvm-source GO=:
local s=$(find . -type f ! -path '*/.git/*' -print0 | xargs -0 sha256sum | LC_ALL=C sort | sha256sum | cut -d" " -f1)
sed \
-e "s|^TERMUX_PKG_SHA256=.*|TERMUX_PKG_SHA256=${s}|" \
-i "${TERMUX_PKG_BUILDER_DIR}/build.sh"
rm -fr "${tmpdir}"
termux_pkg_upgrade_version "${latest_tag}"
}
termux_step_post_get_source() {
# https://github.com/tinygo-org/tinygo/blob/release/Makefile
# https://github.com/espressif/llvm-project
@ -70,11 +121,11 @@ termux_step_host_build() {
-j "${TERMUX_MAKE_PROCESSES}" \
${_LLVM_EXTRA_BUILD_TARGETS}
echo "========== llvm-config =========="
echo "===== llvm-config ====="
file "${TERMUX_PKG_HOSTBUILD_DIR}/bin/llvm-config"
"${TERMUX_PKG_HOSTBUILD_DIR}/bin/llvm-config" --cppflags
"${TERMUX_PKG_HOSTBUILD_DIR}/bin/llvm-config" --ldflags --libs --system-libs
echo "========== llvm-config =========="
echo "===== llvm-config ====="
make build/release \
LLVM_BUILDDIR="${TERMUX_PKG_HOSTBUILD_DIR}" \
@ -117,10 +168,10 @@ termux_step_make() {
local _LLVM_TARGET_TRIPLE=${TERMUX_HOST_PLATFORM/-/-unknown-}${TERMUX_PKG_API_LEVEL}
local _LLVM_TARGET_ARCH
case "${TERMUX_ARCH}" in
aarch64) _LLVM_TARGET_ARCH=AArch64 ;;
arm) _LLVM_TARGET_ARCH=ARM ;;
i686|x86_64) _LLVM_TARGET_ARCH=X86 ;;
*) termux_error_exit "Invalid arch: ${TERMUX_ARCH}" ;;
aarch64) _LLVM_TARGET_ARCH="AArch64" ;;
arm) _LLVM_TARGET_ARCH="ARM" ;;
i686|x86_64) _LLVM_TARGET_ARCH="X86" ;;
*) termux_error_exit "Invalid arch: ${TERMUX_ARCH}" ;;
esac
_LLVM_OPTION+="
-DLLVM_HOST_TRIPLE=${_LLVM_TARGET_TRIPLE}