hugo
hugo copied to clipboard
build: Add linux/arm64 extended
/cc @klakegg
OK, installing both a Linux C++ build chain for AMD64 and ARM64 was filled with more conflicts/troubles than I'm prepared to contribute at the moment. This will have to wait.
@bep @klakegg from personal experience I've had no problem building extended in a multi-arch Alpine container (on my M1 Mac but inside Docker) since 0.82.0 just using mage.
#25 [linux/arm64 build 5/6] RUN mage -v hugo && mage install
#25 367.9 Running target: Hugo
#25 367.9 exec: git rev-parse --short HEAD
#25 367.9 exec: go build -ldflags -X github.com/gohugoio/hugo/common/hugo.commitHash=6061821 -X github.com/gohugoio/hugo/common/hugo.buildDate=2021-04-20T13:44:41Z -tags extended github.com/gohugoio/hugo
#25 369.6 go: downloading github.com/bep/golibsass v0.7.0
#25 DONE 2339.2s
#26 [linux/arm64 build 6/6] RUN go get github.com/yaegashi/muslstack && muslstack -s 0x800000 /go/bin/hugo
#26 1.386 go: downloading github.com/yaegashi/muslstack v0.0.0-20190620175431-d19cc5866abc
#26 4.293 go get: added github.com/yaegashi/muslstack v0.0.0-20190620175431-d19cc5866abc
#26 4.757 /go/bin/hugo: stackSize: 0x800000
#26 DONE 4.8s
#28 [linux/arm64 stage-1 3/4] RUN hugo env
#28 113.2 hugo v0.82.1-6061821+extended linux/arm64 BuildDate=2021-04-20T14:16:54Z
#28 113.2 GOOS="linux"
#28 113.2 GOARCH="arm64"
#28 113.2 GOVERSION="go1.16.3"
Full (very messy) build log example here, Dockerfile here, and my v0.82.1 extended Docker image for both AMD64 and ARM64 here. I'm using docker buildx which is just a wrapper for QEMU, so the ARM64 binary is built on ARM64 and the AMD64 binary is built on AMD64 — maybe that helps?
I haven't tried building it on Debian/Ubuntu (that's what the release CI uses, right?) but I can investigate further if that'd be helpful.
The macOS ARM64 binary has been working fantastically but Linux would also be very helpful now that Docker for Mac supports M1! 👍
@jakejarvis does your multiarch docker setup include MacOS and Windows?
To elaborate on my last comment -- I don't have any problems building extended in a Docker container, I don't have problem with ARM64, either -- but I have problems all of this in the same Docker container -- which is how the current build setup works.
I've had success (after lots of trial and error) in two scenarios which end up with the same result:
- On my M1 Mac with Docker, which runs ARM64 Linux natively to build the ARM64 Linux binary, and emulates AMD64 Linux to build the AMD64 Linux binary.
- On GitHub Actions which does the exact opposite of that (emulating ARM64 on an AMD64 machine).
So what I have not tried is using a single container to build both Linux binaries, which sounds like where the difference lies? I'm not actually building any macOS (or windows) binaries either which simplifies things too.
I'm definitely no expert with any of this though, and if running two parallel containers via buildx is truly the only way to achieve this with Go, reworking the whole CI releaser to use it is probably much more complicated than I'm assuming it is... ;)
build both Linux binaries, which sounds like where the difference lies?
That is the core of my problem, I think.
below goreleaser script for build arm64:
env:
- CGO_ENABLED=1
- CC=aarch64-linux-gnu-gcc
- CXX=aarch64-linux-gnu-g++
flags:
- -buildmode
- exe
- -tags
- extended
goos:
- linux
goarch:
- arm64
goarm:
- 7
You migth need to insteall gcc/g++ for cross compile in the docker to build arm64 too.
I didn't have any problems when using the same docker to build for linux_amd64, linux_arm64, osx, window.
I able to run binary it on android with termux but I unable to execute babel via hugo but able to execute babel cli from command line instead, it seems golang bug but I'm not sure. however, I change from from babel to javascript building(esbuild) and it's working fine.
Hope this help.
The previous 10 (encounting) Hugo releases are available for Linux on arm/v7 and arm64/v8 right over here for those looking for the binaries and checksums: https://github.com/hugoguru/dist-hugo/releases
This does not solve this issue, however it may help move further in their testing on arm architectures. :smile:
FWIW using Fedora 36 as a builder I had to install g++ to get the extended version to build at all. It failed at:
#0 181.7 go build github.com/bep/golibsass/internal/libsass
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.