Unverified Commit e9766716 authored by Luflosi's avatar Luflosi Committed by Jack Leightcap
Browse files

verilog: 11.0 -> 12.0

https://github.com/steveicarus/iverilog/releases/tag/v12_0

Bump `iverilog` to 12.0, fixing two build failures:

1. autoconf now picks up on the unwrapped `x86_64-unknown-gnu-gcc` in
   path that fails at configurePhase to link executables.
   See: https://github.com/NixOS/nixpkgs/issues/21751


   fix/hack: define the `{CC,CXX}_FOR_BUILD` variables.
2. buildPhase generates a `-Werror=format-security` error. Backport
   the the upstream patch that fixed the warning very shortly after the
   release was cut.

And in the process,

- use post-install tests from `.github/test.sh` and as a result,
  remove the now unneeded clone of `ivtest`
- un-pin the verilog autoconf version

Signed-off-by: default avatarJack Leightcap <jack@leightcap.com>
parent 103897b4
Loading
Loading
Loading
Loading
+29 −27
Original line number Diff line number Diff line
{ lib, stdenv
, fetchFromGitHub
, fetchpatch
, autoconf
, bison
, bzip2
@@ -7,56 +8,57 @@
, gperf
, ncurses
, perl
, python3
, readline
, zlib
}:

let
  # iverilog-test has been merged to the main iverilog main source tree
  # in January 2022, so it won't be longer necessary.
  # For now let's fetch it from the separate repo, since 11.0 was released in 2020.
  iverilog-test = fetchFromGitHub {
    owner  = "steveicarus";
    repo   = "ivtest";
    rev    = "a19e629a1879801ffcc6f2e6256ca435c20570f3";
    sha256 = "sha256-3EkmrAXU0/mRxrxp5Hy7C3yWTVK16L+tPqqeEryY/r8=";
  };
in
stdenv.mkDerivation rec {
  pname   = "iverilog";
  version = "11.0";
  version = "12.0";

  src = fetchFromGitHub {
    owner  = "steveicarus";
    repo   = pname;
    rev    = "v${lib.replaceStrings ["."] ["_"] version}";
    sha256 = "0nzcyi6l2zv9wxzsv9i963p3igyjds0n55x0ph561mc3pfbc7aqp";
    hash   = "sha256-J9hedSmC6mFVcoDnXBtaTXigxrSCFa2AhhFd77ueo7I=";
  };

  nativeBuildInputs = [ autoconf bison flex gperf ];

  CC_FOR_BUILD="${stdenv.cc}/bin/cc";
  CXX_FOR_BUILD="${stdenv.cc}/bin/c++";

  patches = [
    # NOTE(jleightcap): `-Werror=format-security` warning patched shortly after release, backport the upstream fix
    (fetchpatch {
      name = "format-security";
      url = "https://github.com/steveicarus/iverilog/commit/23e51ef7a8e8e4ba42208936e0a6a25901f58c65.patch";
      hash = "sha256-fMWfBsCl2fuXe+6AR10ytb8QpC84bXlP5RSdrqsWzEk=";
    })
  ];

  buildInputs = [ bzip2 ncurses readline zlib ];

  preConfigure = "sh autoconf.sh";

  enableParallelBuilding = true;

  nativeInstallCheckInputs = [ perl ];
  doCheck = true;
  doInstallCheck = true;

  installCheckPhase = ''
    # copy tests to allow writing results
    export TESTDIR=$(mktemp -d)
    cp -r ${iverilog-test}/* $TESTDIR

    pushd $TESTDIR
  nativeInstallCheckInputs = [
    perl
    (python3.withPackages (pp: with pp; [
      docopt
    ]))
  ];

    # Run & check tests
    PATH=$out/bin:$PATH perl vvp_reg.pl
    # Check the tests, will error if unexpected tests fail. Some failures MIGHT be normal.
    diff regression_report-devel.txt regression_report.txt
    PATH=$out/bin:$PATH perl vpi_reg.pl

    popd
  installCheckPhase = ''
    runHook preInstallCheck
    export PATH="$PATH:$out/bin"
    sh .github/test.sh
    runHook postInstallCheck
  '';

  meta = with lib; {
+1 −3
Original line number Diff line number Diff line
@@ -13336,9 +13336,7 @@ with pkgs;
  verilator = callPackage ../applications/science/electronics/verilator { };
  verilog = callPackage ../applications/science/electronics/verilog {
    autoconf = buildPackages.autoconf269;
  };
  verilog = callPackage ../applications/science/electronics/verilog { };
  versus = callPackage ../applications/networking/versus { };