Merge pull request #91 from infosiftr/riscv64

Add riscv64
This commit is contained in:
Tianon Gravi 2021-07-08 15:49:32 +00:00 committed by GitHub
commit fc03878295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 16 deletions

View File

@ -18,6 +18,7 @@ RUN set -eux; \
libc6-dev-i386-cross \
libc6-dev-mips64el-cross \
libc6-dev-ppc64el-cross \
libc6-dev-riscv64-cross \
libc6-dev-s390x-cross \
\
gcc-aarch64-linux-gnu \
@ -26,8 +27,10 @@ RUN set -eux; \
gcc-i686-linux-gnu \
gcc-mips64el-linux-gnuabi64 \
gcc-powerpc64le-linux-gnu \
gcc-riscv64-linux-gnu \
gcc-s390x-linux-gnu \
\
arch-test \
file \
; \
rm -rf /var/lib/apt/lists/*
@ -54,43 +57,57 @@ COPY . .
RUN set -ex; \
make clean all test \
TARGET_ARCH='amd64' \
CROSS_COMPILE='x86_64-linux-gnu-'
CROSS_COMPILE='x86_64-linux-gnu-' \
ARCH_TEST='amd64'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='arm32v5' \
CROSS_COMPILE='arm-linux-gnueabi-'
CROSS_COMPILE='arm-linux-gnueabi-' \
ARCH_TEST='armel'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='arm32v7' \
CROSS_COMPILE='arm-linux-gnueabihf-'
CROSS_COMPILE='arm-linux-gnueabihf-' \
ARCH_TEST='armhf'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='arm64v8' \
CROSS_COMPILE='aarch64-linux-gnu-'
CROSS_COMPILE='aarch64-linux-gnu-' \
ARCH_TEST='arm64'
RUN set -ex; \
make clean all test \
TARGET_ARCH='i386' \
CROSS_COMPILE='i686-linux-gnu-'
CROSS_COMPILE='i686-linux-gnu-' \
ARCH_TEST='i386'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='mips64le' \
CROSS_COMPILE='mips64el-linux-gnuabi64-'
CROSS_COMPILE='mips64el-linux-gnuabi64-' \
ARCH_TEST='mips64el'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='ppc64le' \
CROSS_COMPILE='powerpc64le-linux-gnu-' \
CFLAGS+='-mlong-double-64'
CFLAGS+='-mlong-double-64' \
ARCH_TEST='ppc64el'
RUN set -ex; \
make clean all \
make clean all test \
TARGET_ARCH='riscv64' \
CROSS_COMPILE='riscv64-linux-gnu-' \
ARCH_TEST='riscv64'
RUN set -ex; \
make clean all test \
TARGET_ARCH='s390x' \
CROSS_COMPILE='s390x-linux-gnu-'
CROSS_COMPILE='s390x-linux-gnu-' \
ARCH_TEST='s390x'
RUN find \( -name 'hello' -or -name 'hello.txt' \) -exec file '{}' + -exec ls -lh '{}' +

View File

@ -1,6 +1,7 @@
SHELL := bash -Eeuo pipefail
TARGET_ARCH := amd64
export ARCH_TEST :=
C_TARGETS := $(addsuffix hello, $(wildcard $(TARGET_ARCH)/*/))
export CFLAGS := -Os -fdata-sections -ffunction-sections -s
@ -48,6 +49,10 @@ clean:
.PHONY: test
test: $(C_TARGETS)
@for b in $^; do \
( set -x && "./$$b" ); \
( set -x && "./$$b" | grep -q '"'"$$(basename "$$(dirname "$$b")")"'"' ); \
if [ -n "$$ARCH_TEST" ] && command -v arch-test > /dev/null && arch-test "$$ARCH_TEST" > /dev/null; then \
( set -x && "./$$b" ); \
( set -x && "./$$b" | grep -q '"'"$$(basename "$$(dirname "$$b")")"'"' ); \
else \
echo >&2 "warning: $$TARGET_ARCH ($$ARCH_TEST) not supported; skipping test"; \
fi; \
done

View File

@ -0,0 +1,3 @@
FROM scratch
COPY hello /
CMD ["/hello"]

BIN
riscv64/hello-world/hello Executable file

Binary file not shown.