From b6e546a7445ec9b07b3ceff4f0179b6b39c2ea76 Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Wed, 15 Oct 2025 14:48:25 +0300 Subject: [PATCH 1/2] chore: prepare yosys pybind11 updates [skip ci] --- flake.nix | 1 + nix/patches/yosys/abc-editline.patch | 14 ------- nix/patches/yosys/new-bitwuzla.patch | 16 -------- nix/patches/yosys/plugin-search-dirs.patch | 46 ---------------------- nix/pybind11_3.nix | 21 ++++++++++ nix/yosys-eqy.nix | 4 +- nix/yosys-sby.nix | 4 +- nix/yosys.nix | 46 ++++++++++++++-------- 8 files changed, 56 insertions(+), 96 deletions(-) delete mode 100644 nix/patches/yosys/abc-editline.patch delete mode 100644 nix/patches/yosys/new-bitwuzla.patch delete mode 100644 nix/patches/yosys/plugin-search-dirs.patch create mode 100644 nix/pybind11_3.nix diff --git a/flake.nix b/flake.nix index 27a834b..e35ce00 100644 --- a/flake.nix +++ b/flake.nix @@ -70,6 +70,7 @@ callPythonPackage = lib.callPackageWith (pkgs' // pypkgs'); in { + pybind11_3 = callPythonPackage ./nix/pybind11_3.nix { }; cocotb = callPythonPackage ./nix/cocotb.nix { ghdl = if (lib.lists.any (el: el == pkgs'.system) pkgs'.ghdl-bin.meta.platforms) then diff --git a/nix/patches/yosys/abc-editline.patch b/nix/patches/yosys/abc-editline.patch deleted file mode 100644 index 65e64f2..0000000 --- a/nix/patches/yosys/abc-editline.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/src/base/main/mainUtils.c b/src/base/main/mainUtils.c -index 245e936a..0a3cde72 100644 ---- a/src/base/main/mainUtils.c -+++ b/src/base/main/mainUtils.c -@@ -22,8 +22,7 @@ - #include "mainInt.h" - - #ifdef ABC_USE_READLINE --#include --#include -+#include - #endif - - ABC_NAMESPACE_IMPL_START diff --git a/nix/patches/yosys/new-bitwuzla.patch b/nix/patches/yosys/new-bitwuzla.patch deleted file mode 100644 index 4dbee74..0000000 --- a/nix/patches/yosys/new-bitwuzla.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py -index 0ec7f08f4..9984bba97 100644 ---- a/backends/smt2/smtio.py -+++ b/backends/smt2/smtio.py -@@ -210,10 +210,7 @@ class SmtIo: - sys.exit(1) - - if self.solver in ["boolector", "bitwuzla"]: -- if self.noincr: -- self.popen_vargs = [self.solver, '--smt2'] + self.solver_opts -- else: -- self.popen_vargs = [self.solver, '--smt2', '-i'] + self.solver_opts -+ self.popen_vargs = [self.solver, '--lang', 'smt2'] + self.solver_opts - self.unroll = True - if self.timeout != 0: - print('timeout option is not supported for %s.' % self.solver) diff --git a/nix/patches/yosys/plugin-search-dirs.patch b/nix/patches/yosys/plugin-search-dirs.patch deleted file mode 100644 index b1b90cd..0000000 --- a/nix/patches/yosys/plugin-search-dirs.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/passes/cmds/plugin.cc b/passes/cmds/plugin.cc -index 08b4aa8c4..1b7639bc9 100644 ---- a/passes/cmds/plugin.cc -+++ b/passes/cmds/plugin.cc -@@ -87,15 +87,34 @@ void load_plugin(std::string filename, std::vector aliases) - - // We were unable to open the file, try to do so from the plugin directory - if (hdl == NULL && orig_filename.find('/') == std::string::npos) { -- hdl = dlopen([orig_filename]() { -- std::string new_path = proc_share_dirname() + "plugins/" + orig_filename; -+ std::string install_dir = proc_share_dirname() + "plugins"; -+ std::vector all_dirs; -+ all_dirs.push_back(install_dir); - -- // Check if we need to append .so -- if (new_path.find(".so") == std::string::npos) -- new_path.append(".so"); -+ char* plugin_dirs = getenv("NIX_YOSYS_PLUGIN_DIRS"); - -- return new_path; -- }().c_str(), RTLD_LAZY|RTLD_LOCAL); -+ if (plugin_dirs != NULL) { -+ std::string p(plugin_dirs), t; -+ std::stringstream ss(p); -+ -+ while(std::getline(ss, t, ':')) { -+ all_dirs.push_back(t); -+ } -+ } -+ -+ for (auto dir : all_dirs) { -+ hdl = dlopen([&]() { -+ std::string new_path = dir + "/" + orig_filename; -+ -+ // Check if we need to append .so -+ if (new_path.find(".so") == std::string::npos) -+ new_path.append(".so"); -+ -+ return new_path; -+ }().c_str(), RTLD_LAZY|RTLD_LOCAL); -+ if (hdl != NULL) -+ break; -+ } - } - - if (hdl == NULL) diff --git a/nix/pybind11_3.nix b/nix/pybind11_3.nix new file mode 100644 index 0000000..e9ff469 --- /dev/null +++ b/nix/pybind11_3.nix @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: MIT +# Copyright (c) 2025 nix-eda Contributors +{ + lib, + fetchPypi, + buildPythonPackage, +}: +buildPythonPackage rec { + pname = "pybind11"; + version = "3.0.1"; + format = "wheel"; + + src = fetchPypi { + pname = "pybind11"; + inherit version; + inherit format; + dist = "py3"; + python = "py3"; + sha256 = "sha256-qo8KpuCpTTtkrfw49WDzPxXlib4hdeEDwKM8a85V7ok="; + }; +} diff --git a/nix/yosys-eqy.nix b/nix/yosys-eqy.nix index d07e83a..c1d0d1f 100644 --- a/nix/yosys-eqy.nix +++ b/nix/yosys-eqy.nix @@ -30,8 +30,8 @@ yosys-sby, python3, makeBinaryWrapper, - version ? "0.54", - sha256 ? "sha256-Km6layPDTAfd6oWnztJRdbiFkJeVT0YU06xWb/ewAms=", + version ? "0.58", + sha256 ? "sha256-bYcFIZRUk72mt0dN8wzpC+91nB+Xo0MXG6kmnzYURR4=", }: yosys.stdenv.mkDerivation (finalAttrs: { pname = "yosys-eqy"; diff --git a/nix/yosys-sby.nix b/nix/yosys-sby.nix index cca2d57..f699a75 100644 --- a/nix/yosys-sby.nix +++ b/nix/yosys-sby.nix @@ -28,8 +28,8 @@ boolector, z3, yices, - version ? "0.54", - sha256 ? "sha256-onVeK23KgCodEoaUtfh3R0MraaXuoNuQ2BAX5k4RNis=", + version ? "0.58", + sha256 ? "sha256-msQ+aqdp8i5KMLUABYU6vA5VBkI6G3zF06RrQzfJucY=", }: yosys.stdenv.mkDerivation (finalAttrs: { pname = "yosys-sby"; diff --git a/nix/yosys.nix b/nix/yosys.nix index 0c13d40..90f80c6 100644 --- a/nix/yosys.nix +++ b/nix/yosys.nix @@ -37,9 +37,11 @@ libffi, zlib, fetchurl, + fetchGitHubSnapshot, bash, - version ? "0.54", - sha256 ? "sha256-meKlZh6ZiiPHwQCvS7Y667lvE9XWgIaual8c6SDpeDw=", + version ? "0.59", + rev ? "e86797f0297ef75826cebdd0e6f4cc51b7c77e0a", + sha256 ? "sha256-08ZxWgYF+orLX6l97BBdYqAJ13Iq0gSex01Zfd8BPzE=", darwin, # To fix codesigning issue for pyosys # For environments yosys, @@ -54,6 +56,8 @@ let }; yosys-python3-env = python3.withPackages ( ps: with ps; [ + cxxheaderparser + pybind11_3 click setuptools wheel @@ -71,13 +75,29 @@ let "python" ]; - src = fetchurl { - url = "https://github.com/YosysHQ/yosys/releases/download/v${version}/yosys.tar.gz"; - inherit sha256; - }; + src = + if rev != null then + fetchGitHubSnapshot { + owner = "yosyshq"; + repo = "yosys"; + inherit rev; + hash = sha256; + } + else + fetchurl { + url = "https://github.com/YosysHQ/yosys/releases/download/v${version}/yosys.tar.gz"; + inherit sha256; + }; unpackPhase = '' - tar -xzvC . -f ${finalAttrs.src} + runHook preUnpack + if [ -d ${finalAttrs.src} ]; then + cp -r ${finalAttrs.src}/* . + chmod u+w -R . + else + tar -xzvC . -f ${finalAttrs.src} --strip-components=1 + fi + runHook postUnpack ''; nativeBuildInputs = [ @@ -92,7 +112,6 @@ let libbsd libffi zlib - boost-python ]; buildInputs = [ @@ -121,15 +140,15 @@ let postBuild = '' cat <