k0sproject / k0s

k0s - The Zero Friction Kubernetes
https://docs.k0sproject.io
Other
3.11k stars 353 forks source link

feat(riscv64): Here is how far I've got. #4665

Open IngwiePhoenix opened 6 days ago

IngwiePhoenix commented 6 days ago

Hello!

I have been using k3s for a while now, but long-term I want to expand to literally all my hardware - which includes a VisionFive2. So, I just throw stuff at a wall and see what sticks. Hence, here is an attempt at compiling for riscv64:

root@riscboi /n/o/k0s (main)# make HOST_ARCH=riscv64 EMBEDDED_BINS_BUILDMODE=none -j$(nproc)
mkdir -p -- 'build/cache'
docker build --progress=plain --iidfile '.k0sbuild.docker-image.k0s' \
  --build-arg BUILDIMAGE=docker.io/library/golang:1.22.4-alpine3.20 \
  -t k0sbuild.docker-image.k0s - <build/Dockerfile
STEP 1/3: FROM docker.io/library/golang:1.22.4-alpine3.20
Trying to pull docker.io/library/golang:1.22.4-alpine3.20...
Getting image source signatures
Copying blob 4f4fb700ef54 done   |
Copying blob 4e5b5f435f7e done   |
Copying blob d4714cc4c8bb done   |
Copying blob 720f2671938f done   |
Copying blob e88f851c95d1 done   |
Copying config f9e44e4509 done   |
Writing manifest to image destination
STEP 2/3: RUN apk add --no-cache make gcc musl-dev binutils-gold
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/riscv64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/riscv64/APKINDEX.tar.gz
ERROR: unable to select packages:
  binutils-gold (no such package):
    required by: world[binutils-gold]
Error: building at STEP "RUN apk add --no-cache make gcc musl-dev binutils-gold": while running runtime: exit status 1
make: *** [Makefile:108: .k0sbuild.docker-image.k0s] Error 1

Notes:

I thought setting EMBEDDED_BINS_BUILDMODE=none would disable Docker alltogether, but it did not...?

Any improvements I could do to get this building a little further than...that?

Kind regards, Ingwie

twz123 commented 6 days ago

/cc #1919

haven't tested it in a while, but now that Alpine 3.20 has RISC-V support, you should be able to compile k0s directly on the VisionFive using Docker. It'll take time, but it should work.

Cross compilation is not really supported by the k0s build system. Sorry. You can disable the docker wrapper by make GO=go K0S_EMBEDDED_BINS=none. Note that you'll need RISC-V docker images as well if you want to run workloads on the cluster.

twz123 commented 6 days ago

That was my last attempt: https://github.com/k0sproject/k0s/issues/1919#issuecomment-1746962060

You can have a look at the diff to figure out what to tweak.

twz123 commented 3 days ago

@ncopa concerning https://github.com/k0sproject/k0s/issues/1919#issuecomment-1761203870, do you think we can simply unconditionally switch from binutils-gold to binutils?

ncopa commented 1 day ago

Go forces use of gold on arm/arm64 due to an old bug in binutils, which seems to be fixed now. Go still need to adapt.

See: https://github.com/golang/go/issues/22040

I think we can pull in binutils-gold conditionally.