diff --git a/.github/workflows/obitest.yml b/.github/workflows/obitest.yml index 9d0f12a..2827f65 100644 --- a/.github/workflows/obitest.yml +++ b/.github/workflows/obitest.yml @@ -12,7 +12,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: '1.23' + go-version: '1.27' - name: Checkout obitools4 project uses: actions/checkout@v5 - name: Run tests diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c8855d6..a215b51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.26" + go-version: "1.27" - name: Checkout obitools4 project uses: actions/checkout@v5 - name: Run tests @@ -54,7 +54,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.26" + go-version: "1.27" - name: Extract version from tag id: get_version @@ -78,7 +78,8 @@ jobs: -v "$(pwd):/src" \ -w /src \ -e VERSION="${VERSION}" \ - golang:1.26-alpine \ + -e GOEXPERIMENT=simd \ + golang:1.27-alpine \ sh -c "apk add --no-cache gcc musl-dev zlib-dev zlib-static make && \ make LDFLAGS='-linkmode=external -extldflags=-static' obitools" mkdir -p artifacts diff --git a/Makefile b/Makefile index 2a7817b..96a0768 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,14 @@ NC := \033[0m GOFLAGS= LDFLAGS= + +# The SIMD code (pkg/obikmer, simd package of Go >= 1.27) is only compiled with +# GOEXPERIMENT=simd; without it, a portable scalar code is used instead. +# The binaries select the vector width at run time (and fall back on an +# emulation without SIMD hardware), so they run on any CPU. +# Use `make GOEXPERIMENT= obitools` to build without SIMD. +GOEXPERIMENT?=simd +export GOEXPERIMENT GOCMD=go GOBUILD=$(GOCMD) build $(GOFLAGS) $(if $(LDFLAGS),-ldflags="$(LDFLAGS)") GOGENERATE=$(GOCMD) generate diff --git a/doc/book/installation.qmd b/doc/book/installation.qmd index f015194..b96b2f5 100644 --- a/doc/book/installation.qmd +++ b/doc/book/installation.qmd @@ -8,7 +8,7 @@ All the sources of the [*OBITools4*](http://metabarcoding.org/obitools4) can be ## Prerequisites -The *OBITools4* are developped using the [GO programming language](https://go.dev/), we stick to the latest version of the language, today the $1.21.4$. If you want to download and compile the sources yourself, you first need to install the corresponding compiler on your system. Some parts of the soft are also written in C, therefore a recent C compiler is also requested, GCC on Linux or Windows, the Developer Tools on Mac. +The *OBITools4* are developped using the [GO programming language](https://go.dev/), we stick to the latest version of the language, today the $1.27$. If you want to download and compile the sources yourself, you first need to install the corresponding compiler on your system. Some computations (distances between k-mers) use the experimental `simd` package of Go: the `Makefile` compiles them with `GOEXPERIMENT=simd`, and the installation script uses a Go 1.27 compiler for that reason. The resulting programs run on any processor, a portable code being used when no SIMD instruction is available. Some parts of the soft are also written in C, therefore a recent C compiler is also requested, GCC on Linux or Windows, the Developer Tools on Mac. Whatever the installation you decide for, you will have to ensure that a C compiler is available on your system. diff --git a/install_obitools.sh b/install_obitools.sh index 9248d44..9c410d4 100755 --- a/install_obitools.sh +++ b/install_obitools.sh @@ -2,6 +2,11 @@ # Default values URL="https://go.dev/dl/" +# Series of the Go compiler used to build OBITools4. The SIMD code relies on the +# experimental simd package of Go (GOEXPERIMENT=simd), whose API may change +# between Go versions: the build is therefore tied to the series the code was +# written for rather than to the latest release. +GO_SERIES="1.27" GITHUB_REPO="https://github.com/metabarcoding/obitools4" INSTALL_DIR="/usr/local" OBITOOLS_PREFIX="" @@ -174,10 +179,16 @@ GOFILE=$(curl -s "$URL" \ | grep 'class="download"' \ | grep "\.tar\.gz" \ | sed -E 's@^.*/dl/(go[1-9].+\.tar\.gz)".*$@\1@' \ + | awk -v prefix="go${GO_SERIES}." 'index($0, prefix) == 1' \ | grep -i "$OS" \ | grep -i "$ARCH" \ | head -1) +if [ -z "$GOFILE" ]; then + echo "Error: no Go ${GO_SERIES} archive found for ${OS}/${ARCH} at ${URL}" 1>&2 + exit 1 +fi + GOURL=$(curl -s "${URL}${GOFILE}" \ | sed -E 's@^.*href="(.*\.tar\.gz)".*$@\1@') @@ -191,8 +202,12 @@ export PATH export GOPATH="$(pwd)/gopath" export GOCACHE="$(pwd)/cache" export GOTOOLCHAIN=local +# OBITools4 is built with the SIMD code enabled (it falls back on a portable +# code at run time if the processor has no SIMD instructions). +export GOEXPERIMENT=simd echo "GOROOT=$GOROOT" 1>&2 +echo "GOEXPERIMENT=$GOEXPERIMENT" 1>&2 echo "GOCACHE=$GOCACHE" 1>&2 mkdir -p "$GOPATH" "$GOCACHE"