diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c175c68..37852fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: CI +name: vrtlmod CI - build, test, and benchmark on: push: @@ -45,7 +45,16 @@ jobs: with: path: vrtlmod_src submodules: true - + - name: Load env vars from docker/.env + run: | + while IFS='=' read -r key value || [ -n "$key" ]; do + [[ -z "$key" || "$key" == \#* ]] && continue + key="$(echo "$key" | xargs)" + value="$(echo "$value" | xargs)" + value="${value%\"}" + value="${value#\"}" + echo "$key=$value" >> $GITHUB_ENV + done < vrtlmod_src/docker/.env - if: ${{ matrix.llvm.src == 'true' }} name: Cache LLVM id: cache-llvm @@ -54,7 +63,6 @@ jobs: path: /llvm_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} - - name: Cache Verilator id: cache-verilator uses: actions/cache@v4 @@ -62,7 +70,6 @@ jobs: path: /verilator_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} - - name: Cache SystemC id: cache-systemc uses: actions/cache@v4 @@ -70,7 +77,6 @@ jobs: path: /systemc_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} - - name: Requirements (Linux) if: runner.os == 'Linux' continue-on-error: false @@ -79,7 +85,6 @@ jobs: run: | . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_env - - if: ${{ steps.cache-systemc.outputs.cache-hit != 'true' }} name: Requirements SystemC working-directory: ${{runner.workspace}} @@ -87,7 +92,6 @@ jobs: run: | . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_systemc "${{runner.workspace}}/systemc_src" "${{runner.workspace}}/systemc_build" "/systemc_install" "${{ matrix.systemc_version }}" - - if: ${{ steps.cache-verilator.outputs.cache-hit != 'true' }} name: Requirements Verilator working-directory: ${{runner.workspace}} @@ -95,22 +99,19 @@ jobs: run: | . "./vrtlmod/vrtlmod_src/docker/setup_debian.sh" setup_verilator "${{runner.workspace}}/verilator_src" "${{runner.workspace}}/verilator_src" "/verilator_install" "${{ matrix.verilator_version }}" - - name: Check (cached) Verilator continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: /verilator_install/bin/verilator --version - - if: ${{ (matrix.llvm.src == 'true') && (steps.cache-llvm.outputs.cache-hit != 'true') }} name: Requirements LLVM+Clang working-directory: ${{runner.workspace}} shell: bash run: | - export LLVM_FROM_SOURCE="ON" + export ENV_LLVM_FROM_SOURCE="ON" . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_llvm "${{runner.workspace}}/llvm_src" "${{runner.workspace}}/llvm_build" "/llvm_install" "${{ matrix.llvm.version }}" "$PWD/vrtlmod/vrtlmod_src/deps/llvm/patches" - - if: ${{ matrix.llvm.src == 'true' }} name: Check (cached) LLVM continue-on-error: false @@ -142,22 +143,30 @@ jobs: run: | apt update apt install -y git - - name: Checkout uses: actions/checkout@v4 with: path: vrtlmod_src submodules: recursive - + - name: Load env vars from docker/.env + run: | + while IFS='=' read -r key value || [ -n "$key" ]; do + [[ -z "$key" || "$key" == \#* ]] && continue + key="$(echo "$key" | xargs)" + value="$(echo "$value" | xargs)" + value="${value%\"}" + value="${value#\"}" + echo "$key=$value" >> $GITHUB_ENV + done < vrtlmod_src/docker/.env - name: Requirements (Linux) if: runner.os == 'Linux' continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: | + . ./vrtlmod/vrtlmod_src/docker/.env . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_env - - if: ${{ matrix.llvm.src == 'true' }} name: Cache LLVM id: cache-llvm @@ -166,14 +175,12 @@ jobs: path: /llvm_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} - - if: ${{ matrix.llvm.src != 'true' }} name: Install LLVM build dependencies (system) run: | apt update apt remove -y llvm* clang* libllvm* libclang* apt install -y libzstd-dev llvm-${{ matrix.llvm.version }}-dev libclang-${{ matrix.llvm.version }}-dev clang-${{ matrix.llvm.version }} - - name: Cache Verilator id: cache-verilator uses: actions/cache@v4 @@ -181,7 +188,6 @@ jobs: path: /verilator_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} - - name: Cache SystemC id: cache-systemc uses: actions/cache@v4 @@ -189,20 +195,17 @@ jobs: path: /systemc_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} - - name: Check (cached) Verilator continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: /verilator_install/bin/verilator --version - - if: ${{ matrix.llvm.src == 'true' }} name: Check (cached) Clang continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: /llvm_install/bin/clang --version - - if: ${{ matrix.llvm.src == 'true' }} name: Build vRTLmod (LLVM from source) shell: bash @@ -211,9 +214,9 @@ jobs: export VERILATOR_ROOT=/verilator_install export LLVM_DIR=/llvm_install export SYSTEMC_HOME=/systemc_install + . ./vrtlmod/vrtlmod_src/docker/.env . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_vrtlmod "${GITHUB_WORKSPACE}/vrtlmod_src" "/vrtlmod_build" "/vrtlmod_install" - - if: ${{ matrix.llvm.src != 'true' }} name: Build vRTLmod (LLVM system) shell: bash @@ -221,9 +224,16 @@ jobs: run: | export VERILATOR_ROOT=/verilator_install export SYSTEMC_HOME=/systemc_install + . ./vrtlmod/vrtlmod_src/docker/.env . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh - setup_vrtlmod "${GITHUB_WORKSPACE}/vrtlmod_src" "/vrtlmod_build" "/vrtlmod_install" - + setup_vrtlmod "${GITHUB_WORKSPACE}/vrtlmod_src" "/vrtlmod_build" "/vrtlmod_install" + - name: Run Tests + shell: bash + working-directory: ${{runner.workspace}} + run: | + . ./vrtlmod/vrtlmod_src/docker/.env + . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh + test_vrtlmod "${GITHUB_WORKSPACE}/vrtlmod_src" "/vrtlmod_build" "/vrtlmod_install" - name: (CTest) Upload Artifacts on Failure uses: actions/upload-artifact@v5 if: ${{ failure() }} @@ -232,7 +242,6 @@ jobs: path: /vrtlmod_build/Testing/ if-no-files-found: error retention-days: 15 - - name: Upload Compiled System if: runner.os == 'Linux' uses: actions/upload-artifact@v5 @@ -268,12 +277,20 @@ jobs: run: | apt update apt install -y git - - name: Checkout vrtlmod uses: actions/checkout@v4 with: path: vrtlmod_src - + - name: Load env vars from docker/.env + run: | + while IFS='=' read -r key value || [ -n "$key" ]; do + [[ -z "$key" || "$key" == \#* ]] && continue + key="$(echo "$key" | xargs)" + value="$(echo "$value" | xargs)" + value="${value%\"}" + value="${value#\"}" + echo "$key=$value" >> $GITHUB_ENV + done < vrtlmod_src/docker/.env - name: Checkout vrtlmod-test uses: actions/checkout@v4 with: @@ -281,16 +298,15 @@ jobs: repository: tum-ei-eda/vrtlmod-test ref: master submodules: recursive - - name: Requirements (Linux) if: runner.os == 'Linux' continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: | + . ./vrtlmod/vrtlmod_src/docker/.env . ./vrtlmod/vrtlmod_src/docker/setup_debian.sh setup_env - - name: Cache Verilator id: cache-verilator uses: actions/cache@v4 @@ -298,7 +314,6 @@ jobs: path: /verilator_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }} - - if: ${{ matrix.llvm.src == 'true' }} name: Cache LLVM id: cache-llvm @@ -307,14 +322,12 @@ jobs: path: /llvm_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} - - if: ${{ matrix.llvm.src != 'true' }} name: Install LLVM build dependencies (system) run: | apt update apt remove -y llvm* clang* libllvm* libclang* apt install -y libzstd-dev llvm-${{ matrix.llvm.version }}-dev libclang-${{ matrix.llvm.version }}-dev clang-${{ matrix.llvm.version }} - - name: Cache SystemC id: cache-systemc uses: actions/cache@v4 @@ -322,26 +335,22 @@ jobs: path: /systemc_install key: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} restore-keys: ${{ matrix.os.name }}-${{ matrix.os.version }}_systemc-${{ matrix.systemc_version }} - - name: Check (cached) Verilator continue-on-error: false shell: bash working-directory: ${{runner.workspace}} run: /verilator_install/bin/verilator --version - - name: Fetch Compiled System uses: actions/download-artifact@v5 with: name: vrtlmod_${{ matrix.os.name }}-${{ matrix.os.version }}_verilator-${{ matrix.verilator_version }}_llvm-${{ matrix.llvm.name }}-${{ matrix.llvm.version }} path: /vrtlmod_install/ - - name: Check pre-compiled vrtlmod shell: bash run: | chmod +x /vrtlmod_install/bin/vrtlmod chmod +x /vrtlmod_install/cmake/vrtlmod-config.cmake /vrtlmod_install/bin/vrtlmod --version - - name: Patch Submodule shell: bash run: | @@ -352,7 +361,6 @@ jobs: ls -la . git apply "../../../patches/scc-gcc_gt_13.patch" git apply "../../../patches/scc-byteenabletransactions.patch" - - if: ${{ matrix.llvm.src == 'true' }} name: Configure Benchmarks (LLVM source) shell: bash @@ -362,7 +370,6 @@ jobs: export LLVM_DIR=/llvm_install export SYSTEMC_HOME=/systemc_install cmake -S ${GITHUB_WORKSPACE}/vrtlmod-test_src -B build -D VRTL_NAMES="${{matrix.duts}}" -D CMAKE_BUILD_TYPE=${{ matrix.cmakegen }} -D VRTLMOD_ROOT=/vrtlmod_install - - if: ${{ matrix.llvm.src != 'true' }} name: Configure Benchmarks (LLVM system) shell: bash @@ -371,20 +378,17 @@ jobs: export VERILATOR_ROOT=/verilator_install export SYSTEMC_HOME=/systemc_install cmake -S ${GITHUB_WORKSPACE}/vrtlmod-test_src -B build -D VRTL_NAMES="${{matrix.duts}}" -D CMAKE_BUILD_TYPE=${{ matrix.cmakegen }} -D VRTLMOD_ROOT=/vrtlmod_install - - name: Compile Benchmarks shell: bash working-directory: ${{runner.workspace}} run: | cmake --build build --parallel $(nproc) - - name: Run Benchmarks shell: bash working-directory: ${{runner.workspace}} run: | build/benchmark/V${{ matrix.duts }}-SC_TEST_VRTLMOD ${GITHUB_WORKSPACE}/vrtlmod-test_src/benchmark/${{matrix.duts}}/dhry.elf 5 10 > ${{matrix.duts}}-log.txt cat ${{matrix.duts}}-log.txt - - name: Save Benchmark Results uses: actions/upload-artifact@v5 with: diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml new file mode 100644 index 0000000..e9e9265 --- /dev/null +++ b/.github/workflows/container.yml @@ -0,0 +1,83 @@ +name: Build single vrtlmod docker image +on: + workflow_dispatch: + inputs: + vrtlmod-ref: + description: docker version/tag/branch + required: true + default: default + base-image: + description: OS base image + required: true + default: debian:stable + llvm-ref: + description: LLVM Version + required: true + default: 18 +jobs: + image-base: + name: Build vrtlmod-base image for users + runs-on: ubuntu-latest + steps: + - name: Set current date as env variable + run: | + echo "builddate=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + id: timestamp + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Set os env variable. Append env vars from docker/.env + run: | + echo "os=$(echo '${{ github.event.inputs.base-image }}' | tr ':' '-')" >> $GITHUB_OUTPUT + while IFS='=' read -r key value || [ -n "$key" ]; do + [[ -z "$key" || "$key" == \#* ]] && continue + key="$(echo "$key" | xargs)" + value="$(echo "$value" | xargs)" + value="${value%\"}" + value="${value#\"}" + echo "$key=$value" >> $GITHUB_ENV + done < docker/.env + id: os + - name: Remove unused software + run: | + echo "Available storage before:" + sudo df -h + echo + sudo rm -rf /usr/share/dotnet + sudo rm -rf /usr/local/lib/android + sudo rm -rf /opt/ghc + sudo rm -rf /opt/hostedtoolcache/CodeQL + sudo docker image prune --force + sudo docker builder prune + echo "Available storage after:" + sudo df -h + echo + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to DockerHub + uses: docker/login-action@v3 + if: ${{ github.repository == 'tum-ei-eda/vrtlmod' }} + with: + registry: ${{ secrets.DOCKER_REGISTRY }} + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Build and push to Docker Hub + uses: docker/build-push-action@v6 + if: ${{ github.repository == 'tum-ei-eda/vrtlmod' }} + with: + context: . + file: docker/Dockerfile + pull: true + push: true + target: vrtlmod-base + build-args: | + BASE_IMAGE=${{ github.event.inputs.base-image }} + workspace_dir=${{ env.workspace_dir }} + ENV_LLVM_FROM_SOURCE=${{ env.ENV_LLVM_FROM_SOURCE }} + ENV_LLVM_VERSION=${{ github.event.inputs.llvm-ref }} + ENV_BUILD_CONFIG=${{ env.ENV_BUILD_CONFIG }} + ENV_BUILD_CXX_STANDARD=${{ env.ENV_BUILD_CXX_STANDARD }} + tags: | + ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_NAMESPACE }}/vrtlmod-base:${{ steps.timestamp.outputs.builddate }}-${{ github.event.inputs.vrtlmod-ref }}-${{ steps.os.outputs.os }}-${{ github.event.inputs.llvm-ref }} + ${{ secrets.DOCKER_REGISTRY }}/${{ secrets.DOCKER_NAMESPACE }}/vrtlmod-base:latest-${{ github.event.inputs.vrtlmod-ref }}-${{ steps.os.outputs.os }}-${{ github.event.inputs.llvm-ref }} diff --git a/docker/.env b/docker/.env index 0b8b350..40280e1 100644 --- a/docker/.env +++ b/docker/.env @@ -1 +1,5 @@ -workspace_dir="/vrtlmod" \ No newline at end of file +workspace_dir=vrtlmod +ENV_LLVM_FROM_SOURCE=OFF +ENV_BUILD_CONFIG=Release +ENV_BUILD_CXX_STANDARD=17 +ENV_LLVM_VERSION=15 diff --git a/docker/README.adoc b/docker/README.adoc new file mode 100644 index 0000000..d1a2775 --- /dev/null +++ b/docker/README.adoc @@ -0,0 +1,103 @@ += Docker Images for vrtlmod + +== Prerequisites + +In addition to a regular Docker installation, `buildx` is required for building the vrtlmod images. + +Dependencies:: +[,bash] +---- +apt install docker-buildx-plugin +---- + +== Container/Image Types + +=== `vrtlmod-base` + +The `vrtlmod-base` image contains an installation of LLVM patched and built with `vrtlmod`. Furthermore, the image is pruned of LLVM build artifacts and source-code. + +NOTE: `vrtlmod-base` is intended to be used as a "standalone" compiler container. + +=== `vrtlmod-dev` + +t.b.d. + + +== Use + +=== Pulling prebuilt images + +Check our https://hub.docker.com/r/tumeda/[DockerHub] for the latest images and supported OS/LLVM versions: + +* https://hub.docker.com/r/tumeda/vrtlmod-base/tags[`vrtlmod-base`] +** debian:stable image:https://img.shields.io/docker/v/tumeda/vrtlmod-base/latest-default-debian-stable["tumeda/vrtlmod-base", link="https://img.shields.io/docker/v/tumeda/vrtlmod-base/latest-default-debian-stable"] + +Example commands to pull an image from the registry:: +[,bash] +---- +docker pull tumeda/vrtlmod-base:latest-default-debian-stable +---- + +=== Building Images + +==== Local + +You can build the images locally as follows:: +[,bash] +---- +cd path/to/vrtlmod/clone +source docker/.env + +# Build vrtlmod-base image +docker buildx build . -f docker/Dockerfile \ + --tag tumeda/vrtlmod-base:latest-default-debian-stable \ + --target vrtlmod-base \ + --build-arg BASE_IMAGE=debian:stable \ + --build-arg workspace_dir=. \ + --build-arg ENV_LLVM_FROM_SOURCE=${ENV_LLVM_FROM_SOURCE} \ + --build-arg ENV_LLVM_VERSION=${ENV_LLVM_VERSION} \ + --build-arg ENV_BUILD_CONFIG=${ENV_BUILD_CONFIG} \ + --build-arg ENV_BUILD_CXX_STANDARD=${ENV_BUILD_CXX_STANDARD} +---- + +Build times (excluding pulling of base image) on 18-core workstation:: + +- `vrtlmod-dev`: `t.b.d.` +- `vrtlmod-base`: `t.b.d.` + +Image sizes:: + +- `vrtlmod-dev`: `t.b.d.` +- `vrtlmod-base`: `t.b.d.` + +==== GitHub Action + +Manual builds:: + +Use the `Run Workflow` button on https://github.com/tum-ei-eda/vrtlmod/actions/workflows/container.yml to build images for a specific OS. + +CI Setup for DockerHub:: + +If you want to use the actions on a fork, they will fail due to missing docker credentials. Please export the following variables via `Settings -> Secrets -> Actions` to tell the jobs about your username and password: + +- `DOCKER_PASSWORD` +- `DOCKER_USERNAME` (e.g., `tumeda`) +- `DOCKER_REGISTRY` (e.g., `docker.io`, `ghcr.io`) +- `DOCKER_NAMESPACE` (e.g., `tumeda`, `path/to/container`) + +=== Running the Images in Docker Containers + +To use the previously built or pulled images, run the following commands:: + +[,bash] +---- +# pull a latest image: +docker pull tumeda/vrtlmod-base:latest-default-debian-stable + +# run the pulled container and mount the host's vrtlmod repo: +cd path/to/vrtlmod/clone +docker run -it --rm -v $(pwd):$(pwd) -v .:/vrtlmod tumeda/vrtlmod-base:latest-default-debian-stable + +# in the container: +/vrtlmod-install/bin/vrtlmod --version # <-- is the vrtlmod binary +---- \ No newline at end of file diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index 59ed476..a62b39a 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -1,10 +1,15 @@ services: vrtlmodworkspace: + env_file: ".env" build: context: .. dockerfile: docker/dockerfile args: workspace_dir: "${workspace_dir}" + ENV_LLVM_FROM_SOURCE: "${ENV_LLVM_FROM_SOURCE}" + ENV_LLVM_VERSION: "${ENV_LLVM_VERSION}" + ENV_BUILD_CONFIG: "${ENV_BUILD_CONFIG}" + ENV_BUILD_CXX_STANDARD: "${ENV_BUILD_CXX_STANDARD}" environment: workspace_dir: "${workspace_dir}" volumes: diff --git a/docker/dockerfile b/docker/dockerfile index 1936204..661ee3f 100644 --- a/docker/dockerfile +++ b/docker/dockerfile @@ -1,13 +1,24 @@ -FROM debian:stable - +ARG BASE_IMAGE=debian:stable +ARG workspace_dir +ARG ENV_LLVM_FROM_SOURCE +ARG ENV_LLVM_VERSION +ARG ENV_BUILD_CONFIG +ARG ENV_BUILD_CXX_STANDARD +################################################################################################### +FROM ${BASE_IMAGE} AS vrtlmod-base +ARG workspace_dir +ARG ENV_LLVM_FROM_SOURCE +ARG ENV_LLVM_VERSION +ARG ENV_BUILD_CONFIG +ARG ENV_BUILD_CXX_STANDARD # Overall build config for cmake dependencies -ENV LLVM_FROM_SOURCE="OFF" - -ARG build_config="Release" -ARG GLOBAL_BUILD_CONFIG="${build_config}" - -ARG workspace_dir=${workspace_dir} -# Prerequisite packages +ENV ENV_LLVM_FROM_SOURCE=${ENV_LLVM_FROM_SOURCE} +ENV ENV_LLVM_VERSION=${ENV_LLVM_VERSION} +ENV ENV_BUILD_CONFIG=${ENV_BUILD_CONFIG} +ENV ENV_BUILD_CXX_STANDARD=${ENV_BUILD_CXX_STANDARD} +######################### +# Prerequisite packages # +######################### RUN \ --mount=type=bind,source=".",target=${workspace_dir} \ . "${workspace_dir}/docker/setup_debian.sh" && \ @@ -49,8 +60,8 @@ RUN \ ARG llvm_srcdir="/llvm-src" ARG llvm_builddir="/llvm-build" ARG llvm_destdir="/llvm-install" -ARG llvm_version="18" -ARG llvm_patch_dir="${workspace_dir}/vrtlmod/deps/llvm/patches" +ARG llvm_version="${ENV_LLVM_VERSION}" +ARG llvm_patch_dir="${workspace_dir}/deps/llvm/patches" RUN \ --mount=type=bind,source=".",target=${workspace_dir} \ @@ -77,7 +88,6 @@ ARG vrtlmod_destdir="/vrtlmod-install" ENV LLVM_DIR="${llvm_destdir}" ENV VERILATOR_ROOT="${verilator_destdir}" -ENV VRTLMOD_BUILD_CONFIG="${build_config}" ENV SYSTEMC_HOME="${systemc_destdir}" RUN mkdir -p ${vrtlmod_srcdir} @@ -86,4 +96,10 @@ RUN \ --mount=type=bind,source=".",target="${workspace_dir}" \ . "${venvdir}/bin/activate" && \ . "${workspace_dir}/docker/setup_debian.sh" && \ - setup vrtlmod ${vrtlmod_srcdir} ${vrtlmod_builddir} ${vrtlmod_destdir} \ No newline at end of file + setup vrtlmod ${vrtlmod_srcdir} ${vrtlmod_builddir} ${vrtlmod_destdir} + +RUN \ + --mount=type=bind,source=".",target="${workspace_dir}" \ + . "${venvdir}/bin/activate" && \ + . "${workspace_dir}/docker/setup_debian.sh" && \ + cleanup_vrtlmod ${vrtlmod_srcdir} ${vrtlmod_builddir} ${vrtlmod_destdir} diff --git a/docker/setup_debian.sh b/docker/setup_debian.sh index 68971b5..f6b4e5c 100644 --- a/docker/setup_debian.sh +++ b/docker/setup_debian.sh @@ -108,7 +108,7 @@ setup_llvm() { version="${4}" patch_dir=$5 - if [ "${LLVM_FROM_SOURCE}" = "ON" ]; then + if [ "${ENV_LLVM_FROM_SOURCE}" = "ON" ]; then if [ ! -f "${install_dir}/bin/clang" ]; then fetch_llvm "$1" "$2" "$3" "${4}" ${5} && \ configure_llvm "$1" "$2" "$3" "${4}" && \ @@ -147,11 +147,13 @@ configure_systemc() { install_dir="$3" version="${4}" - echo "[configure] systemc" + echo "[configure] systemc (${ENV_BUILD_CONFIG}-c++${ENV_BUILD_CXX_STANDARD})" cmake -S "${src_dir}" -B "${build_dir}" \ -D CMAKE_INSTALL_PREFIX="${install_dir}" \ - -D CMAKE_BUILD_TYPE=Release \ - -D CMAKE_CXX_STANDARD=17 + -D CMAKE_BUILD_TYPE="${ENV_BUILD_CONFIG}" \ + -D CMAKE_CXX_STANDARD="${ENV_BUILD_CXX_STANDARD}" \ + -D BUILD_SHARED_LIBS=Off \ + -D CMAKE_POSITION_INDEPENDENT_CODE=ON } build_systemc() { src_dir="$1" @@ -285,7 +287,8 @@ configure_vrtlmod() { cmake \ -S "${src_dir}" \ -B "${build_dir}" \ - -D CMAKE_BUILD_TYPE=${VRTLMOD_BUILD_CONFIG} \ + -D CMAKE_BUILD_TYPE=${ENV_BUILD_CONFIG} \ + -D CMAKE_CXX_STANDARD="${ENV_BUILD_CXX_STANDARD}" \ -D CMAKE_INSTALL_PREFIX=${install_dir} \ -D SystemCLanguage_DIR="${SYSTEMC_HOME}/lib/cmake/SystemCLanguage" \ -D BUILD_TESTING=On @@ -321,8 +324,7 @@ cleanup_vrtlmod() { install_dir="$3" echo "[clean-up] vRTLmod" - echo "nothing to do." - #rm -r ${build_dir} + rm -rf "${build_dir}" } setup_vrtlmod() { src_dir="$1" @@ -333,9 +335,7 @@ setup_vrtlmod() { fetch_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" && \ configure_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" && \ build_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" && \ - install_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" && \ - test_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" && \ - cleanup_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" + install_vrtlmod "${src_dir}" "${build_dir}" "${install_dir}" fi }