Skip to content

Commit 15de97e

Browse files
committed
Add linux.riscv64 precompiled support
1 parent ac8fb00 commit 15de97e

File tree

6 files changed

+66
-1
lines changed

6 files changed

+66
-1
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
needs: package_source
4848
strategy:
4949
matrix:
50-
build: [linux.x86_64, linux.aarch64, linux.armv6hf, darwin.x86_64, darwin.aarch64, windows.x86_64]
50+
build: [linux.x86_64, linux.aarch64, linux.armv6hf, linux.riscv64, darwin.x86_64, darwin.aarch64, windows.x86_64]
5151
runs-on: ubuntu-latest
5252
steps:
5353
- name: Checkout repository

.multi_arch_docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function multi_arch_docker::main() {
8080
export DOCKER_PLATFORMS='linux/amd64'
8181
DOCKER_PLATFORMS+=' linux/arm64'
8282
DOCKER_PLATFORMS+=' linux/arm/v6'
83+
DOCKER_PLATFORMS+=' linux/riscv64'
8384

8485
multi_arch_docker::install_docker_buildx
8586
multi_arch_docker::login_to_docker_hub

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- SC2327/SC2328: Warn about capturing the output of redirected commands.
44
- SC2329: Warn when (non-escaping) functions are never invoked.
55
- SC2330: Warn about unsupported glob matches with [[ .. ]] in BusyBox.
6+
- Precompiled binaries for Linux riscv64 (linux.riscv64)
67
### Changed
78
- SC2015 about `A && B || C` no longer triggers when B is a test command.
89
### Fixed

build/linux.riscv64/Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
FROM ubuntu:22.04
2+
3+
ENV TARGETNAME linux.riscv64
4+
ENV TARGET riscv64-linux-gnu
5+
6+
USER root
7+
ENV DEBIAN_FRONTEND noninteractive
8+
9+
# Init base
10+
RUN apt update -y
11+
12+
# Install qemu
13+
RUN apt install -y --no-install-recommends build-essential ninja-build python3 pkg-config libglib2.0-dev libpixman-1-dev curl ca-certificates python3-virtualenv
14+
WORKDIR /qemu
15+
RUN curl -Lv "https://download.qemu.org/qemu-9.0.0.tar.xz" | tar xJ --strip-components=1
16+
RUN ./configure --target-list=riscv64-linux-user --static --disable-system --disable-pie
17+
RUN cd build && ninja qemu-riscv64
18+
ENV QEMU_EXECVE 1
19+
20+
21+
# Set up a riscv64 userspace
22+
RUN apt install -y --no-install-recommends debootstrap
23+
RUN debootstrap --arch=riscv64 --foreign jammy /rvfs http://ports.ubuntu.com/ubuntu-ports
24+
RUN cp /qemu/build/qemu-riscv64 /rvfs/usr/bin/qemu-riscv64-static
25+
26+
RUN printf > /bin/rv '%s\n' '#!/bin/sh' 'chroot /rvfs /usr/bin/qemu-riscv64-static /usr/bin/env "$@"'
27+
RUN chmod +x /bin/rv
28+
RUN [ ! -e /rvfs/debootstrap ] || rv '/debootstrap/debootstrap' --second-stage
29+
30+
# Install deps in the chroot
31+
RUN printf > /rvfs/etc/apt/sources.list '%s\n' 'deb http://ports.ubuntu.com/ubuntu-ports jammy main universe'
32+
RUN rv apt update -y
33+
RUN rv apt install -y --no-install-recommends ghc cabal-install
34+
35+
# Finally we can build the current dependencies. This takes hours.
36+
# jobs must be 1, GHS riscv will use about 40G memory
37+
RUN rv cabal update
38+
RUN IFS=";" && rv cabal install --dependencies-only --jobs=1 ShellCheck
39+
RUN IFS=';' && rv cabal install --lib --jobs=1 fgl
40+
41+
# Clean up
42+
RUN rm -rf /qemu
43+
44+
# Copy the build script
45+
WORKDIR /rvfs/scratch
46+
COPY build /rvfs/usr/bin/build
47+
ENTRYPOINT ["/bin/rv", "/usr/bin/build"]

build/linux.riscv64/build

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
set -xe
3+
{
4+
tar xzv --strip-components=1
5+
chmod +x striptests && ./striptests
6+
mkdir "$TARGETNAME"
7+
cabal update
8+
( IFS=';'; cabal build --enable-executable-static )
9+
find . -name shellcheck -type f -exec mv {} "$TARGETNAME/" \;
10+
ls -l "$TARGETNAME"
11+
"$TARGET-strip" -s "$TARGETNAME/shellcheck"
12+
ls -l "$TARGETNAME"
13+
qemu-riscv64-static "$TARGETNAME/shellcheck" --version
14+
} >&2
15+
tar czv "$TARGETNAME"

build/linux.riscv64/tag

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
koalaman/scbuilder-linux-riscv64

0 commit comments

Comments
 (0)