Skip to content
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

[CI] Add RISCV in test and build #3706

Merged
merged 52 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a42cd96
[CI] Add RISCV in test and build
ptitSeb Mar 24, 2023
a1db1ec
Fixed a typo
ptitSeb Mar 24, 2023
1306a94
update Cargo lock to fix cargo deny step
ptitSeb Mar 24, 2023
8a1fa49
Some updates to avoid riscv incompatibilities
ptitSeb Mar 24, 2023
05b2d2f
[CI] Added libssl-dev to RISCV Doker image
ptitSeb Mar 24, 2023
57a7513
[CI] It's libssl-dev:riscv64 that is needed for RISCV Doker image
ptitSeb Mar 24, 2023
10afcb2
[CI] More work to get riscv to be cross compiled
ptitSeb Mar 24, 2023
daf963d
[CI] Added debian-port sid or riscv Docker image
ptitSeb Mar 24, 2023
7b4250f
[CI] Added archive_2023 key for debian port
ptitSeb Mar 24, 2023
9bd113a
[CI] Try to used vendored openssl for riscv
ptitSeb Mar 24, 2023
0222f09
[CI] Try to cross-build a localy OpenSSL for riscv
ptitSeb Mar 24, 2023
835c081
Merge branch 'master' into ci_riscv64
ptitSeb Mar 24, 2023
b916166
[CI] gcc-riscv64-linux-gnu is not installed it seems, only g++ is
ptitSeb Mar 24, 2023
5b8dedc
Fixed linter
ptitSeb Mar 24, 2023
863d33b
[CI] Fined tune OpenSSL installation on RISCV Docker image
ptitSeb Mar 24, 2023
50d0cab
Fixed linter
ptitSeb Mar 24, 2023
bc37e32
[CI] Try to force RISCV64GC_UNKNOWN_LINUX_GNU_OPENSSL_DIR env. var.
ptitSeb Mar 24, 2023
af592e3
[CI] Use the cross-rs docker image instead of creating one from scratch
ptitSeb Mar 24, 2023
3b19bcf
[CI] Use the katest cross-rs docker image for RISCV
ptitSeb Mar 24, 2023
5f31ade
[CI] more attempt to get opensll for RISCV
ptitSeb Mar 24, 2023
1478eb4
[CI] nother attempt to get opensll for RISCV
ptitSeb Mar 24, 2023
3b8fd5c
[CI] New Docker image for riscv64 cross build
ptitSeb Mar 27, 2023
a1b336e
[CI] Can you please find those openssl libs now
ptitSeb Mar 27, 2023
1e8dd09
[CI] Try not to use pkg-config maybe
ptitSeb Mar 27, 2023
f684e0c
[CI] one more try
ptitSeb Mar 27, 2023
b9cb23e
[CI] more openssl try
ptitSeb Mar 27, 2023
cce1963
[CI] again, more openssl try
ptitSeb Mar 27, 2023
57309ee
[CI] again, one more openssl try
ptitSeb Mar 27, 2023
5788909
[CI] again and again, one more openssl try
ptitSeb Mar 27, 2023
156b017
[CI] a newer openssl try
ptitSeb Mar 27, 2023
f30d4c4
[CI] and another openssl try
ptitSeb Mar 27, 2023
56c9087
[CI] yet another openssl try
ptitSeb Mar 27, 2023
54dcaa9
[CI] adding riscv64gc manualy, not using cross
ptitSeb Mar 27, 2023
a28caf7
[CI] again,adding riscv64gc manualy, not using cross
ptitSeb Mar 27, 2023
b7e71e3
[CI] don't mess with llvm-14 for now
ptitSeb Mar 27, 2023
d43393a
[CI] and another try
ptitSeb Mar 27, 2023
05ec30b
[CI] New try, it works localy, so there is hope
ptitSeb Mar 28, 2023
8b83e1a
Merge branch 'master' into ci_riscv64
ptitSeb Mar 28, 2023
d484f34
Fixed build after merge
ptitSeb Mar 28, 2023
4b9aa42
Another build fix
ptitSeb Mar 28, 2023
6a4bbf8
[CI] Removed unused file
ptitSeb Mar 28, 2023
bac23f6
Merge branch 'master' into ci_riscv64
ptitSeb Mar 29, 2023
f324765
Merge branch 'master' into ci_riscv64
ptitSeb Mar 29, 2023
b86d182
Use the correct webc version for cli
ptitSeb Mar 29, 2023
c8d8bb7
Merge branch 'master' into ci_riscv64
ptitSeb Mar 29, 2023
59fb6e3
Merge branch 'master' into ci_riscv64
ptitSeb Mar 30, 2023
2e1413d
Merge branch 'master' into ci_riscv64
ptitSeb Mar 30, 2023
a87747c
Merge branch 'master' into ci_riscv64
ptitSeb Apr 5, 2023
1cb0300
Fix build after merge
ptitSeb Apr 5, 2023
b198d91
Merge branch 'master' into ci_riscv64
ptitSeb Apr 6, 2023
59c0933
Use webc 5.0.0.0-rc.7
ptitSeb Apr 6, 2023
d16c2ca
Merge branch 'master' into ci_riscv64
ptitSeb Apr 14, 2023
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
61 changes: 61 additions & 0 deletions .github/cross-linux-riscv64/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
FROM debian:sid AS openssl_riscv64
#FROM ghcr.io/cross-rs/aarch64-unknown-linux-gnu:edge

# set CROSS_DOCKER_IN_DOCKER to inform `cross` that it is executed from within a container
ENV CROSS_DOCKER_IN_DOCKER=true

RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends \
ca-certificates \
curl \
cpio \
sharutils \
gnupg \
build-essential \
libc6-dev

COPY install_deb.sh /

#install libssl-dev for riscv64!
RUN /install_deb.sh riscv64 libssl-dev
ENV RISCV64GC_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include
ENV RISCV64GC_UNKNOWN_LINUX_GNU_OPENSSL_LIB_DIR=/usr/lib/riscv64-linux-gnu


# install rust tools
RUN curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup -v toolchain install 1.65
# add docker the manual way
COPY install_docker.sh /
RUN /install_docker.sh

RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin

RUN apt-get update && apt-get install -y --no-install-recommends \
gcc-riscv64-linux-gnu \
g++-riscv64-linux-gnu \
qemu-user-static \
libssl-dev \
pkg-config \
libc6-dev-riscv64-cross

ENV CROSS_TOOLCHAIN_PREFIX=riscv64-linux-gnu-
ENV CROSS_SYSROOT=/usr/riscv64-linux-gnu
ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER="$CROSS_TOOLCHAIN_PREFIX"gcc \
AR_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"ar \
CC_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"gcc \
CXX_riscv64gc_unknown_linux_gnu="$CROSS_TOOLCHAIN_PREFIX"g++ \
CFLAGS_riscv64gc_unknown_linux_gnu="-march=rv64gc -mabi=lp64d" \
BINDGEN_EXTRA_CLANG_ARGS_riscv64gc_unknown_linux_gnu="--sysroot=$CROSS_SYSROOT" \
QEMU_LD_PREFIX="$CROSS_SYSROOT" \
RUST_TEST_THREADS=1 \
PKG_CONFIG_PATH="/usr/lib/riscv64-linux-gnu/pkgconfig/:${PKG_CONFIG_PATH}"

RUN rustup target add riscv64gc-unknown-linux-gnu --toolchain 1.65-x86_64-unknown-linux-gnu
56 changes: 56 additions & 0 deletions .github/cross-linux-riscv64/install_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
set -x
set -euo pipefail

arch="${1}"
shift

# need to install certain local dependencies
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --assume-yes --no-install-recommends \
ca-certificates \
curl \
cpio \
sharutils \
gnupg

# Add port from sid to get some riscv packages
debsource="deb http://deb.debian.org/debian-ports sid main"

# temporarily use debian sources rather than ubuntu.
touch /etc/apt/sources.list
mv /etc/apt/sources.list /etc/apt/sources.list.bak
echo -e "${debsource}" > /etc/apt/sources.list

dpkg --add-architecture "${arch}" || echo "foreign-architecture ${arch}" \
> /etc/dpkg/dpkg.cfg.d/multiarch

# Add Debian keys.
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{7.0,8,9,10}.asc' -O
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/archive-key-{8,9,10}-security.asc' -O
curl --retry 3 -sSfL 'https://ftp-master.debian.org/keys/release-{7,8,9,10}.asc' -O
curl --retry 3 -sSfL 'https://www.ports.debian.org/archive_{2020,2021,2022,2023}.key' -O

for key in *.asc *.key; do
apt-key add "${key}"
rm "${key}"
done

# allow apt-get to retry downloads
echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries

apt-get update
for dep in $@; do
apt-get install "${dep}:${arch}" --assume-yes
done

# restore our old sources list
mv -f /etc/apt/sources.list.bak /etc/apt/sources.list
if [ -f /etc/dpkg/dpkg.cfg.d/multiarch.bak ]; then
mv /etc/dpkg/dpkg.cfg.d/multiarch.bak /etc/dpkg/dpkg.cfg.d/multiarch
fi

# can fail if arch is used (amd64 and/or i386)
dpkg --remove-architecture "${arch}" || true
apt-get update
11 changes: 11 additions & 0 deletions .github/cross-linux-riscv64/install_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -x
set -euo pipefail

mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
76 changes: 75 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,73 @@ jobs:
if-no-files-found: error
retention-days: 2

linux_riscv64:
name: Linux riscv64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
target: riscv64gc-unknown-linux-gnu
- name: Build cross image
run: |
docker build -t wasmer/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/
env:
CROSS_DOCKER_IN_DOCKER: true
- name: Build Wasmer binary
run: |
make build-wasmer
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64:latest cargo
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
ENABLE_LLVM: 0
- name: Build C API headless
shell: bash
run: |
make package-capi-headless
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64:latest cargo
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
ENABLE_LLVM: 0
TARGET: riscv64gc-unknown-linux-gnu
TARGET_DIR: target/riscv64gc-unknown-linux-gnu/release
- name: Build C API
run: |
make build-capi
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64:latest cargo
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
ENABLE_LLVM: 0
- name: Dist
run: |
make distribution
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64:latest cargo
theduke marked this conversation as resolved.
Show resolved Hide resolved
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
TARGET: riscv64gc-unknown-linux-gnu
TARGET_DIR: target/riscv64gc-unknown-linux-gnu/release
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: wasmer-linux-riscv64
path: dist
if-no-files-found: error
retention-days: 2

release:
needs: [setup, build, linux_aarch64, windows_gnu]
needs: [setup, build, linux_aarch64, windows_gnu, linux_riscv64]
runs-on: ubuntu-latest
if: needs.setup.outputs.DOING_RELEASE == '1' || github.event.inputs.release != ''
steps:
Expand Down Expand Up @@ -456,6 +521,15 @@ jobs:
asset_path: artifacts/wasmer-linux-aarch64/wasmer.tar.gz
asset_name: wasmer-linux-aarch64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Linux riscv64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: artifacts/wasmer-linux-riscv64/wasmer.tar.gz
asset_name: wasmer-linux-riscv64.tar.gz
asset_content_type: application/gzip
- name: Upload Release Asset Windows gnu64
uses: actions/upload-release-asset@v1
env:
Expand Down
67 changes: 65 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.61
toolchain: 1.65
target: aarch64-unknown-linux-gnu
- name: Build cross image
run: |
Expand Down Expand Up @@ -188,6 +188,64 @@ jobs:
if-no-files-found: error
retention-days: 2

build_linux_riscv64:
name: ${{ matrix.build-what.name }} on linux-riscv64
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
build-what: [
{
key: capi,
build-cmd: 'make build-capi && make package-capi',
name: 'Build C-API'
},
{
key: wasmer,
build-cmd: 'make build-wasmer && make package-wasmer && make tar-wasmer',
name: 'Build wasmer-cli'
}
]
steps:
- uses: actions/checkout@v3
#- uses: dtolnay/rust-toolchain@stable
# with:
# toolchain: 1.65
# target: riscv64gc-unknown-linux-gnu
- name: Build cross image
run: |
docker build -t wasmer/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/
env:
CROSS_DOCKER_IN_DOCKER: true
- name: Build ${{ matrix.build-what.key }}
run: |
${{ matrix.build-what.build-cmd }}
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64 cargo
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
ENABLE_LLVM: 0
- name: Dist
if: ${{ matrix.build-what.key == 'capi' }}
run: |
make distribution
env:
CARGO_BINARY: docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project wasmer/riscv64 cargo
CROSS_DOCKER_IN_DOCKER: true
CARGO_TARGET: riscv64gc-unknown-linux-gnu
PKG_CONFIG_PATH: /usr/lib/riscv64-linux-gnu/pkgconfig
PKG_CONFIG_ALLOW_CROSS: true
TARGET: riscv64gc-unknown-linux-gnu
TARGET_DIR: target/riscv64gc-unknown-linux-gnu/release
- name: Upload Artifacts
if: ${{ matrix.build-what.key == 'capi' }}
uses: actions/upload-artifact@v3
with:
name: capi-linux-riscv64
path: dist
if-no-files-found: error
retention-days: 2

build:
name: ${{ matrix.build-what.name }} on ${{ matrix.metadata.build }}
runs-on: ${{ matrix.metadata.os }}
Expand Down Expand Up @@ -544,7 +602,7 @@ jobs:
test_integration_cli:
name: CLI integration tests on ${{ matrix.build }}
runs-on: ${{ matrix.os }}
needs: [build, build_linux_aarch64]
needs: [build, build_linux_aarch64, build_linux_riscv64]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -634,6 +692,10 @@ jobs:
with:
name: capi-linux-x64
path: package/cache/wasmercache5
- uses: actions/download-artifact@v3
with:
name: capi-linux-riscv64
path: package/cache/wasmercache6
- name: Copy .tar.gz files to proper location
shell: bash
run: |
Expand All @@ -647,6 +709,7 @@ jobs:
cp package/cache/wasmercache3/build-capi.tar.gz package/cache/wasmer-darwin-arm64.tar.gz
cp package/cache/wasmercache4/build-capi.tar.gz package/cache/wasmer-darwin-amd64.tar.gz
cp package/cache/wasmercache5/build-capi.tar.gz package/cache/wasmer-linux-amd64.tar.gz
cp package/cache/wasmercache6/wasmer.tar.gz package/cache/wasmer-linux-riscv64.tar.gz
- uses: actions/download-artifact@v3
if: ${{ matrix.build == 'windows-x64' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ else
# We use spaces instead of tabs to indent `$(error)`
# otherwise it's considered as a command outside a
# target and it will fail.
$(error Unrecognized architecture, expect `x86_64`, `aarch64` or `arm64`)
$(error Unrecognized architecture, expect `x86_64`, `aarch64`, `arm64`, 'riscv64')
endif

# Libc
Expand Down
4 changes: 4 additions & 0 deletions lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ bin-dir = "bin/{ bin }"
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-aarch64.{ archive-format }"
bin-dir = "bin/{ bin }"

[package.metadata.binstall.overrides.riscv64gc-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-riscv64gc.{ archive-format }"
bin-dir = "bin/{ bin }"

[package.metadata.binstall.overrides.x86_64-unknown-linux-gnu]
pkg-url = "{ repo }/releases/download/v{ version }/wasmer-linux-amd64.{ archive-format }"
bin-dir = "bin/{ bin }"
Expand Down