Skip to content

Conversation

HepoH3
Copy link
Contributor

@HepoH3 HepoH3 commented Jun 18, 2025

This PR adds the ability to compile test software, synthesize and simulate on windows platform through WSL2.

This change adds ability to compile test software, synthesize
and simulate  on windows platform through WSL2.

# Symlink proj for easy access and build tracking, ensuring its update
file delete -force ${project_root}/out.xci
file link -symbolic ${project_root}/out.xci $xci
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows, Vivado can't create symbolic links (hard links only).
Because of that, symlink creation moved to xilinx.mk

This makes script to be independent of import Windows PATH variable.
@paulsc96
Copy link
Member

Looks pretty good at first sight 👍 I will need to find some time to play with this on a Windows system.

An open point is if we can perhaps set up some Github runners to test Windows support as much as possible without commercial tools (mostly the build steps), as I'd hate to break it with a silly typo down the road and not notice. I will also look into this.

@HepoH3
Copy link
Contributor Author

HepoH3 commented Jun 20, 2025

Sure, take your time! The documentation with WSL configuration specifics is in the linked PR.

@HepoH3
Copy link
Contributor Author

HepoH3 commented Jun 25, 2025

if we can perhaps set up some Github runners to test Windows support

If it helps: WSL2 is available in the windows-2025 runner images. If you plan to use an older image, you may find this action useful.

@HepoH3
Copy link
Contributor Author

HepoH3 commented Jun 26, 2025

It turned out that even when using Windows-2025 runner, it is still necessary to configure WSL, since the system image comes without a pre-installed WSL2 distribution.

I was able to write a build workflow ported for the Windows platform, but it includes some workarounds. The issue is that GitHub Actions are applied to the host itself, and I'm not aware of a way to apply them inside WSL on that host. Because of this, existing actions like setup-python, riscv-gcc-install, and bender-install are not usable in this context, so I implemented their functionality manually.

Currently, the build completes successfully, but there is a problem with the whether-clean check. During the build, line endings in the repository change from CRLF to LF, which is shown by git status. This has been worked around by temporary adding a .gitattributes file to the repository with the following content:

* text=auto

Additionally, the current check effectively tests parts of the repository that are unchanged by this pull request, since all my modifications are tied to targets depending on commercial CAD tools. Effectively, it just verifies that the build flow sw/hw/sim -all on the Windows platform via WSL2 completes without errors. It might make sense to verify that commands for Vivado by, for example, correctly expanding them to the expected text outputs. However, I'm not sure how to implement that without hardcoding paths in the checks.

This is my first workflow, so it might not be perfectly written, but I hope you'll find it useful:

name: build

on: [push, pull_request, workflow_dispatch]

jobs:
  build:
    strategy:
      matrix:
        target: [sw, hw, sim]
      fail-fast: false
    runs-on: windows-2025

    steps:
      - name: Setup WSL
        uses: vedantmgoyal9/setup-wsl2@main
        with:
          distro: Ubuntu

      - name: Set custom WSL mount root
        run: |
          wsl bash -c "echo -e '[automount]\nroot = /' | sudo tee /etc/wsl.conf"
          wsl --shutdown

      - name: Install Dependencies
        run: |
          wsl bash -c "set -e; sudo apt update; for i in {1..5}; do sudo apt install -y python3 python3-pip python3-venv unzip gdisk && break; echo 'APT failed, retrying (\$i)...'; sleep 10; done"

      - name: Install Bender
        run: |
          wsl bash -c 'curl -f -sSL https://github.com/pulp-platform/bender/releases/download/v0.27.1/bender-0.27.1-x86_64-linux-gnu-ubuntu22.04.tar.gz -o $HOME/bender.tar.gz'
          wsl bash -c 'tar -xzf $HOME/bender.tar.gz -C $HOME'
          wsl bash -c 'chmod +x $HOME/bender'

      - name: Install RISC-V GCC toolchain
        run: |
          wsl curl -f -sSL https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2023.03.14/riscv64-elf-ubuntu-22.04-nightly-2023.03.14-nightly.tar.gz -o toolchain.tar.gz
          wsl bash -c 'mkdir -p $HOME/riscv'
          wsl bash -c 'tar -xzf toolchain.tar.gz -C $HOME/riscv --strip-components=1'

      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive

      - name: Install Python requirements
        run: wsl pip3 install -r requirements.txt

      - name: Build target
        run: |
          wsl bash -c 'export CHS_SW_GCC_BINROOT=$HOME/riscv/bin BENDER=$HOME/bender && make ${{ matrix.target }}-all'

      - name: Check whether clean
        run: |
          wsl echo "* text=auto" >> .gitattributes
          wsl git add --renormalize .
          wsl rm .gitattributes
          wsl git status
          wsl bash -c 'test -z "$(git status --porcelain --ignore-submodules)"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants