Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libabc: add new libabc package #30566

Closed
wants to merge 3 commits into from
Closed

Libabc: add new libabc package #30566

wants to merge 3 commits into from

Conversation

kquick
Copy link
Contributor

@kquick kquick commented Oct 19, 2017

Motivation for this change

Adds new package to provide the libabc library for other applications to link against.

Replaces pull request #27198
Depends on pull request #30565

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
    N/A
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
    N/A
  • Tested execution of all binary files (usually in ./result/bin/)
    N/A
  • Fits CONTRIBUTING.md.

Existing abc-verifier installs only the binary; this parallel package
installs the library under the name that matches the existing
conventions for library/package name association.
@kquick
Copy link
Contributor Author

kquick commented Oct 19, 2017

cc @thoughtpolice for review

sha256 = "09yvhj53af91nc54gmy7cbp7yljfcyj68a87494r5xvdfnsj11gy";
};

buildInputs = [ ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I was being explicit, but I can remove that and update this pull request shortly.

@kquick
Copy link
Contributor Author

kquick commented Oct 19, 2017

@vyp: extraneous line removed.

@Mic92
Copy link
Member

Mic92 commented Oct 19, 2017

what do you think about the following approach (building library and verifier in one go)?

From 847e8076b56db66dd61354e8e4c1bd44cd24624a Mon Sep 17 00:00:00 2001
From: Joerg Thalheim <joerg@thalheim.io>
Date: Thu, 19 Oct 2017 12:05:42 +0100
Subject: [PATCH] abc: build verifier and library in one package

Signed-off-by: Joerg Thalheim <joerg@thalheim.io>
---
 pkgs/applications/science/logic/abc/default.nix    | 23 +++++++------
 pkgs/applications/science/logic/abc/libabc.nix     | 40 ----------------------
 .../science/logic/abc/shared-library.patch         | 11 ++++++
 pkgs/top-level/all-packages.nix                    |  3 +-
 4 files changed, 25 insertions(+), 52 deletions(-)
 delete mode 100644 pkgs/applications/science/logic/abc/libabc.nix
 create mode 100644 pkgs/applications/science/logic/abc/shared-library.patch

diff --git a/pkgs/applications/science/logic/abc/default.nix b/pkgs/applications/science/logic/abc/default.nix
index bab9b302d7d..b95d6963652 100644
--- a/pkgs/applications/science/logic/abc/default.nix
+++ b/pkgs/applications/science/logic/abc/default.nix
@@ -1,7 +1,7 @@
-{ fetchhg, stdenv, readline }:
+{ fetchhg, stdenv, cmake, readline }:
 
 stdenv.mkDerivation rec {
-  name = "abc-verifier-${version}";
+  name = "abc-${version}";
   version = "20160818";
 
   src = fetchhg {
@@ -10,21 +10,24 @@ stdenv.mkDerivation rec {
     sha256 = "09yvhj53af91nc54gmy7cbp7yljfcyj68a87494r5xvdfnsj11gy";
   };
 
-  buildInputs = [ readline ];
-  preBuild = ''
-    export buildFlags="CC=$CC CXX=$CXX LD=$CXX"
+  buildInputs = [ cmake readline ];
+
+  patches = [ ./shared-library.patch ];
+
+  postBuild = ''
+    make libabc
   '';
-  enableParallelBuilding = true;
+
   installPhase = ''
-    mkdir -p $out/bin
-    mv abc $out/bin
+    install -D abc $out/bin/abc
+    install -D libabc.so $out/lib/libabc.so
   '';
 
   meta = {
-    description = "A tool for squential logic synthesis and formal verification";
+    description = "A library for sequential logic synthesis and formal verification";
     homepage    = "https://people.eecs.berkeley.edu/~alanmi/abc/abc.htm";
     license     = stdenv.lib.licenses.mit;
     platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
+    maintainers = [ stdenv.lib.maintainers.kquick ];
   };
 }
diff --git a/pkgs/applications/science/logic/abc/libabc.nix b/pkgs/applications/science/logic/abc/libabc.nix
deleted file mode 100644
index 9b2efd1b5ab..00000000000
--- a/pkgs/applications/science/logic/abc/libabc.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ fetchhg, stdenv, pkgs }:
-
-stdenv.mkDerivation rec {
-
-  # Note that this derivation provides only the library, but under the
-  # "abc" name, to associate with libabc, which conforms to the
-  # standard library dependency referencing nomenclature.  The binary
-  # is available as a separate package with the "abc-verifier" naming.
-
-  name = "abc-${version}";
-  version = "20160818";
-
-  src = fetchhg {
-    url    = "https://bitbucket.org/alanmi/abc";
-    rev    = "a2e5bc66a68a72ccd267949e5c9973dd18f8932a";
-    sha256 = "09yvhj53af91nc54gmy7cbp7yljfcyj68a87494r5xvdfnsj11gy";
-  };
-
-  preBuild = ''
-    export buildFlags="CC=$CC CXX=$CXX LD=$CXX ABC_USE_NO_READLINE=1 libabc.a"
-  '';
-
-  # n.b. the following are documented, but libabc.so is not a valid make target:
-  # ABC_USE_PIC=1 libabc.so
-
-  enableParallelBuilding = true;
-  installPhase = ''
-    mkdir -p $out/lib
-    mv libabc.a $out/lib
-    # mv libabc.so $out/lib
-  '';
-
-  meta = {
-    description = "A library for sequential logic synthesis and formal verification";
-    homepage    = "https://people.eecs.berkeley.edu/~alanmi/abc/abc.htm";
-    license     = stdenv.lib.licenses.mit;
-    platforms   = stdenv.lib.platforms.unix;
-    maintainers = [ stdenv.lib.maintainers.kquick ];
-  };
-}
diff --git a/pkgs/applications/science/logic/abc/shared-library.patch b/pkgs/applications/science/logic/abc/shared-library.patch
new file mode 100644
index 00000000000..8954c36b560
--- /dev/null
+++ b/pkgs/applications/science/logic/abc/shared-library.patch
@@ -0,0 +1,11 @@
+--- hg-archive-org/CMakeLists.txt	2017-10-19 11:25:32.940200041 +0100
++++ hg-archive/CMakeLists.txt	2017-10-19 11:32:20.239750726 +0100
+@@ -93,7 +93,7 @@
+ 
+ list(REMOVE_ITEM ABC_SRC src/base/main/main.c)
+ 
+-add_library(libabc EXCLUDE_FROM_ALL ${ABC_SRC})
++add_library(libabc SHARED EXCLUDE_FROM_ALL ${ABC_SRC})
+ abc_properties(libabc PUBLIC)
+ set_property(TARGET libabc PROPERTY OUTPUT_NAME abc)
+ 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 12d57f556b2..2e2d8d0ceb2 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -18481,8 +18481,7 @@ with pkgs;
 
   ### SCIENCE/LOGIC
 
-  abc = callPackage ../applications/science/logic/abc/libabc.nix {};
-  abc-verifier = callPackage ../applications/science/logic/abc {};
+  abc = callPackage ../applications/science/logic/abc {};
 
   abella = callPackage ../applications/science/logic/abella {};
 
-- 
2.14.2

@kquick
Copy link
Contributor Author

kquick commented Oct 19, 2017

@Mic92, my preference would be for the original form for the following reasons:

  1. Your proposed change would involve changing the name of an existing package, which could have unintended consequences beyond the scope of just this repository.
  2. The needs for the library or for the executable are separate and distinct. For my purposes, I do not use the abc-verifier package, but I do need to link to the library. This is akin to Redhat's practice of creating "foo-devel" packages.
  3. The description in your form should probably be "A tool and library for ...".
  4. Your form would remove thoughtpolice as a maintainer.
  5. I'm not sure why you disabled enableParallelBuilding.
  6. Your form also makes a change to always generate a shared library version instead of the static library. My need is (slightly) better served by the static library version, and since there didn't seem to be anyone else using this 😈 I didn't invest the time to diagnose and enable building both versions.

While my preference is still for the original, divided form, I would be amenable to updates if you are strongly disposed to a version of your combined form (although I would like to hear from @thoughtpolice on this as well).

@Mic92
Copy link
Member

Mic92 commented Oct 20, 2017

I prefer the combined version since the project is otherwise build twice.
We prefer shared libraries in nixpkgs. By using outputs = ["out" "dev" "lib"]; the package can be splitted further to not include the executable. enableParallelBuilding did not had an effect in the build - it still used -j1. The maintainer thing was just a copy'n'paste error in doubt we can keep both. We can use an alias in pkgs/top-level/aliases.nix to link abc-verifier to abc.

@kquick
Copy link
Contributor Author

kquick commented Oct 20, 2017

OK, thanks for the feedback.

@kquick kquick closed this Oct 20, 2017
@Mic92
Copy link
Member

Mic92 commented Oct 20, 2017

So you no longer want to add this library?

@kquick
Copy link
Contributor Author

kquick commented Oct 20, 2017

I can locally build the static library which meets the needs I have for the moment. I originally submitted this in July, and since there's been no interest from anyone else expressed in that period, I'm assuming I'm the only user. I will probably work on this again sometime in the future when I have time to address your input and submit updates to the upstream package to allow building both the static and shared versions of the library.

@thoughtpolice
Copy link
Member

thoughtpolice commented Oct 22, 2017

Hi @kquick,

I apologize for getting back to you late. I had way too many Nixpkgs notifications, so I ignored them for a time. Thank you for the manual ping, I'm back in action now!

I agree with @Mic92 actually that having them both in the same place would be ideal, using the new shared output functionality. The main reason is: it's simply a lot easier to maintain for everyone when I won't have to go through and maintain multiple copies. (The yosys package actually uses its own variant of abc, but this is luckily less annoying since it abstracts away the details...)

However, abc has a very weird build system (I was actually fighting it on Windows recently); for example, I don't think the static Makefile variant actually builds shared objects, but we tend to like those for our -dev packages, but the CMake build was less reliable for me. It's all a bit odd...

In any case, if you have something that works for you now, I might be able to test @Mic92's changes and write up a patch and have you test it, if that's OK.

Also: The reason I named the abc package abc-verifier is because there was already some bizarre abc package (some kind of weird "Aspect Oriented" thing, IIRC?) that was effectively unmaintained, but I was hesitant about just blindly renaming it. However, I removed that quite a while ago, I think, meaning that anyone who encountered it would have already hit that issue at least. abc-verifier isn't an especially good name, either, IMO, though... But I'm not entirely sure how many users there really are, so I'm sort of ambivalent on changing it, honestly. Most people probably use the expr name rather than the .name attribute to resolve their packages...

@kquick
Copy link
Contributor Author

kquick commented Oct 22, 2017

@thoughtpolice, thanks for the response. Both you and @Mic92 have much more experience with Nixpkg maintenance, so I think it would be fine to go forward with @Mic92's version for the general support if neither of you have any significant concerns. I agree about the build system, which is why I'm not eager to spend the time at the moment to resolve the static/shared issue... it may be better and easier for me to see if I can evolve my local use case to be able to use the shared library once I have some time to address it.

I figured there was some conflict on the original name. My initial approach was intended to minimally conflict with any existing setup to avoid problems; I'm happy to defer to the two of you, I just don't have any additional bandwidth to work on the nixpkg for a couple of weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants