Skip to content

Instantly share code, notes, and snippets.

@ulidtko
Last active March 12, 2024 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulidtko/fd65f7e5d486744d0f70dbe1934c6894 to your computer and use it in GitHub Desktop.
Save ulidtko/fd65f7e5d486744d0f70dbe1934c6894 to your computer and use it in GitHub Desktop.
Cabal#9784 minimized repro case

Issue haskell/cabal#9784

Found & minimized on Linux. In CI, reproduces on Windows too, see issue.

Steps to reproduce

  1. Download or git-clone this gist
  2. Set executable-dynamic: True in ~/.cabal/config
    • ⚠️ important: don't pass as a flag --enable-executable-dynamic, set in the config.
      The flag has different effect (specifically: no effect) from the config option. That's the bug.
  3. cabal v2-install

Expected result

Installs, successfully running the executable from postCopy Setup hook, that prints Module Main speaking.

Actual result

dist/build/cabal9784-repro/cabal9784-repro: error while loading shared libraries: libHScabal9784-repro-0.1-273208628f9b290e48d0007c2a55aff138469cc5ac0dd78b416c2ef6e98387a2-ghc9.6.4.so: cannot open shared object file: No such file or directory

cabal-version: 2.0
name: cabal9784-repro
version: 0.1
synopsis: Minimal bug repro case
homepage: https://github.com/haskell/cabal/issues/9784
license: PublicDomain
author: Max Ulidtko
maintainer: ulidtko@gmail.com
build-type: Custom
custom-setup
setup-depends:
base >= 4.12.0.0 && < 4.20,
Cabal >= 2.4.0.1 && < 3.11,
filepath >= 1.4.2.1 && < 1.5,
process >= 1.6.3.0 && < 1.7
library
hs-source-dirs: .
build-depends: base ^>=4.18.2.0
default-language: Haskell2010
exposed-modules: LibModule
executable cabal9784-repro
hs-source-dirs: .
main-is: Main.hs
default-language: Haskell2010
build-depends: base ^>=4.18.2.0, cabal9784-repro
module LibModule where
greeting = "=== Hello, Cabal! === Module Main speaking ~~~"
module Main where
import LibModule
main :: IO ()
main = putStrLn LibModule.greeting
import Distribution.Simple
import Distribution.Simple.BuildPaths (exeExtension)
import Distribution.Simple.LocalBuildInfo (LocalBuildInfo, buildDir)
import Distribution.PackageDescription (PackageDescription)
import Distribution.Simple.Setup
import Distribution.System (buildPlatform)
import Distribution.Types.HookedBuildInfo
import System.FilePath ((</>), (<.>))
import System.Process (callCommand, callProcess)
main = defaultMainWithHooks simpleUserHooks
{ postBuild = postBuild'
, preCopy = preCopy'
, postCopy = postCopy'
}
postBuild' :: Args -> BuildFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postBuild' _ flags pd lbi = do
putStrLn "=== Hello, Cabal! === Setup's postBuild hook speaking ~~~"
preCopy' :: Args -> CopyFlags -> IO HookedBuildInfo
preCopy' args flags = do
putStrLn "=== Hello, Cabal! === Setup's preCopy hook speaking ~~~"
return emptyHookedBuildInfo
postCopy' :: Args -> CopyFlags -> PackageDescription -> LocalBuildInfo -> IO ()
postCopy' _ flags pd lbi = do
putStrLn "=== Hello, Cabal! === Setup's postCopy hook speaking ~~~"
-- callCommand "set -x; pwd && ls -lh"
let exe = buildDir lbi </> "cabal9784-repro"
</> "cabal9784-repro" <.> exeExtension buildPlatform
callProcess exe []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment