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 00000000..77d39ac6 Binary files /dev/null and b/go/riscv64/rootfs/helloWorld differ 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; +}