gentoo-haskell / hackport

A command line tool to generate Gentoo ebuilds from Hackage packages.
GNU General Public License v3.0
55 stars 21 forks source link

Dependencies for `cryptonite` are not being generated #116

Open hololeap opened 2 years ago

hololeap commented 2 years ago
# hackport merge cryptonite

generated cryptonite-0.30.0.ebuild:

  # Copyright 1999-2022 Gentoo Authors
  # Distributed under the terms of the GNU General Public License v2

  EAPI=8

  # ebuild generated by hackport 0.7.2.2.9999
  #hackport: flags: -check_alignment,-old_toolchain_inliner,+support_deepseq,support_aesni:cpu_flags_x86_aes,support_pclmuldq:cpu_flags_x86_sse4_1,support_sse:cpu_flags_x86_sse,support_rdrand:cpu_flags_x86_rdrand

  CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
  inherit haskell-cabal

  DESCRIPTION="Cryptography Primitives sink"
  HOMEPAGE="https://github.com/haskell-crypto/cryptonite"

  LICENSE="BSD"
  SLOT="0/${PV}"
  KEYWORDS="~amd64 ~x86"
  IUSE="+cpu_flags_x86_aes +cpu_flags_x86_rdrand cpu_flags_x86_sse cpu_flags_x86_sse4_1 +integer-gmp +target-attributes"

  RDEPEND=">=dev-lang/ghc-8.4.3:=
          virtual/libc
  "
  DEPEND="${RDEPEND}
          >=dev-haskell/cabal-2.2.0.1
          test? ( dev-haskell/memory
                  dev-haskell/tasty
                  dev-haskell/tasty-hunit
                  dev-haskell/tasty-kat
                  dev-haskell/tasty-quickcheck )
  "

  src_configure() {
          haskell-cabal_src_configure \
                  --flag=-check_alignment \
                  $(cabal_flag integer-gmp integer-gmp) \
                  --flag=-old_toolchain_inliner \
                  $(cabal_flag cpu_flags_x86_aes support_aesni) \
                  --flag=support_deepseq \
                  $(cabal_flag cpu_flags_x86_sse4_1 support_pclmuldq) \
                  $(cabal_flag cpu_flags_x86_rdrand support_rdrand) \
                  $(cabal_flag cpu_flags_x86_sse support_sse) \
                  $(cabal_flag target-attributes use_target_attributes)
  }

This should be adding memory and basement to RDEPEND as you can see in the .cabal file:

  Build-depends:     bytestring
                   , memory >= 0.14.18
                   , basement >= 0.0.6
                   , ghc-prim

Could it have something to do with this conditional Buildable: False in the library stanza?

  if impl(ghc < 8.8)
    Buildable: False
  else
    Build-depends:   base

Related: https://github.com/gentoo-haskell/gentoo-haskell/pull/1324

hololeap commented 2 years ago

Yep, it works fine if you take that stuff out:

diff -urN cryptonite-0.30/cryptonite.cabal cryptonite-0.30-r1/cryptonite.cabal
--- cryptonite-0.30/cryptonite.cabal    2022-09-04 15:57:21.239133464 -0600
+++ cryptonite-0.30-r1/cryptonite.cabal 2022-09-04 15:56:28.329133438 -0600
@@ -245,12 +245,9 @@
                      Crypto.Internal.Nat
                      Crypto.Internal.Words
                      Crypto.Internal.WordArray
-  if impl(ghc < 8.8)
-    Buildable: False
-  else
-    Build-depends:   base

-  Build-depends:     bytestring
+  Build-depends:     base
+                   , bytestring
                    , memory >= 0.14.18
                    , basement >= 0.0.6
                    , ghc-prim
# hackport make-ebuild dev-haskell /tmp/cryptonite-0.30-r1/cryptonite.cabal

generated cryptonite-0.30.ebuild:

# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

# ebuild generated by hackport 0.7.2.2.9999
#hackport: flags: -check_alignment,-old_toolchain_inliner,+support_deepseq,support_aesni:cpu_flags_x86_aes,support_pclmuldq:cpu_flags_x86_sse4_1,support_sse:cpu_flags_x86_sse,support_rdrand:cpu_flags_x86_rdrand

CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
inherit haskell-cabal

DESCRIPTION="Cryptography Primitives sink"
HOMEPAGE="https://github.com/haskell-crypto/cryptonite"

LICENSE="BSD"
SLOT="0/${PV}"
KEYWORDS="~amd64 ~x86"
IUSE="+cpu_flags_x86_aes +cpu_flags_x86_rdrand cpu_flags_x86_sse cpu_flags_x86_sse4_1 +integer-gmp +target-attributes"

RDEPEND=">=dev-haskell/basement-0.0.6:=[profile?]
        >=dev-haskell/memory-0.14.18:=[profile?]
        >=dev-lang/ghc-8.4.3:=
        virtual/libc
"
DEPEND="${RDEPEND}
        >=dev-haskell/cabal-2.2.0.1
        test? ( dev-haskell/tasty
                dev-haskell/tasty-hunit
                dev-haskell/tasty-kat
                dev-haskell/tasty-quickcheck )
"

src_configure() {
        haskell-cabal_src_configure \
                --flag=-check_alignment \
                $(cabal_flag integer-gmp integer-gmp) \
                --flag=-old_toolchain_inliner \
                $(cabal_flag cpu_flags_x86_aes support_aesni) \
                --flag=support_deepseq \
                $(cabal_flag cpu_flags_x86_sse4_1 support_pclmuldq) \
                $(cabal_flag cpu_flags_x86_rdrand support_rdrand) \
                $(cabal_flag cpu_flags_x86_sse support_sse) \
                $(cabal_flag target-attributes use_target_attributes)
}
hololeap commented 2 years ago

It is also worth mentioning the virtual/libc in RDEPEND seems pointless.

(New bug: https://github.com/gentoo-haskell/hackport/issues/117)

hololeap commented 2 years ago

It looks like this bug also stems from a conditional buildable: False in the .cabal file:

    if impl(ghc < 8.6)
        buildable: False
hololeap commented 2 years ago

Also seems related:

The problem is not in multiple stanzas, but in a version-specific guard:

  if !impl(ghc >=8.0)
    buildable: False

hackport starts off with ghc-7 and settles on an older ghc version with subset of tests disabled.

https://github.com/gentoo-haskell/hackport/issues/81#issuecomment-759967429

hololeap commented 1 year ago

https://github.com/gentoo-haskell/hackport/commit/f4cf447468bf935bc4b57856d01268ea87c47f37 addresses the most egregious case, where an entire library in a package is marked with buildable: False (usually inside if impl(ghc<X)). It will now throw an error if a library is marked unbuildable and display a warning for executables and test-suites.

hololeap commented 1 year ago

https://github.com/gentoo-haskell/hackport/commit/dd883f1221c37b3074428c2bbd0a59ba5b1d450f raises the minimum version of GHC that hackport will consider.

Many of these if impl(ghc<X) expressions in .cabal files are strictly for compatibility with old versions of GHC. If hackport chooses a version of GHC that is too old, the ebuild will be generated based off this version of GHC and may pull in dependencies that are meant as compatibility options.