diff --git a/.gitignore b/.gitignore index a1a532d..6f5d014 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ verilator-3.803.tgz /verilator-4.226.tar.gz /verilator-5.014.tar.gz /verilator-5.020.tar.gz +/verilator-5.022.tar.gz diff --git a/0001-fix-try-lock-spuriously-fails.patch b/0001-fix-try-lock-spuriously-fails.patch new file mode 100644 index 0000000..018e577 --- /dev/null +++ b/0001-fix-try-lock-spuriously-fails.patch @@ -0,0 +1,27 @@ +commit 01dadb0a8d1c86493d310f400a084fa899915edb +Author: Kamil Rakoczy +Date: Fri Mar 1 21:29:13 2024 +0100 + + Fix try-lock spuriously fails (#4931) (#4938) + +diff --git a/src/V3ThreadPool.h b/src/V3ThreadPool.h +index 2d552c10a..09b2ba17c 100644 +--- a/src/V3ThreadPool.h ++++ b/src/V3ThreadPool.h +@@ -139,7 +139,15 @@ class V3ThreadPool final { + std::abort(); + } + +- if (VL_UNCOVERABLE(!m_mutex.try_lock())) { ++ bool m_mutex_locked = m_mutex.try_lock(); ++ // try_lock can sometimes spontaneously fail even when mutex is not locked, ++ // make sure this isn't the case ++ for (int i = 0; i < VL_LOCK_SPINS; ++i) { ++ if (VL_LIKELY(m_mutex_locked)) break; ++ VL_CPU_RELAX(); ++ m_mutex_locked = m_mutex.try_lock(); ++ } ++ if (VL_UNCOVERABLE(!m_mutex_locked)) { + if (VL_UNCOVERABLE(m_jobsInProgress != 0)) { + // ThreadPool shouldn't be destroyed when jobs are running and mutex is locked, + // something is wrong. Most likely Verilator is exiting as a result of failed diff --git a/0002-Allow-for-custom-verilator-revision-in-version-check.patch b/0002-Allow-for-custom-verilator-revision-in-version-check.patch new file mode 100644 index 0000000..dad2486 --- /dev/null +++ b/0002-Allow-for-custom-verilator-revision-in-version-check.patch @@ -0,0 +1,35 @@ +commit 04512e5d0484f26b75cf7386facceb929fbf2536 +Author: Nolan Poe +Date: Sat Mar 9 13:44:25 2024 -0800 + + Add custom version for verilator --version packaging (#4954) + +diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS +index fa22f84fd..82e6160b6 100644 +--- a/docs/CONTRIBUTORS ++++ b/docs/CONTRIBUTORS +@@ -136,6 +136,7 @@ Mostafa Gamal + Nandu Raj + Nathan Kohagen + Nathan Myers ++Nolan Poe + Oleh Maksymenko + Patrick Stewart + Paul Swirhun +diff --git a/src/config_rev b/src/config_rev +index 0640d85b1..bbbcf9b3f 100755 +--- a/src/config_rev ++++ b/src/config_rev +@@ -22,7 +22,11 @@ Args = parser.parse_args() + + os.chdir(Args.directory) + +-rev = 'UNKNOWN_REV' ++if 'VERILATOR_SRC_VERSION' in os.environ: ++ rev = os.environ['VERILATOR_SRC_VERSION'] ++else: ++ rev = 'UNKNOWN_REV' ++ + data = os.popen('git describe').read() + + match = re.search(r'^(v[0-9].*)', data) diff --git a/0003-Enable-optimization-in-tests.patch b/0003-Enable-optimization-in-tests.patch new file mode 100644 index 0000000..198eb51 --- /dev/null +++ b/0003-Enable-optimization-in-tests.patch @@ -0,0 +1,15 @@ +diff --git a/test_regress/driver.pl b/test_regress/driver.pl +index 1e643ec83..7430a9c26 100755 +--- a/test_regress/driver.pl ++++ b/test_regress/driver.pl +@@ -1254,8 +1254,8 @@ sub compile { + "TEST_OBJ_DIR=$self->{obj_dir}", + "CPPFLAGS_DRIVER=-D" . uc($self->{name}), + ($self->{verbose} ? "CPPFLAGS_DRIVER2=-DTEST_VERBOSE=1" : ""), +- ($param{benchmark} ? "" : "OPT_FAST=-O0"), +- ($param{benchmark} ? "" : "OPT_GLOBAL=-O0"), ++ ($param{benchmark} ? "" : "OPT_FAST=-O1"), ++ ($param{benchmark} ? "" : "OPT_GLOBAL=-O1"), + "$self->{vm_prefix}", # bypass default rule, as we don't need archive + ($param{make_flags} || ""), + ]); diff --git a/0004-Fix-GCC14-warnings-on-template-specialization-syntax.patch b/0004-Fix-GCC14-warnings-on-template-specialization-syntax.patch new file mode 100644 index 0000000..1551690 --- /dev/null +++ b/0004-Fix-GCC14-warnings-on-template-specialization-syntax.patch @@ -0,0 +1,49 @@ +commit 08c76b1da6e132b1e91f82136a8647f71f774904 +Author: Nolan Poe +Date: Fri Mar 15 19:21:08 2024 -0700 + + Fix GCC14 warnings on template specialization syntax (#4974) (#4975) + +diff --git a/src/V3OptionParser.cpp b/src/V3OptionParser.cpp +index b1855c462..e0d7fbd04 100644 +--- a/src/V3OptionParser.cpp ++++ b/src/V3OptionParser.cpp +@@ -114,16 +114,33 @@ V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbCall, void(void), m_cb(), en::NONE); + V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbFOnOff, void(bool), m_cb(!hasPrefixFNo(optp)), + en::FONOFF); + V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbOnOff, void(bool), m_cb(!hasPrefixNo(optp)), en::ONOFF); +-template <> +-V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbVal, void(int), m_cb(std::atoi(argp)), en::VALUE); +-template <> +-V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbVal, void(const char*), m_cb(argp), +- en::VALUE); + V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbPartialMatch, void(const char*), m_cb(optp), en::NONE, + true); + V3OPTION_PARSER_DEF_ACT_CB_CLASS(ActionCbPartialMatchVal, void(const char*, const char*), + m_cb(optp, argp), en::VALUE, true); + ++template <> ++class V3OptionParser::Impl::ActionCbVal final : public ActionBase { ++ std::function m_cb; ++ ++public: ++ using CbType = std::function; ++ explicit ActionCbVal(CbType cb) ++ : m_cb(std::move(cb)) {} ++ void exec(const char* optp, const char* argp) override { m_cb(std::atoi(argp)); } ++}; ++ ++template <> ++class V3OptionParser::Impl::ActionCbVal final : public ActionBase { ++ std::function m_cb; ++ ++public: ++ using CbType = std::function; ++ explicit ActionCbVal(CbType cb) ++ : m_cb(std::move(cb)) {} ++ void exec(const char* optp, const char* argp) override { m_cb(argp); } ++}; ++ + #undef V3OPTION_PARSER_DEF_ACT_CB_CLASS + + //###################################################################### diff --git a/sources b/sources index e79f560..ce6a1fe 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (verilator-5.020.tar.gz) = 63f4ca6f7aad9c03b50c4040480ed0abdbcfed5f2fc9ce0994dc02a5078daa003d592314a778ab847ac100486038f75ab151d55eaa02d60f979af177ca1dd34e +SHA512 (verilator-5.022.tar.gz) = 5b919ed5d4cf863434f10f39bbb3a5155d63f79765f5f1d5ae543023b0e350e0996507d250fbfb2e5129bbdf9a51cc5fd0b7154962747c89435648897525bc84 diff --git a/verilator.spec b/verilator.spec index 70f9531..b3eb7c9 100644 --- a/verilator.spec +++ b/verilator.spec @@ -1,13 +1,44 @@ +# Blocked by perl-parallel-forker not being packaged +# https://bugzilla.redhat.com/show_bug.cgi?id=2268659 +%bcond longtests 0 + +# A warning caused by glibc in F38 fails build +%if 0%{?fedora} == 38 + %ifarch ppc64le + %bcond ccwarn 0 + %endif +%else +%bcond ccwarn 1 +%endif + +%bcond tcmalloc 0 +%bcond ccache 0 +%bcond mold 0 + Name: verilator -Version: 5.020 +Version: 5.022 Release: %autorelease Summary: A fast simulator for synthesizable Verilog -License: LGPLv3 or Artistic 2.0 +License: LGPL-3.0-only OR Artistic-2.0 URL: https://veripool.org/verilator/ Source0: https://github.com/verilator/verilator/archive/refs/tags/v%{version}/%{name}-%{version}.tar.gz + +# Backported from upstream to fix building +Patch0: 0001-fix-try-lock-spuriously-fails.patch + +# Accepted upstream through GitHub, awaiting release +Patch1: 0002-Allow-for-custom-verilator-revision-in-version-check.patch + +# Undesirable upstream, fixes warnings with FORTIFY_SOURCE +Patch2: 0003-Enable-optimization-in-tests.patch + +# Accepted upstream through GitHub, awaiting release +Patch3: 0004-Fix-GCC14-warnings-on-template-specialization-syntax.patch + BuildRequires: autoconf BuildRequires: bison BuildRequires: coreutils +BuildRequires: cmake BuildRequires: findutils BuildRequires: flex BuildRequires: gcc @@ -29,10 +60,35 @@ BuildRequires: perl(Time::HiRes) BuildRequires: perl(vars) BuildRequires: python3-devel BuildRequires: sed +%if %{with tcmalloc} +BuildRequires: gperftools-libs +BuildRequires: gperftools-devel +%endif +%if %{with mold} +Requires: mold +%endif +%if %{with ccache} +BuildRequires: ccache +%endif # required for further tests BuildRequires: gdb +# Initial entrypoint needs perl +Requires: perl-interpreter + +# Optional deps +%if %{with tcmalloc} +Requires: gperftools-libs +%endif +%if %{with ccache} +Requires: ccache +%endif +# NOTE: currently fails on ppc64le +%if %{with mold} +Requires: mold +%endif + %description Verilator is the fastest free Verilog HDL simulator. It compiles synthesizable Verilog, plus some PSL, SystemVerilog and Synthesis @@ -42,14 +98,23 @@ especially well suited to create executable models of CPUs for embedded software design teams. %prep -%autosetup +%autosetup -p1 find . -name .gitignore -delete export VERILATOR_ROOT=%{_datadir} autoconf -%{configure} \ - --disable-ccwarn \ +%configure \ + --disable-partial-static \ --enable-defenv \ +%ifarch %{with ccwarn} + --enable-ccwarn \ +%else + --disable-ccwarn \ +%endif +%if %{with longtests} + --enable-longtests +%else --disable-longtests +%endif # We cannot run autoreconf because upstream uses unqualifed stdlib identifiers # that are included by autoconf-generated header files. @@ -59,10 +124,11 @@ find -name Makefile_obj -exec sed -i \ {} \; %build -%make_build +export VERILATOR_SRC_VERSION=fedora-%{version} +%make_build %check -make test +make test %install %make_install