|
1 |
| -# Copyright 2023 Efabless Corporation |
| 1 | +# Copyright 2025 Ciel Contributors |
2 | 2 | #
|
3 | 3 | # Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | # you may not use this file except in compliance with the License.
|
|
13 | 13 | # limitations under the License.
|
14 | 14 | # Code adapated from nixpkgs, original license follows
|
15 | 15 | # ---
|
16 |
| -# Copyright (c) 2003-2023 Eelco Dolstra and the Nixpkgs/NixOS contributors |
| 16 | +# Copyright (c) 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors |
17 | 17 | #
|
18 | 18 | # Permission is hereby granted, free of charge, to any person obtaining
|
19 | 19 | # a copy of this software and associated documentation files (the
|
|
34 | 34 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
35 | 35 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
36 | 36 | {
|
37 |
| - clangStdenv, |
| 37 | + lib, |
| 38 | + stdenv, |
38 | 39 | fetchFromGitHub,
|
39 | 40 | perl,
|
40 |
| - makeWrapper, |
41 | 41 | flex,
|
42 | 42 | bison,
|
43 | 43 | python3,
|
44 | 44 | autoconf,
|
45 |
| - help2man, |
46 | 45 | which,
|
| 46 | + help2man, |
| 47 | + makeWrapper, |
| 48 | + systemc, |
| 49 | + git, |
| 50 | + numactl, |
| 51 | + coreutils, |
| 52 | + gdb, |
47 | 53 | glibcLocales,
|
48 |
| - lib, |
49 |
| - version ? "v5.018", |
| 54 | + version ? "5.038", |
50 | 55 | rev ? null,
|
51 |
| - sha256 ? "sha256-f06UzNw2MQ5me03EPrVFhkwxKum/GLDzQbDNTBsJMJs=", |
| 56 | + sha256 ? "sha256-uPGVE7y3zm+5ZydGjd1+/kIjW+a5u6d+YzjUSE4KnCY=", |
52 | 57 | }:
|
53 |
| -clangStdenv.mkDerivation { |
| 58 | + |
| 59 | +stdenv.mkDerivation rec { |
54 | 60 | pname = "verilator";
|
55 | 61 | inherit version;
|
56 | 62 |
|
| 63 | + # Verilator gets the version from this environment variable |
| 64 | + # if it can't do git describe while building. |
| 65 | + VERILATOR_SRC_VERSION = "v${version}"; |
| 66 | + |
57 | 67 | src = fetchFromGitHub {
|
58 | 68 | owner = "verilator";
|
59 | 69 | repo = "verilator";
|
60 | 70 | rev =
|
61 | 71 | if rev == null
|
62 |
| - then version |
| 72 | + then "v${version}" |
63 | 73 | else rev;
|
64 | 74 | inherit sha256;
|
65 | 75 | };
|
66 | 76 |
|
67 | 77 | enableParallelBuilding = true;
|
68 |
| - buildInputs = [perl]; |
69 |
| - nativeBuildInputs = [makeWrapper flex bison python3 autoconf help2man]; |
70 |
| - nativeCheckInputs = [which]; |
| 78 | + buildInputs = [ |
| 79 | + perl |
| 80 | + systemc |
| 81 | + (python3.withPackages ( |
| 82 | + pp: with pp; [ |
| 83 | + distro |
| 84 | + ] |
| 85 | + )) |
| 86 | + # ccache |
| 87 | + ]; |
| 88 | + nativeBuildInputs = [ |
| 89 | + makeWrapper |
| 90 | + flex |
| 91 | + bison |
| 92 | + autoconf |
| 93 | + help2man |
| 94 | + git |
| 95 | + ] |
| 96 | + ++ lib.optionals stdenv.hostPlatform.isLinux [ |
| 97 | + gdb |
| 98 | + ]; |
| 99 | + |
| 100 | + nativeCheckInputs = [ |
| 101 | + which |
| 102 | + coreutils |
| 103 | + # cmake |
| 104 | + python3 |
| 105 | + ] |
| 106 | + ++ lib.optionals stdenv.hostPlatform.isLinux [ |
| 107 | + numactl |
| 108 | + ]; |
| 109 | + |
| 110 | + doCheck = true; |
| 111 | + checkTarget = "test"; |
71 | 112 |
|
72 | 113 | preConfigure = "autoconf";
|
73 | 114 |
|
74 | 115 | postPatch = ''
|
75 |
| - patchShebangs bin/* src/{flexfix,vlcovgen} |
| 116 | + patchShebangs bin/* src/* nodist/* docs/bin/* examples/xml_py/* \ |
| 117 | + test_regress/{driver.py,t/*.{pl,pf}} \ |
| 118 | + test_regress/t/t_a1_first_cc.py \ |
| 119 | + test_regress/t/t_a2_first_sc.py \ |
| 120 | + ci/* ci/docker/run/* ci/docker/run/hooks/* ci/docker/buildenv/build.sh |
| 121 | + # verilator --gdbbt uses /bin/echo to test if gdb works. |
| 122 | + substituteInPlace bin/verilator --replace-fail "/bin/echo" "${coreutils}/bin/echo" |
| 123 | + ''; |
| 124 | + # grep '^#!/' -R . | grep -v /nix/store | less |
| 125 | + # (in nix-shell after patchPhase) |
| 126 | + |
| 127 | + # This is needed to ensure that the check phase can find the verilator_bin_dbg. |
| 128 | + preCheck = '' |
| 129 | + export PATH=$PWD/bin:$PATH |
76 | 130 | '';
|
77 | 131 |
|
78 |
| - postInstall = lib.optionalString clangStdenv.isLinux '' |
| 132 | + env = { |
| 133 | + SYSTEMC_INCLUDE = "${lib.getDev systemc}/include"; |
| 134 | + SYSTEMC_LIBDIR = "${lib.getLib systemc}/lib"; |
| 135 | + }; |
| 136 | + |
| 137 | + postInstall = lib.optionalString stdenv.isLinux '' |
79 | 138 | for x in $(ls $out/bin/verilator*); do
|
80 | 139 | wrapProgram "$x" --set LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive"
|
81 | 140 | done
|
82 | 141 | '';
|
83 | 142 |
|
84 |
| - doCheck = false; |
85 |
| - |
86 | 143 | meta = with lib; {
|
87 | 144 | description = "Fast and robust (System)Verilog simulator/compiler and linter";
|
88 | 145 | homepage = "https://www.veripool.org/verilator";
|
89 |
| - license = with licenses; [lgpl3Only artistic2]; |
| 146 | + license = with licenses; [ |
| 147 | + lgpl3Only |
| 148 | + artistic2 |
| 149 | + ]; |
90 | 150 | platforms = platforms.unix;
|
91 | 151 | };
|
92 | 152 | }
|
0 commit comments