Skip to content

Add linux/riscv64 arch support #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,6 +72,8 @@ Replace `<GOLANG_VERSION>` with the version you would like to use, for instance:
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-ppc-debian12` - linux/ppc64, linux/ppc64le
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian11` - linux/s390x
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-s390x-debian12` - linux/s390x
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-riscv64-debian11` - linux/riscv64
- `docker.elastic.co/beats-dev/golang-crossbuild:<GOLANG_VERSION>-riscv64-debian12` - linux/riscv64

### glibc

Expand Down
2 changes: 1 addition & 1 deletion go/Makefile.debian11
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion go/Makefile.debian12
Original file line number Diff line number Diff line change
@@ -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

Expand Down
1 change: 1 addition & 0 deletions go/riscv64/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Makefile
76 changes: 76 additions & 0 deletions go/riscv64/Dockerfile.tmpl
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions go/riscv64/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ../Makefile.common
6 changes: 6 additions & 0 deletions go/riscv64/rootfs/compilers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

linux:
riscv64:
CC: riscv64-linux-gnu-gcc
CXX: riscv64-linux-gnu-g++
Binary file added go/riscv64/rootfs/helloWorld
Binary file not shown.
5 changes: 5 additions & 0 deletions go/riscv64/rootfs/helloWorld.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}