Commit a83ae395 authored by Gon Solo's avatar Gon Solo
Browse files

openroad: 2.0-unstable-2025-03-01 -> 26Q1



Co-authored-by: default avatarGaétan Lepage <gaetan@glepage.com>
Co-authored-by: default avatarNick Cao <nickcao@nichi.co>
parent 1677703a
Loading
Loading
Loading
Loading
+40 −31
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  stdenv,
  fetchFromGitHub,
  yaml-cpp,

  # nativeBuildInputs
  bison,
@@ -13,12 +14,13 @@
  libsForQt5,
  pkg-config,
  swig,
  versionCheckHook,

  # buildInputs
  boost186, # 1.87.0 broken https://github.com/boostorg/asio/issues/442
  cbc, # for clp
  boost,
  cbc,
  cimg,
  clp, # for or-tools
  clp,
  cudd,
  eigen,
  glpk,
@@ -28,7 +30,7 @@
  or-tools,
  pcre,
  python3,
  re2, # for or-tools
  re2,
  readline,
  spdlog,
  tcl,
@@ -39,16 +41,16 @@
  llvmPackages,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "openroad";
  version = "2.0-unstable-2025-03-01";
  version = "26Q1";

  src = fetchFromGitHub {
    owner = "The-OpenROAD-Project";
    repo = "OpenROAD";
    rev = "e794373d44ac5421f0633d8dda7e5c59e8fe79bf";
    tag = finalAttrs.version;
    fetchSubmodules = true;
    hash = "sha256-a/X4FHkbiqHeblse2ZkLT56gYP+LCrAIZVCdsWF59jM=";
    hash = "sha256-DMyoqDse9W6ahOajEINzFpgLsSKam/I1mQkRSSKepI8=";
  };

  nativeBuildInputs = [
@@ -64,7 +66,7 @@ stdenv.mkDerivation rec {
  ];

  buildInputs = [
    boost186
    boost
    cbc
    cimg
    clp
@@ -88,63 +90,70 @@ stdenv.mkDerivation rec {
    tclPackages.tclreadline
    yosys
    zlib
    yaml-cpp
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [ xorg.libX11 ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [ llvmPackages.openmp ];

  postPatch = ''
    patchShebangs --build etc/find_messages.py
    # Disable two tests that are failing curently.
    sed 's/^.*partition_gcd/# \0/g' -i src/par/test/CMakeLists.txt
    # fix build with gcc15
    patchShebangs etc/

    # C++20 Fixes
    sed -e '39i #include <cstdint>' -i src/gpl/src/placerBase.h
    sed -e '37i #include <cstdint>' -i src/gpl/src/routeBase.h
  ''
  # Disable failing PSM tests on aarch64
  + lib.optionalString stdenv.hostPlatform.isAarch64 ''
    if [ -f src/psm/test/CMakeLists.txt ]; then
      echo "Patching PSM tests for aarch64..."
      sed -i -E 's/^[[:space:]]+(gcd_all_vss|gcd_em_test_vdd|insert_decap1|insert_decap_with_padding1)/    # \1/' src/psm/test/CMakeLists.txt
    fi
  '';

  cmakeFlags = [
    (lib.cmakeBool "ENABLE_TESTS" true)
    # Disable tests on Darwin to avoid discovery timeouts during build
    (lib.cmakeBool "ENABLE_TESTS" finalAttrs.finalPackage.doCheck)
    (lib.cmakeBool "USE_SYSTEM_BOOST" true)
    (lib.cmakeBool "USE_SYSTEM_ABC" false)
    (lib.cmakeBool "ABC_SKIP_TESTS" true) # it attempts to download gtest
    (lib.cmakeBool "ABC_SKIP_TESTS" true)
    (lib.cmakeBool "USE_SYSTEM_OPENSTA" false)
    (lib.cmakeFeature "OPENROAD_VERSION" "${version}_${src.rev}")
    (lib.cmakeFeature "OPENROAD_VERSION" finalAttrs.version)
    (lib.cmakeBool "CMAKE_RULE_MESSAGES" false)
    (lib.cmakeFeature "TCL_HEADER" "${tcl}/include/tcl.h")
    (lib.cmakeFeature "TCL_LIBRARY" "${tcl}/lib/libtcl${stdenv.hostPlatform.extensions.sharedLibrary}")
    (lib.cmakeFeature "BOOST_ROOT" "${boost}")
  ]
  ++ lib.optionals stdenv.hostPlatform.isDarwin [
    (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED")
    (lib.cmakeFeature "CMAKE_CXX_FLAGS" "-DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED -Wno-error=deprecated-declarations")
  ];

  # Resynthesis needs access to the Yosys binaries.
  qtWrapperArgs = [ "--prefix PATH : ${lib.makeBinPath [ yosys ]}" ];

  # Upstream uses vendored package versions for some dependencies, so regression testing is prudent
  # to see if there are any breaking changes in unstable that should be vendored as well.
  doCheck = !stdenv.hostPlatform.isDarwin; # it seems to hang on darwin
  # Some tests are unstable on Darwin
  doCheck = !stdenv.hostPlatform.isDarwin;

  checkPhase = ''
    runHook preCheck
    make test
    ../test/regression
    runHook postCheck
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    runHook preInstallCheck

    $out/bin/openroad -version
    $out/bin/sta -version
  nativeInstallCheckInputs = [
    versionCheckHook
  ];

    runHook postInstallCheck
  '';
  doInstallCheck = true;
  versionCheckProgramArg = "-version";

  meta = {
    description = "OpenROAD's unified application implementing an RTL-to-GDS flow";
    homepage = "https://theopenroadproject.org";
    license = lib.licenses.bsd3;
    mainProgram = "openroad";
    maintainers = with lib.maintainers; [
      trepetti
      hzeller
    ];
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}
})