Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
donn committed Dec 6, 2024
1 parent d5b8565 commit 6e276a8
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 40 deletions.
17 changes: 11 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
{
description = "open-source infrastructure for implementing chip design flows";

nixConfig = {
extra-substituters = [
"https://openlane.cachix.org"
Expand Down Expand Up @@ -54,13 +54,17 @@
default = lib.composeManyExtensions [
(import ./nix/overlay.nix)
(nix-eda.flakesToOverlay [libparse ioplace-parser volare])
(pkgs': pkgs: {
yosys-sby = (pkgs.yosys-sby.override { sha256 = "sha256-Il2pXw2doaoZrVme2p0dSUUa8dCQtJJrmYitn1MkTD4="; });
})
(
pkgs': pkgs: let
callPackage = lib.callPackageWith pkgs';
in {
or-tools_9_11 = callPackage ./nix/or-tools_9_11.nix {
inherit (pkgs'.darwin) DarwinTools;
clangStdenv =
if pkgs'.system == "x86_64-darwin"
then (pkgs'.overrideSDK pkgs'.clangStdenv "11.0")
else pkgs'.clangStdenv;
};
colab-env = callPackage ./nix/colab-env.nix {};
opensta = callPackage ./nix/opensta.nix {};
openroad-abc = callPackage ./nix/openroad-abc.nix {};
Expand Down Expand Up @@ -112,8 +116,9 @@

packages = nix-eda.forAllSystems (
system: let
pkgs = (self.legacyPackages."${system}");
in {
pkgs = self.legacyPackages."${system}";
in
{
inherit (pkgs) colab-env opensta openroad-abc openroad;
inherit (pkgs.python3.pkgs) openlane;
default = pkgs.python3.pkgs.openlane;
Expand Down
12 changes: 8 additions & 4 deletions nix/create-shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
extra-packages ? [],
extra-python-packages ? [],
openlane-plugins ? [],
include-openlane ? true
include-openlane ? true,
}: ({
lib,
git,
Expand All @@ -31,9 +31,13 @@
openlane = python3.pkgs.openlane;
openlane-env = (
python3.withPackages (pp:
(if include-openlane then [openlane] else openlane.propagatedBuildInputs)
++ extra-python-packages
++ openlane-plugins)
(
if include-openlane
then [openlane]
else openlane.propagatedBuildInputs
)
++ extra-python-packages
++ openlane-plugins)
);
openlane-env-sitepackages = "${openlane-env}/${openlane-env.sitePackages}";
pluginIncludedTools = lib.lists.flatten (map (n: n.includedTools) openlane-plugins);
Expand Down
21 changes: 10 additions & 11 deletions nix/openroad.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Efabless Corporation
# Copyright 2023-2024 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,7 +29,7 @@
libffi,
llvmPackages,
lemon-graph,
or-tools,
or-tools_9_11,
glpk,
zlib,
clp,
Expand All @@ -52,7 +52,8 @@
buildPythonEnvForInterpreter,
}: let
stdenv = llvmPackages_17.stdenv;
self = stdenv.mkDerivation (finalAttrs: {
in
stdenv.mkDerivation (finalAttrs: {
name = "openroad";
inherit rev;

Expand All @@ -62,8 +63,8 @@
inherit rev;
inherit sha256;
};
patches = [ ./patches/openroad/patches.diff ];

patches = [./patches/openroad/patches.diff];

cmakeFlagsAll = [
"-DTCL_LIBRARY=${tcl}/lib/libtcl${stdenv.hostPlatform.extensions.sharedLibrary}"
Expand Down Expand Up @@ -110,13 +111,13 @@
llvmPackages.openmp

lemon-graph
or-tools
opensta
glpk
zlib
clp
cbc
re2

or-tools_9_11
];

nativeBuildInputs = [
Expand All @@ -132,7 +133,7 @@
];

shellHook = ''
alias ord-format-changed="${git}/bin/git diff --name-only | grep -E '\.(cpp|cc|c|h|hh)$' | xargs clang-format -i -style=file:.clang-format";
alias ord-format-changed="${git}/bin/git diff --name-only | grep -E '\.(cpp|cc|c|h|hh)$' | xargs clang-format -i -style=file:.clang-format";
alias ord-cmake-debug="cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-g" -G Ninja $cmakeFlags .."
alias ord-cmake-release="cmake -DCMAKE_BUILD_TYPE=Release -G Ninja $cmakeFlags .."
'';
Expand All @@ -155,6 +156,4 @@
license = licenses.gpl3Plus;
platforms = platforms.linux ++ platforms.darwin;
};
});
in
self
})
144 changes: 144 additions & 0 deletions nix/or-tools_9_11.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Copyright 2024 Efabless Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
# ---
# Original license follows:
#
# Copyright (c) 2003-2024 Eelco Dolstra and the Nixpkgs/NixOS contributors
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
{
abseil-cpp,
bzip2,
cbc,
cmake,
DarwinTools, # sw_vers
eigen,
ensureNewerSourcesForZipFilesHook,
fetchFromGitHub,
glpk,
lib,
pkg-config,
protobuf,
re2,
clangStdenv,
swig,
unzip,
zlib,
highs,
}:
clangStdenv.mkDerivation (finalAttrs: {
pname = "or-tools";
version = "9.11";

src = fetchFromGitHub {
owner = "google";
repo = "or-tools";
rev = "v${finalAttrs.version}";
hash = "sha256-aRhUAs9Otvra7VPJvrf0fhDCGpYhOw1//BC4dFJ7/xI=";
};

cmakeFlags =
[
"-DBUILD_DEPS=OFF"
"-DBUILD_absl=OFF"
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DUSE_GLPK=ON"
"-DUSE_SCIP=OFF"
"-DPROTOC_PRG=${protobuf}/bin/protoc"
]
++ lib.optionals clangStdenv.hostPlatform.isDarwin ["-DCMAKE_MACOSX_RPATH=OFF"];

strictDeps = true;

nativeBuildInputs =
[
cmake
ensureNewerSourcesForZipFilesHook
pkg-config
swig
unzip
]
++ lib.optionals clangStdenv.hostPlatform.isDarwin [
DarwinTools
];

buildInputs = [
abseil-cpp
bzip2
cbc
eigen
glpk
zlib
];

propagatedBuildInputs = [
abseil-cpp
protobuf
re2
highs
];

env.NIX_CFLAGS_COMPILE = toString [
# fatal error: 'python/google/protobuf/proto_api.h' file not found
"-I${protobuf.src}"
];

# some tests fail on linux and hang on darwin
doCheck = false;

preCheck = ''
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH''${LD_LIBRARY_PATH:+:}$PWD/lib
'';

# This extra configure step prevents the installer from littering
# $out/bin with sample programs that only really function as tests,
# and disables the upstream installation of a zipped Python egg that
# can’t be imported with our Python setup.
installPhase = ''
cmake . -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=OFF -DBUILD_SAMPLES=OFF
cmake --install .
'';

outputs = ["out"];

meta = {
homepage = "https://github.com/google/or-tools";
license = lib.licenses.asl20;
description = ''
Google's software suite for combinatorial optimization.
'';
mainProgram = "fzn-ortools";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
};
})
19 changes: 0 additions & 19 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ new: old: {
}))
else (old.clp);

## Clang 16's Default is C++17, which cbc does not support
cbc =
if (old.stdenv.isDarwin)
then
old.cbc.overrideAttrs
(finalAttrs: previousAttrs: {
configureFlags = previousAttrs.configureFlags ++ ["CXXFLAGS=-std=c++14"];
})
else (old.cbc);

## Clang 16 breaks Jshon
jshon =
if (old.stdenv.isDarwin)
Expand All @@ -35,13 +25,4 @@ new: old: {
stdenv = old.gccStdenv;
}
else (old.jshon);

## Alligned alloc not available on the default SDK for x86_64-darwin (10.12!!)
or-tools =
if old.system == "x86_64-darwin"
then
(old.or-tools.override {
stdenv = old.overrideSDK old.stdenv "11.0";
})
else (old.or-tools);
}

0 comments on commit 6e276a8

Please sign in to comment.