From b4657c80a44ba5bb9965a28fbad027a9fe5e44dd Mon Sep 17 00:00:00 2001 From: bits Date: Thu, 5 Sep 2024 11:19:04 +0800 Subject: [PATCH] Add linux/riscv64 arch support --- .github/release-drafter.yml | 2 + README.md | 3 ++ go/Makefile.debian11 | 2 +- go/Makefile.debian12 | 2 +- go/riscv64/.dockerignore | 1 + go/riscv64/Dockerfile.tmpl | 76 +++++++++++++++++++++++++++++++ go/riscv64/Makefile | 1 + go/riscv64/rootfs/compilers.yaml | 6 +++ go/riscv64/rootfs/helloWorld | Bin 0 -> 8496 bytes go/riscv64/rootfs/helloWorld.c | 5 ++ 10 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 go/riscv64/.dockerignore create mode 100644 go/riscv64/Dockerfile.tmpl create mode 100644 go/riscv64/Makefile create mode 100644 go/riscv64/rootfs/compilers.yaml create mode 100644 go/riscv64/rootfs/helloWorld create mode 100644 go/riscv64/rootfs/helloWorld.c diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 9361f77e..742066af 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -62,6 +62,8 @@ template: | - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-ppc-debian12` - linux/ppc64, linux/ppc64le - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x-debian11` - linux/s390x - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-s390x-debian12` - linux/s390x + - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-riscv64-debian11` - linux/riscv64 + - `docker.elastic.co/beats-dev/golang-crossbuild:$RESOLVED_VERSION-riscv64-debian12` - linux/riscv64 ### Changes diff --git a/README.md b/README.md index ce7522b5..a8a2d46f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ To do that the project provides a set of Docker images that can be used to build * linux/ppc64 * linux/ppc64le * linux/s390x +* linux/riscv64 * windows/amd64 * darwin/amd64 * darwin/arm64 @@ -71,6 +72,8 @@ Replace `` with the version you would like to use, for instance: - `docker.elastic.co/beats-dev/golang-crossbuild:-ppc-debian12` - linux/ppc64, linux/ppc64le - `docker.elastic.co/beats-dev/golang-crossbuild:-s390x-debian11` - linux/s390x - `docker.elastic.co/beats-dev/golang-crossbuild:-s390x-debian12` - linux/s390x +- `docker.elastic.co/beats-dev/golang-crossbuild:-riscv64-debian11` - linux/riscv64 +- `docker.elastic.co/beats-dev/golang-crossbuild:-riscv64-debian12` - linux/riscv64 ### glibc diff --git a/go/Makefile.debian11 b/go/Makefile.debian11 index 4270c11a..73c98190 100644 --- a/go/Makefile.debian11 +++ b/go/Makefile.debian11 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips ppc s390x darwin-arm64 npcap +IMAGES := base main darwin arm armhf armel mips ppc s390x darwin-arm64 npcap riscv64 DEBIAN_VERSION := 11 TAG_EXTENSION := -debian11 diff --git a/go/Makefile.debian12 b/go/Makefile.debian12 index af003d66..cd530dbc 100644 --- a/go/Makefile.debian12 +++ b/go/Makefile.debian12 @@ -1,4 +1,4 @@ -IMAGES := base main darwin arm armhf armel mips ppc s390x darwin-arm64 npcap +IMAGES := base main darwin arm armhf armel mips ppc s390x darwin-arm64 npcap riscv64 DEBIAN_VERSION := 12 TAG_EXTENSION := -debian12 diff --git a/go/riscv64/.dockerignore b/go/riscv64/.dockerignore new file mode 100644 index 00000000..f3c7a7c5 --- /dev/null +++ b/go/riscv64/.dockerignore @@ -0,0 +1 @@ +Makefile diff --git a/go/riscv64/Dockerfile.tmpl b/go/riscv64/Dockerfile.tmpl new file mode 100644 index 00000000..ae603d3e --- /dev/null +++ b/go/riscv64/Dockerfile.tmpl @@ -0,0 +1,76 @@ +ARG REPOSITORY +ARG VERSION +ARG TAG_EXTENSION='' +FROM ${REPOSITORY}/golang-crossbuild:${VERSION}-base${TAG_EXTENSION} + +RUN dpkg --add-architecture riscv64 \ + && apt update -y --no-install-recommends \ + && apt upgrade -y --no-install-recommends \ + && apt full-upgrade -y --no-install-recommends \ + && apt install -qq -y --no-install-recommends \ + g++-riscv64-linux-gnu \ + gcc-riscv64-linux-gnu + +RUN apt install -qq -y \ + libc-dev:riscv64 \ + libpopt-dev:riscv64 \ + linux-libc-dev:riscv64 + +{{- if eq .DEBIAN_VERSION "9" }} +RUN apt install -qq -y \ + libelf1:riscv64 \ + libicu-dev:riscv64 \ + libicu57:riscv64 \ + librpm-dev:riscv64 \ + libxml2-dev:riscv64 \ + libxml2:riscv64 \ + librpm3:riscv64 \ + librpmio3:riscv64 \ + librpmbuild3:riscv64 \ + librpmsign3:riscv64 \ + libsqlite3-dev:riscv64 \ + libnss3:riscv64 \ + libsqlite3-0:riscv64 + +# RUN apt install -y \ +# libsystemd-dev:riscv64 libsystemd0:riscv64 liblz4-1:riscv64 +{{- end }} + +{{- if or (eq .DEBIAN_VERSION "10") (eq .DEBIAN_VERSION "11") (eq .DEBIAN_VERSION "12")}} +# librpm-dev +RUN apt install -y \ + librpm-dev:riscv64 + +# libsystemd-dev +RUN apt install -y \ + libsystemd-dev:riscv64 +{{- end }} + +RUN rm -rf /var/lib/apt/lists/* + +COPY rootfs / + +# Basic test +RUN cd / \ + && riscv64-linux-gnu-gcc helloWorld.c -o helloWorld \ + && file helloWorld \ + && readelf -h helloWorld \ + && readelf -h helloWorld | grep -c 'RISC-V' \ + && readelf -h helloWorld | grep -c 'ELF64' \ + && readelf -h helloWorld | grep -c "little endian" \ + && rm helloWorld.c helloWorld + +RUN cd /libpcap/libpcap-1.8.1 \ + && CC=riscv64-linux-gnu-gcc ./configure --enable-usb=no --enable-bluetooth=no --enable-dbus=no --host=riscv64-unknown-linux-gnu --with-pcap=linux \ + && make + +# Build-time metadata as defined at http://label-schema.org. +ARG BUILD_DATE +ARG IMAGE +ARG VCS_REF +ARG VCS_URL +LABEL org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.name=$IMAGE \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.schema-version="1.0" diff --git a/go/riscv64/Makefile b/go/riscv64/Makefile new file mode 100644 index 00000000..0a42375f --- /dev/null +++ b/go/riscv64/Makefile @@ -0,0 +1 @@ +include ../Makefile.common diff --git a/go/riscv64/rootfs/compilers.yaml b/go/riscv64/rootfs/compilers.yaml new file mode 100644 index 00000000..24498edb --- /dev/null +++ b/go/riscv64/rootfs/compilers.yaml @@ -0,0 +1,6 @@ +--- + +linux: + riscv64: + CC: riscv64-linux-gnu-gcc + CXX: riscv64-linux-gnu-g++ diff --git a/go/riscv64/rootfs/helloWorld b/go/riscv64/rootfs/helloWorld new file mode 100644 index 0000000000000000000000000000000000000000..77d39ac66a83310fbc50978307cd4ce9a9811992 GIT binary patch literal 8496 zcmeHMZ)_Y#6`#Ac6DLh#Cr%q6rCk0rZKY)6IB7s2MZUA0vxVaX+kt{ar|Y}5ef0jZ zw^uo#D2Y=m=?AJtDMW2a8>K~+Dj`KE68_X0MFsZ@R8=J+Ay5!OfP`cR3M!(Bd2jdq z)_d!7i$uR5c}{n4-tWCP^XARW?##Or-F*k+v6ws4uA1 z^n0(`tX2@;;9yZaxk~1V{rh(1%lr3b%}UAK!@aX_8|lkyB;9{h{c`sUovXjo{Ps6iJfHsYqeCAS z-m_m~9rlIWWgRYzHG4IsxO<*b%%2B0sDwjJwzzh$(eIMAdd~TSFo!dA6ExFOWIemFLdK)+t^iKEE#DXH_Ep`k77llh(uc zzcOLBsn&1D=1(1rrB|Pwozox2pS`d}sq?3PzjfjyS(9FCN~eh^o}OmabFrvkj>=O={q0 zshKtLmK1NY<+2=s|&B8-2 z*FA;v7VZs@|KrYliA}D{p@&}UUYVA|RB%QTeznL?2)#=vzo)s}?UUdaXR@i#xr>Eu zqQUnAE;!F`@>$g(jsQO?hcEa&Cwi-dqW}AZhu**E{qa#;J&2AH-gu8ldvuKOc*K29 z_zsc(OL)XZn*YQI_3srlSeA}JanFSO<7m3G^NWcGj}BLhZZ)xIui0+4?P}j!_4s`c z38In%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dUFs5h4|27Fc q=bv`d7vsnNUqu+kPSv1H$;KIpG#>4LJz3PVzfTfk%@KnLtNsHkB;~;X literal 0 HcmV?d00001 diff --git a/go/riscv64/rootfs/helloWorld.c b/go/riscv64/rootfs/helloWorld.c new file mode 100644 index 00000000..dcfb86bc --- /dev/null +++ b/go/riscv64/rootfs/helloWorld.c @@ -0,0 +1,5 @@ +#include +int main() { + printf("Hello, World!"); + return 0; +}