diff --git a/.github/workflows/almalinux-build-toolchain.yml b/.github/workflows/almalinux-build-toolchain.yml new file mode 100644 index 0000000..399f569 --- /dev/null +++ b/.github/workflows/almalinux-build-toolchain.yml @@ -0,0 +1,144 @@ +name: Container Build (Toolchain) +on: + push: + paths: + - 'containers/labs344-almalinux/**' + - '.github/workflows/almalinux-build-toolchain.yml' + workflow_dispatch: + inputs: + publish: + description: "Publish to the registry" + required: true + default: false + type: boolean + +env: + REGISTRY: ghcr.io/bouncmpe + IMAGE_NAME: labs344-almalinux + LABS344_VERSION: latest + CONTAINERS_ROOT: /home/runner/.local/share/containers + TMPDIR: /home/runner/.local/share/containers/tmp + HOSTARCH: amd64 + PLATFORM: linux-amd64 + +permissions: + contents: read + packages: write + +jobs: + buildah-build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04, ubuntu-24.04-arm] + runs-on: ${{ matrix.os }} + concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.os }} + cancel-in-progress: true + + steps: + - name: Install container tools + run: sudo apt-get install podman buildah jq + + - name: Maximize build space + uses: easimon/maximize-build-space@v10 + with: + root-reserve-mb: 2048 # Reserve disk space for repository + remove-dotnet: "true" + remove-android: "true" + remove-haskell: "true" + remove-codeql: "true" + remove-docker-images: "true" + build-mount-path: ${{ env.CONTAINERS_ROOT }} # The remaining space only for container build + + - run: mkdir -p $TMPDIR + + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Prepare environment variables + run: | + echo "HOSTARCH=$(podman info --format='{{.Host.Arch}}')" >> $GITHUB_ENV + echo "PLATFORM=$(podman info --format='{{.Version.OsArch}}' | sed 's/\//-/g')" >> $GITHUB_ENV + echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - name: Log in to the GitHub Container registry + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build toolchain container image + id: build-toolchain + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.IMAGE_NAME }} + tags: | + ${{ env.LABS344_VERSION }}-toolchain + ${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }} + layers: true + oci: true + build-args: | + LABS344_VERSION=${{ env.LABS344_VERSION }} + extra-args: | + --target labs344-toolchain + containerfiles: | + containers/labs344-almalinux/Dockerfile + context: containers + + - name: Push to GitHub Container Repository + if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish + id: push-toolchain-ghcr + uses: redhat-actions/push-to-registry@v2 + with: + registry: ${{ env.REGISTRY }} + image: ${{ steps.build-toolchain.outputs.image }} + tags: ${{ env.LABS344_VERSION }}-toolchain-${{ env.HOSTARCH }} + digestfile: ${{ runner.temp }}/digest-labs344-toolchain-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} + + - name: Upload digests + if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' && github.event.inputs.publish + uses: actions/upload-artifact@v4 + with: + name: digest-bouncmpe-${{ env.LABS344_VERSION }}-${{ env.PLATFORM }} + path: ${{ runner.temp }}/digest-* + if-no-files-found: error + retention-days: 1 + compression-level: 0 # no compression + + buildah-merge: + name: Merge container images + runs-on: ubuntu-24.04 + needs: buildah-build + if: always() && github.event_name == 'workflow_dispatch' && github.event.inputs.publish + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: ${{ runner.temp }}/digests + pattern: digest-* + merge-multiple: true + + - name: Prepare environment variables + run: | + echo "LABS344_VERSION=$(date +'%Y%m%d')" >> $GITHUB_ENV + + - name: Log in to the GitHub Container registry + uses: redhat-actions/podman-login@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push manifest list for labs344-toolchain + run: | + MANIFEST=labs344-toolchain + FULL_IMAGE_NAME=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + buildah manifest create $MANIFEST + for digest in ${{ runner.temp }}/digests/digest-labs344-toolchain-*; do + echo "Adding $(cat $digest)" + buildah manifest add $MANIFEST $FULL_IMAGE_NAME@$(cat $digest) + done + buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:${{ env.LABS344_VERSION }}-toolchain + buildah manifest push --all $MANIFEST docker://$FULL_IMAGE_NAME:latest-toolchain diff --git a/.github/workflows/buildah-build-toolchain.yml b/.github/workflows/buildah-build-toolchain.yml index f2acd07..716c36b 100644 --- a/.github/workflows/buildah-build-toolchain.yml +++ b/.github/workflows/buildah-build-toolchain.yml @@ -5,7 +5,7 @@ on: publish: description: "Publish to the registry" required: true - default: true + default: false type: boolean env: @@ -14,6 +14,8 @@ env: LABS344_VERSION: latest CONTAINERS_ROOT: /home/runner/.local/share/containers TMPDIR: /home/runner/.local/share/containers/tmp + HOSTARCH: amd64 + PLATFORM: linux-amd64 permissions: contents: read diff --git a/.github/workflows/buildah-build-tools.yml b/.github/workflows/buildah-build-tools.yml index 67a8a68..7a4143d 100644 --- a/.github/workflows/buildah-build-tools.yml +++ b/.github/workflows/buildah-build-tools.yml @@ -5,7 +5,7 @@ on: publish: description: "Publish to the registry" required: true - default: true + default: false type: boolean env: @@ -14,6 +14,8 @@ env: LABS344_VERSION: latest CONTAINERS_ROOT: /home/runner/.local/share/containers TMPDIR: /home/runner/.local/share/containers/tmp + HOSTARCH: amd64 + PLATFORM: linux-amd64 permissions: contents: read diff --git a/containers/labs344-almalinux/Dockerfile b/containers/labs344-almalinux/Dockerfile new file mode 100644 index 0000000..9d344da --- /dev/null +++ b/containers/labs344-almalinux/Dockerfile @@ -0,0 +1,78 @@ +ARG LABS344_RHEL_BASE_IMAGE=ghcr.io/almalinux/almalinux +ARG LABS344_RHEL_VERSION=9 + +ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1 + +FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344-builder +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT + +RUN dnf install -y git && \ + dnf install -y --allowerasing curl && \ + dnf clean all + +RUN git clone --recurse-submodules https://github.com/openhwgroup/cvw /tmp/cvw && \ + cd /tmp/cvw && \ + git checkout main && \ + export WALLY=$(pwd) && \ + export RISCV=/opt/riscv && \ + export PYTHON_VERSION=python3.12 && \ + bash -c ". $WALLY/bin/wally-environment-check.sh" && \ + bash -c ". $WALLY/bin/wally-package-install.sh" && \ + cd .. && rm -rf /tmp/cvw && \ + dnf clean all + +FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344-toolchain +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT + +RUN dnf install -y \ + git \ + dnf-plugins-core \ + dnf-plugin-config-manager \ + epel-release \ + && \ + dnf config-manager --enable crb && \ + dnf clean all + +RUN dnf install -y \ + autoconf \ + automake \ + python3.12 \ + libmpc-devel \ + mpfr-devel \ + gmp-devel \ + gawk \ + bison \ + flex \ + texinfo \ + patchutils \ + gcc-toolset-14-gcc \ + gcc-toolset-14-gcc-c++ \ + zlib-devel \ + expat-devel \ + libslirp-devel \ + make \ + cmake \ + ninja-build \ + && \ + dnf clean all + +ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION +ENV LABS344_RISCV_GNU_TOOLCHAIN_VERSION=${LABS344_RISCV_GNU_TOOLCHAIN_VERSION} +ENV LABS344_RISCV_DIR=/opt/riscv +ENV PATH=${LABS344_RISCV_DIR}/riscv-gnu-toolchain/bin:$PATH + +RUN . /opt/rh/gcc-toolset-14/enable && \ + git clone https://github.com/riscv/riscv-gnu-toolchain /tmp/riscv-gnu-toolchain && \ + cd /tmp/riscv-gnu-toolchain && \ + ./configure --prefix=${LABS344_RISCV_DIR} --enable-multilib --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" && \ + make -j$(nproc) && \ + make install && \ + rm -rf /tmp/riscv-gnu-toolchain + +FROM labs344-builder AS labs344-tools +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT + +FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344 +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT + +COPY --from=labs344-toolchain /opt/riscv /opt/riscv diff --git a/containers/labs344/Dockerfile b/containers/labs344/Dockerfile index cf31479..b943856 100644 --- a/containers/labs344/Dockerfile +++ b/containers/labs344/Dockerfile @@ -1,195 +1,41 @@ -ARG LABS344_VERSION=latest -ARG LABS344_DEBIAN_VERSION=12 -ARG LABS344_IMAGE_REGISTRY=localhost -ARG LABS344_IMAGE_REGISTRY_REMOTE=${LABS344_IMAGE_REGISTRY} -ARG LABS344_IMAGE_NAME=labs344 -ARG LABS344_IMAGE_NAME_FULL=${LABS344_IMAGE_REGISTRY}/${LABS344_IMAGE_NAME} -ARG LABS344_IMAGE_VERSION=${LABS344_VERSION} -ARG LABS344_BUILDER_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-builder -ARG LABS344_TOOLCHAIN_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-toolchain -ARG LABS344_TOOLS_IMAGE=${LABS344_IMAGE_NAME_FULL}:${LABS344_IMAGE_VERSION}-tools +ARG LABS344_RHEL_BASE_IMAGE=ghcr.io/almalinux/almalinux +ARG LABS344_RHEL_VERSION=9 -ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION=23863c2ca74e6c050f0c97e7af61f5f1776aadd1 - -FROM docker.io/library/debian:${LABS344_DEBIAN_VERSION} AS labs344-toolchain -ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ - export DEBIAN_FRONTEND=noninteractive && \ - apt-get update -qq && \ - apt-get install -qy --no-install-recommends \ - autoconf \ - automake \ - autotools-dev \ - curl \ - python3 \ - python3-pip \ - python3-tomli \ - libmpc-dev \ - libmpfr-dev \ - libgmp-dev \ - gawk \ - build-essential \ - bison \ - flex \ - texinfo \ - gperf \ - libtool \ - patchutils \ - bc \ - zlib1g-dev \ - libexpat-dev \ - ninja-build \ - git \ - cmake \ - libglib2.0-dev \ - libslirp-dev \ - && \ - apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -ARG LABS344_RISCV_GNU_TOOLCHAIN_VERSION -ENV LABS344_RISCV_GNU_TOOLCHAIN_VERSION=${LABS344_RISCV_GNU_TOOLCHAIN_VERSION} -ENV LABS344_RISCV_DIR=/opt/riscv -ENV PATH=${LABS344_RISCV_DIR}/riscv-gnu-toolchain/bin:$PATH - -RUN git clone https://github.com/riscv/riscv-gnu-toolchain /tmp/riscv-gnu-toolchain && \ - cd /tmp/riscv-gnu-toolchain && \ - ./configure --prefix=${LABS344_RISCV_DIR} --enable-multilib --with-multilib-generator="rv32e-ilp32e--;rv32i-ilp32--;rv32im-ilp32--;rv32iac-ilp32--;rv32imac-ilp32--;rv32imafc-ilp32f--;rv32imafdc-ilp32d--;rv64i-lp64--;rv64ic-lp64--;rv64iac-lp64--;rv64imac-lp64--;rv64imafdc-lp64d--;rv64im-lp64--;" && \ - make -j$(nproc) && \ - make install && \ - rm -rf /tmp/riscv-gnu-toolchain - -FROM ${LABS344_TOOLCHAIN_IMAGE} AS labs344-tools -ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -RUN git clone https://github.com/sifive/elf2hex.git /tmp/elf2hex && \ - cd /tmp/elf2hex && \ - autoreconf -i && \ - ./configure --target=riscv64-unknown-elf --prefix=${LABS344_RISCV_DIR} && \ - make -j$(nproc) && \ - make install && \ - rm -rf /tmp/elf2hex - -RUN git clone https://github.com/riscv-software-src/riscv-isa-sim /tmp/riscv-isa-sim && \ - mkdir -p /tmp/riscv-isa-sim/build && \ - cd /tmp/riscv-isa-sim/build && \ - ../configure --prefix=${LABS344_RISCV_DIR} && \ - make -j$(nproc) && \ - make install && \ - && rm -rf /tmp/riscv-isa-sim - -FROM docker.io/library/debian:${LABS344_DEBIAN_VERSION} AS labs344 +FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344-builder ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -COPY --from=labs344-tools /opt/riscv /opt/riscv - -RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ - apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get install -qqy --no-install-recommends \ - curl \ - wget \ - git \ - gnupg2 \ - ca-certificates \ - build-essential \ - make \ - cmake \ - ninja-build \ - python3-minimal \ - python3-pip \ - && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* +RUN dnf install -y git && \ + dnf install -y --allowerasing curl && \ + dnf clean all -FROM ${LABS344_BUILDER_IMAGE} AS labs344-devel -ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -RUN git clone https://github.com/openhwgroup/cvw && \ - cd cvw && \ +RUN git clone --recurse-submodules https://github.com/openhwgroup/cvw /tmp/cvw && \ + cd /tmp/cvw && \ git checkout main && \ - git submodule update --init --recursive && \ export WALLY=$(pwd) && \ export RISCV=/opt/riscv && \ - export PYTHON_VERSION=python3.11 && \ + export PYTHON_VERSION=python3.12 && \ bash -c ". $WALLY/bin/wally-environment-check.sh" && \ bash -c ". $WALLY/bin/wally-package-install.sh" && \ - bash -c ". $WALLY/bin/installation/python-setup.sh" && \ - bash -c ". $WALLY/bin/installation/activate-tools.sh" && \ - # bash -c ". $WALLY/bin/installation/riscv-gnu-toolchain-install.sh" && \ - bash -c ". $WALLY/bin/installation/elf2hex-install.sh" && \ - bash -c ". $WALLY/bin/installation/qemu-install.sh" && \ - bash -c ". $WALLY/bin/installation/spike-install.sh" && \ - # bash -c ". $WALLY/bin/installation/sail-install.sh" && \ - bash -c ". $WALLY/bin/installation/verilator-install.sh" && \ - cd .. && rm -rf cvw - + cd .. && rm -rf /tmp/cvw && \ + dnf clean all -# FROM docker.io/verilator/verilator:v5.028 AS labs344 -# ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# sudo \ -# git \ -# wget \ -# gnupg2 \ -# ca-certificates \ -# openssh-client \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# gcc-riscv64-unknown-elf \ -# binutils-riscv64-unknown-elf \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# COPY --from=whisper-builder /opt/VeeR-ISS/whisper /usr/local/bin/whisper - -# # hadolint ignore=DL3008 -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# make \ -# ninja-build \ -# libjson-perl \ -# libbit-vector-perl \ -# python3-minimal \ -# python3-pip \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=${TARGETPLATFORM}/var/cache/apt \ -# export DEBIAN_FRONTEND=noninteractive && \ -# apt-get update -qq && \ -# apt-get install -qqy --no-install-recommends \ -# gtkwave \ -# dbus-x11 \ -# libgtk-3-0 \ -# pop-gtk-theme \ -# && apt-get autoremove -y && rm -rf /var/lib/apt/lists/* - -# RUN groupadd bouncmpe -g 1000 && \ -# useradd -ms /bin/bash bouncmpe -g bouncmpe -u 1000 && \ -# printf "bouncmpe ALL= NOPASSWD: ALL\\n" >> /etc/sudoers - -# ENV LC_ALL=C.UTF-8 -# ENV LANG=C.UTF-8 -# ENV LANGUAGE=C.UTF-8 -# ENV GTK_THEME=Pop +FROM labs344-builder AS labs344-toolchain +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -# USER bouncmpe -# WORKDIR /home/bouncmpe +RUN git clone --recurse-submodules https://github.com/openhwgroup/cvw /tmp/cvw && \ + cd /tmp/cvw && \ + git checkout main && \ + export WALLY=$(pwd) && \ + export RISCV=/opt/riscv && \ + export PYTHON_VERSION=python3.12 && \ + bash -c ". $WALLY/bin/wally-tool-chain-install.sh --clean" && \ + cd .. && rm -rf /tmp/cvw && \ + dnf clean all -# # hadolint ignore=DL3013 -# RUN python3 -m pip install --no-cache-dir --user meson numpy pandas matplotlib +FROM labs344-builder AS labs344-tools +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -# RUN git clone --depth=1 --recurse-submodules --shallow-submodules \ -# https://github.com/chipsalliance/Cores-VeeR-EL2.git /home/bouncmpe/cores/VeerEL2 &&\ -# git clone --depth=1 --recurse-submodules --shallow-submodules \ -# https://github.com/chipsalliance/Cores-VeeR-EH1.git /home/bouncmpe/cores/VeerEH1 +FROM ${LABS344_RHEL_BASE_IMAGE}:${LABS344_RHEL_VERSION} AS labs344 +ARG TARGETARCH TARGETOS TARGETPLATFORM TARGETVARIANT -# ENTRYPOINT ["/bin/bash"] +COPY --from=labs344-toolchain /opt/riscv /opt/riscv