From 50341699cc7692bde5ae9474bf78e008c14a685e Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Wed, 2 May 2018 18:48:33 -0700 Subject: [PATCH 1/5] Remove one of the duplicated qualified imports --- src/Stack/Build/Installed.hs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Stack/Build/Installed.hs b/src/Stack/Build/Installed.hs index 0805ce50fc..28cf6e44d8 100644 --- a/src/Stack/Build/Installed.hs +++ b/src/Stack/Build/Installed.hs @@ -16,7 +16,6 @@ import qualified Data.Conduit.List as CL import qualified Data.Foldable as F import qualified Data.HashSet as HashSet import Data.List -import qualified Data.Map.Strict as M import qualified Data.Map.Strict as Map import Path import Stack.Build.Cache @@ -75,7 +74,7 @@ getInstalled opts sourceMap = do loadDatabase' (Just (InstalledTo Snap, snapDBPath)) installedLibs1 (installedLibs3, localDumpPkgs) <- loadDatabase' (Just (InstalledTo Local, localDBPath)) installedLibs2 - let installedLibs = M.fromList $ map lhPair installedLibs3 + let installedLibs = Map.fromList $ map lhPair installedLibs3 F.forM_ mcache $ \cache -> do icache <- configInstalledCache From 4063b7a9d6cf0d34268b85112b7341b72e77ca1b Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Sun, 20 May 2018 21:08:03 -0700 Subject: [PATCH 2/5] Make sure internal libraries are sent to cabal command line invocations. Otherwise, if Cabal doesn't detect that the internal library is needed (it is not listed as a dependency), it will fail to build it and this will cause a subsequent "copy"/"register" step to fail, crashing the entire build. --- src/Stack/Build/Execute.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 073f85a891..29790012ed 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1899,7 +1899,7 @@ extraBuildOptions wc bopts = do else return [optsFlag, baseOpts] --- Library and executable build components. +-- Library, internal and foreign libraries and executable build components. primaryComponentOptions :: Map Text ExecutableBuildStatus -> LocalPackage -> [String] primaryComponentOptions executableBuildStatuses lp = -- TODO: get this information from target parsing instead, @@ -1909,9 +1909,12 @@ primaryComponentOptions executableBuildStatuses lp = NoLibraries -> [] HasLibraries names -> map T.unpack - $ T.append "lib:" (packageNameText (packageName (lpPackage lp))) + $ T.append "lib:" (packageNameText (packageName package)) : map (T.append "flib:") (Set.toList names)) ++ + (map (T.unpack . T.append "lib:") (Set.toList $ packageInternalLibraries package)) ++ map (T.unpack . T.append "exe:") (Set.toList $ exesToBuild executableBuildStatuses lp) + where + package = lpPackage lp -- | History of this function: -- From f7077a8d8b50673ab909cf531f35d4ba5693124d Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 21 May 2018 06:21:29 -0700 Subject: [PATCH 3/5] Add integration test. --- .../tests/3996-sublib-not-depended-upon/Main.hs | 8 ++++++++ .../3996-sublib-not-depended-upon/files/Setup.hs | 2 ++ .../files/files.cabal | 16 ++++++++++++++++ .../files/src-internal/Internal.hs | 4 ++++ .../files/src/Lib.hs | 4 ++++ .../files/stack.yaml | 4 ++++ 6 files changed, 38 insertions(+) create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/Main.hs create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/files/files.cabal create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs create mode 100644 test/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml diff --git a/test/integration/tests/3996-sublib-not-depended-upon/Main.hs b/test/integration/tests/3996-sublib-not-depended-upon/Main.hs new file mode 100644 index 0000000000..d2479bd056 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/Main.hs @@ -0,0 +1,8 @@ +import Control.Monad (unless) +import Data.List (isInfixOf) +import StackTest + +main :: IO () +main = do + stack ["clean"] + stack ["build"] diff --git a/test/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs b/test/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/files/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/test/integration/tests/3996-sublib-not-depended-upon/files/files.cabal b/test/integration/tests/3996-sublib-not-depended-upon/files/files.cabal new file mode 100644 index 0000000000..bf9a55bd17 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/files/files.cabal @@ -0,0 +1,16 @@ +name: files +version: 0.1.0.0 +build-type: Simple +cabal-version: >= 2.0 + +library + hs-source-dirs: src + exposed-modules: Lib + build-depends: base + default-language: Haskell2010 + +library lib + hs-source-dirs: src-internal + exposed-modules: Internal + build-depends: base + default-language: Haskell2010 diff --git a/test/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs b/test/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs new file mode 100644 index 0000000000..462baca786 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/files/src-internal/Internal.hs @@ -0,0 +1,4 @@ +module Internal where + +test :: Int +test = 42 diff --git a/test/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs b/test/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs new file mode 100644 index 0000000000..a35e444b85 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/files/src/Lib.hs @@ -0,0 +1,4 @@ +module Lib where + +testLib :: Int +testLib = 42 diff --git a/test/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml b/test/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml new file mode 100644 index 0000000000..df13716817 --- /dev/null +++ b/test/integration/tests/3996-sublib-not-depended-upon/files/stack.yaml @@ -0,0 +1,4 @@ +resolver: ghc-8.2.2 +extra-deps: +- stm-2.4.4.1 +- mtl-2.2.1 From 35fdc418d85cc961fff98fcce7ae68a490f11797 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 21 May 2018 06:24:08 -0700 Subject: [PATCH 4/5] Add entry to ChangeLog.md. --- ChangeLog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 8875d03482..207035d677 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -21,6 +21,11 @@ Bug fixes: load any module. This has been fixed now and changes to the code in the library and the sublibrary are properly tracked. See [#3926](https://github.com/commercialhaskell/stack/issues/3926). +* For packages with internal libraries not depended upon, `stack build` used + to fail the build process since the internal library was not built but it + was tried to be registered. This is now fixed by always building internal + libraries. See + [#3996](https://github.com/commercialhaskell/stack/issues/3996). ## v1.7.1 From da1cdb87f332d9405d852ef52eb1e86f860ccaf7 Mon Sep 17 00:00:00 2001 From: Mihai Maruseac Date: Mon, 21 May 2018 07:00:18 -0700 Subject: [PATCH 5/5] Style fix. --- src/Stack/Build/Execute.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 29790012ed..499c4ebc75 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1911,7 +1911,7 @@ primaryComponentOptions executableBuildStatuses lp = map T.unpack $ T.append "lib:" (packageNameText (packageName package)) : map (T.append "flib:") (Set.toList names)) ++ - (map (T.unpack . T.append "lib:") (Set.toList $ packageInternalLibraries package)) ++ + map (T.unpack . T.append "lib:") (Set.toList $ packageInternalLibraries package) ++ map (T.unpack . T.append "exe:") (Set.toList $ exesToBuild executableBuildStatuses lp) where package = lpPackage lp