From e050f0f8dab69d220a3308bcb3015005a25f5221 Mon Sep 17 00:00:00 2001 From: Shogo Takata Date: Wed, 22 Jul 2026 13:12:22 +0900 Subject: [PATCH] circt: 1.147.0 -> 1.160.0 sv-lang for circt is pined now. Adds custom update script that handles circt and sv-lang. Assisted-by: pi (OpenAI gpt-5.6-sol) --- pkgs/by-name/ci/circt/package.nix | 20 +++++---- pkgs/by-name/ci/circt/sv-lang.nix | 68 +++++++++++++++++++++++++++++ pkgs/by-name/ci/circt/update.sh | 71 +++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 8 deletions(-) create mode 100644 pkgs/by-name/ci/circt/sv-lang.nix create mode 100755 pkgs/by-name/ci/circt/update.sh diff --git a/pkgs/by-name/ci/circt/package.nix b/pkgs/by-name/ci/circt/package.nix index fdfc8496d016..a72f744bdb57 100644 --- a/pkgs/by-name/ci/circt/package.nix +++ b/pkgs/by-name/ci/circt/package.nix @@ -9,11 +9,9 @@ ninja, lit, z3, - sv-lang_10, # update sv-lang version here according to upstream requirements fmt, boost, mimalloc, - gitUpdater, callPackage, versionCheckHook, @@ -24,15 +22,16 @@ let pythonEnv = python3.withPackages (ps: [ ps.psutil ]); circt-llvm = callPackage ./circt-llvm.nix { }; + circt-sv-lang = callPackage ./sv-lang.nix { }; in stdenv.mkDerivation (finalAttrs: { pname = "circt"; - version = "1.147.0"; + version = "1.160.0"; src = fetchFromGitHub { owner = "llvm"; repo = "circt"; tag = "firtool-${finalAttrs.version}"; - hash = "sha256-rtnvahI7EzUJXE80X3XPWjjDD/6f9BPmZ7S97Lstuhw="; + hash = "sha256-KWh1z2Pvf+BVyzv6+ruaQRAULrIX9T1WjnIhpuTjzNc="; fetchSubmodules = true; }; @@ -55,7 +54,7 @@ stdenv.mkDerivation (finalAttrs: { boost fmt mimalloc - sv-lang_10 + circt-sv-lang ]; cmakeFlags = [ @@ -112,6 +111,12 @@ stdenv.mkDerivation (finalAttrs: { postPatch = '' patchShebangs tools/circt-test + # Keep the self-contained TableGen tests compatible with nixpkgs' lit. + substituteInPlace test/Tools/circt-tblgen/self-contained/self_contained_td_format.py \ + --replace-fail \ + 'timeout = test.config.maxIndividualTestTime or None' \ + 'timeout = getattr(test.config, "maxIndividualTestTime", None)' + # Replace slang references to match the package in nixpkgs substituteInPlace \ lib/Tools/circt-verilog-lsp-server/VerilogServerImpl/CMakeLists.txt \ @@ -169,10 +174,9 @@ stdenv.mkDerivation (finalAttrs: { ''; passthru = { - updateScript = gitUpdater { - rev-prefix = "firtool-"; - }; + updateScript = ./update.sh; llvm = circt-llvm; + sv-lang = circt-sv-lang; }; meta = { diff --git a/pkgs/by-name/ci/circt/sv-lang.nix b/pkgs/by-name/ci/circt/sv-lang.nix new file mode 100644 index 000000000000..7146976e11b6 --- /dev/null +++ b/pkgs/by-name/ci/circt/sv-lang.nix @@ -0,0 +1,68 @@ +# CIRCT depends on a specific sv-lang revision, so pin it separately from nixpkgs' sv-lang. +{ + lib, + stdenv, + fetchFromGitHub, + boost, + catch2_3, + cmake, + ninja, + fmt, + llvmPackages, + mimalloc, + python3, + tomlplusplus, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "circt-sv-lang"; + version = "11.0"; + + src = fetchFromGitHub { + owner = "MikePopoloski"; + repo = "slang"; + rev = "44dc55f99b9c64971893013e7931e643fbedcf23"; + hash = "sha256-tKse5rV5kHZmCOb8Zb8k4bOw4wN3pDfY5exdpva57bU="; + }; + + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ + cmake + ninja + python3 + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # Needed for the wrapped clang-scan-deps to find the C++20 module headers. + llvmPackages.clang-tools + ]; + + buildInputs = [ + boost + catch2_3 + fmt + mimalloc + ]; + + propagatedBuildInputs = [ + tomlplusplus + ]; + + cmakeFlags = [ + # Keep installation paths compatible with the CIRCT build. + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeBool "SLANG_INCLUDE_TESTS" finalAttrs.finalPackage.doCheck) + (lib.cmakeBool "SLANG_USE_SYSTEM_TOMLPLUSPLUS" true) + ]; + + doCheck = true; + + meta = { + description = "SystemVerilog compiler and language services pinned for CIRCT"; + homepage = "https://github.com/MikePopoloski/slang"; + license = lib.licenses.mit; + platforms = lib.platforms.all; + }; +}) diff --git a/pkgs/by-name/ci/circt/update.sh b/pkgs/by-name/ci/circt/update.sh new file mode 100755 index 000000000000..d641c08806b0 --- /dev/null +++ b/pkgs/by-name/ci/circt/update.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env nix-shell +#!nix-shell -I nixpkgs=. -i bash -p bash coreutils gnugrep jq gnused nix nix-prefetch-git nix-prefetch-github common-updater-scripts +# shellcheck shell=bash + +set -euo pipefail + +ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(realpath "$ROOT/../../../..")" +cd "$REPO_ROOT" + +# Make the checkout available to the nested Nix invocations as well. +export NIX_PATH="nixpkgs=$REPO_ROOT${NIX_PATH:+:$NIX_PATH}" + +attrPath="${UPDATE_NIX_ATTR_PATH:-circt}" + +# CIRCT publishes firtool releases as firtool- Git tags. Find the +# highest version rather than relying on the ordering returned by GitHub. +latestVersion=$( + list-git-tags --url=https://github.com/llvm/circt.git | + sed -n 's/^firtool-//p' | + sort --version-sort | + tail -n1 +) +currentVersion="${UPDATE_NIX_OLD_VERSION:-$(nix-instantiate --eval --strict --raw -A "$attrPath.version" .)}" + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "CIRCT is up to date: $currentVersion" + exit 0 +fi + +echo "updating CIRCT from $currentVersion to $latestVersion" +update-source-version "$attrPath" "$latestVersion" + +# Build only the updated source derivation so its CMakeLists.txt can tell us +# which exact slang revision this CIRCT release expects. +src=$(nix-build --no-out-link -A "$attrPath.src") + +# CMakeLists.txt contains several FetchContent declarations and therefore +# several GIT_TAG lines. First isolate the declaration for the slang repository, +# then extract its nearby GIT_TAG. The tag may be followed by a comment or end +# immediately after the revision. +slangRev=$( + grep -A5 "https://github.com/MikePopoloski/slang" "$src/CMakeLists.txt" | + sed -nE 's/.*GIT_TAG[[:space:]]+([0-9a-f]{40}).*/\1/p' | + head -n1 +) +if [[ -z "$slangRev" ]]; then + echo "failed to find slang GIT_TAG in $src/CMakeLists.txt" >&2 + exit 1 +fi + +# Prefetch slang independently because CIRCT's source hash does not cover +# FetchContent dependencies when CIRCT uses a system-provided slang package. +slangHash=$( + nix-prefetch-github MikePopoloski slang --rev "$slangRev" | + jq --exit-status --raw-output .hash +) +currentSlangRev=$(nix-instantiate --eval --strict --raw -A "$attrPath.passthru.sv-lang.src.rev" .) +currentSlangHash=$(nix-instantiate --eval --strict --raw -A "$attrPath.passthru.sv-lang.src.outputHash" .) + +# Keep the private sv-lang override synchronized with the revision declared by +# CIRCT without changing the version of nixpkgs' general sv-lang package. +if [[ "$currentSlangRev" != "$slangRev" || "$currentSlangHash" != "$slangHash" ]]; then + echo "updating slang from $currentSlangRev to $slangRev" + sed -i \ + -e "s|$currentSlangRev|$slangRev|" \ + -e "s|$currentSlangHash|$slangHash|" \ + "$ROOT/sv-lang.nix" +else + echo "slang is up to date: $slangRev" +fi