diff --git a/.github/workflows/dump-wave.yml b/.github/workflows/dump-wave.yml deleted file mode 100644 index 6b370eed9..000000000 --- a/.github/workflows/dump-wave.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Test dump wave -on: [pull_request] -env: - USER: runner - -jobs: - ci: - name: "CI" - runs-on: [self-hosted, linux] - steps: - - uses: actions/checkout@v3 - with: - submodules: true - - run: sudo -E .github/setup-actions.sh - env: - AWS_CREDENTIALS: ${{secrets.AWS_CREDENTIALS}} - CACHE_PRIV_KEY: ${{secrets.CACHE_PRIV_KEY}} - CACHE_DOMAIN: ${{secrets.CACHE_DOMAIN}} - ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY: ${{secrets.ROCKETCHIP_NIX_REMOTE_SSH_PRIVKEY}} - ROCKETCHIP_NIX_REMOTE_HOST: ${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}} - - uses: cachix/install-nix-action@v19 - with: - install_url: https://releases.nixos.org/nix/nix-2.13.3/install - nix_path: nixpkgs=channel:nixos-unstable - extra_nix_config: | - post-build-hook = /etc/nix/upload-to-cache.sh - trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= minio.inner.fi.c-3.moe:gDg5SOIH65O0tTV89dUawME5BTmduWWaA7as/cqvevM= - extra-substituters = https://${{secrets.CACHE_DOMAIN}}/nix - sandbox = relaxed - max-jobs = 0 - builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key - builders-use-substitutes = true - - run: | - # Force to make test fail - sed -i 's/CHECK_EQ/CHECK_GT/' emulator/src/vbridge_impl.cc - nix develop .#testcase -c mill -i verilatorEmulator[v1024l8b2-test-trace,hello-mlir,debug].run || true - outputDir=out/verilatorEmulator/v1024l8b2-test-trace/hello-mlir/debug/run.dest - [[ -f $outputDir/wave.fst ]] || (echo "Wave file doesn't generate" && exit 1) - [[ ! -f $outputDir/wave.fst.hier ]] || \ - (echo "Verilator doesn't exit correctly" \ - && exit 1) diff --git a/.github/workflows/postpr.yml b/.github/workflows/postpr.yml index 5325aa7ac..9b5c92151 100644 --- a/.github/workflows/postpr.yml +++ b/.github/workflows/postpr.yml @@ -38,7 +38,8 @@ jobs: builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key builders-use-substitutes = true - id: ci-tests - run: nix develop '.?submodules=1#ci' -c make ci-unpassed-tests DEFAULT_PASSED=.github/passed/default.txt + run: | + nix develop '.#ci' -c make ci-unpassed-tests DEFAULT_PASSED=.github/passed/default.txt ci: name: "CI" @@ -75,8 +76,8 @@ jobs: builders-use-substitutes = true - id: ci-run run: | - nix develop '.?submodules=1#ci' -c make ci-run "NAME=${{ matrix.name }}" - nix develop '.?submodules=1#ci' -c make convert-perf-to-md + nix develop '.#ci' -c make ci-run "NAME=${{ matrix.name }}" + nix develop '.#ci' -c make convert-perf-to-md - uses: actions/upload-artifact@v3 if: always() diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b4b67ab2b..d03c4f243 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,6 +15,7 @@ jobs: - uses: actions/checkout@v3 with: submodules: true + fetch-depth: 0 - run: sudo -E .github/setup-actions.sh env: AWS_CREDENTIALS: ${{secrets.AWS_CREDENTIALS}} @@ -30,12 +31,12 @@ jobs: post-build-hook = /etc/nix/upload-to-cache.sh trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= minio.inner.fi.c-3.moe:gDg5SOIH65O0tTV89dUawME5BTmduWWaA7as/cqvevM= extra-substituters = https://${{secrets.CACHE_DOMAIN}}/nix - sandbox = relaxed max-jobs = 0 builders = ssh://nix-remote@${{secrets.ROCKETCHIP_NIX_REMOTE_HOST}}?ssh-key=/etc/nix/builder-key builders-use-substitutes = true - id: ci-tests - run: nix develop '.?submodules=1#ci' -c make ci-passed-tests DEFAULT_PASSED=.github/passed/default.txt + run: | + nix develop '.#ci' --show-trace -c make ci-passed-tests DEFAULT_PASSED=.github/passed/default.txt ci: name: "CI" @@ -71,7 +72,7 @@ jobs: builders-use-substitutes = true - id: ci-run run: | - nix develop '.?submodules=1#ci' -c make ci-run "NAME=${{ matrix.name }}" + nix develop '.#ci' -c make ci-run "NAME=${{ matrix.name }}" - uses: actions/upload-artifact@v3 if: always() @@ -149,8 +150,14 @@ jobs: builders-use-substitutes = true - run: | millTask=$(echo ${{ matrix.name }} | sed 's/v1024l8b2-test/v1024l8b2-test-trace/') - nix develop '.?submodules=1#ci' -c mill -i "$millTask" - find out -name 'wave.fst' -exec mv {} "$millTask".fst \; + nix develop '.#ci' -c mill -i "$millTask" + waveFile=$(find out -name 'wave.fst') + hierFile=$(find out -name 'wave.hier') + if [[ -z "$waveFile" || -n "$hierFile" ]]; then + echo "Verilator doesn't generate wave correctly" + exit 1 + fi + mv "$waveFile" ./wave-"$millTask".fst - uses: actions/upload-artifact@v3 with: name: fail-test-wave diff --git a/flake.nix b/flake.nix index 3c7ec93f5..b7f830cbd 100644 --- a/flake.nix +++ b/flake.nix @@ -87,10 +87,7 @@ buildInputs = commonDeps ++ chiselDeps ++ testcaseDeps ++ emulatorDeps; env = let - verilatorEmulator = pkgs.callPackage ./nix/verilator-emulator.nix { - emulatorTypes = [ "v1024l8b2-test" "v1024l8b2-test-trace" ]; - emulatorSrc = self; - }; + verilatorEmulator = pkgs.callPackage ./nix/verilator-emulator.nix {}; in { VERILATOR_EMULATOR_BIN_PATH = "${verilatorEmulator}/bin"; diff --git a/nix/verilator-emulator.nix b/nix/verilator-emulator.nix index 9a3c83404..347a6cd7f 100644 --- a/nix/verilator-emulator.nix +++ b/nix/verilator-emulator.nix @@ -1,5 +1,5 @@ { lib -, runCommandLocal +, fetchFromGitHub , mill , fetchMillDeps , millSetupHook @@ -22,45 +22,34 @@ , # Try speed up compilation llvmPackages_14 , # Compile options - emulatorTypes ? [ "v1024l8b2-test" ] + emulatorTypes ? [ "v1024l8b2-test" "v1024l8b2-test-trace" ] , emulatorSrc ? null }: assert lib.assertMsg ((builtins.typeOf emulatorTypes) == "list") "`emulatorTypes` is not a `list`"; let - srcs = [ - ../build.sc - ../common.sc - ../v - ../run - ../emulator - ../elaborator - ../dependencies - ../configs - ]; - # We can simpliy reference the whole repository, but it will let the emulator build again and again - # even when we are editing GitHub Action workflow. - pureEmulatorSrc = runCommandLocal "prepareEmulatorSrc" { inherit srcs; } '' - mkdir -p $out && cd $out - - srcArray=( $srcs ) - for src in ''${srcArray[@]}; do - dest="$(stripHash "$src")" - cp -pr --reflink=auto -- "$src" "$dest" - done - ''; - - src = if (builtins.typeOf emulatorSrc != "null") then emulatorSrc else pureEmulatorSrc; + t1 = (fetchFromGitHub { + owner = "chipsalliance"; + repo = "t1"; + rev = "1f6bf0b79682d88dc3e95c24c9567a584d6fd9dd"; + hash = "sha256-okDsnjmEJplIfiIMdb0X1hvMYWEj/Wg7w26XJ2KdXvE="; + fetchSubmodules = true; + }).overrideAttrs (_: { + GIT_CONFIG_COUNT = 1; + GIT_CONFIG_KEY_0 = "url.https://github.com/.insteadOf"; + GIT_CONFIG_VALUE_0 = "git@github.com:"; + }); in llvmPackages_14.stdenv.mkDerivation rec { version = "unstable-2023-10"; pname = "emulator"; - inherit src; + + src = if (builtins.typeOf emulatorSrc != "null") then emulatorSrc else t1; millDeps = fetchMillDeps { inherit src pname; - millDepsHash = "sha256-Z/CobcyBWB3y81iT+IFVapRn1gJh7ky71es11a4NvCU="; + millDepsHash = "sha256-8dUmHN85GLthNzHCt5vSO/bH+KdOMopLQ6rCgTnoRPk="; }; nativeBuildInputs = [