diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs index 3c380a41a86..9417eaafb1b 100644 --- a/Cabal/src/Distribution/Simple/GHC.hs +++ b/Cabal/src/Distribution/Simple/GHC.hs @@ -1028,7 +1028,7 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do , ghcOptLinkFrameworks = toNubListR $ PD.frameworks libBi , ghcOptLinkFrameworkDirs = toNubListR $ PD.extraFrameworkDirs libBi - , ghcOptRPaths = rpaths + , ghcOptRPaths = rpaths <> toNubListR (extraLibDirs libBi) } ghcStaticLinkArgs = mempty @@ -1666,7 +1666,7 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do } dynLinkerOpts = mempty - { ghcOptRPaths = rpaths + { ghcOptRPaths = rpaths <> toNubListR (extraLibDirs bnfo) , ghcOptInputFiles = toNubListR [tmpDir x | x <- cLikeObjs ++ cxxObjs ++ cmmObjs ++ asmObjs] diff --git a/Cabal/src/Distribution/Simple/Program/GHC.hs b/Cabal/src/Distribution/Simple/Program/GHC.hs index 537e008c17f..e9ec975b63f 100644 --- a/Cabal/src/Distribution/Simple/Program/GHC.hs +++ b/Cabal/src/Distribution/Simple/Program/GHC.hs @@ -774,6 +774,8 @@ renderGhcOptions comp _platform@(Platform _arch os) opts , ["-no-hs-main" | flagBool ghcOptLinkNoHsMain] , ["-dynload deploy" | not (null (flags ghcOptRPaths))] , concat + -- Ideally, this should call a hypothetical `-rpath` flag on GHC, + -- so that GHC can correctly handle the tricky -rpath logic (e.g. ) [ ["-optl-Wl,-rpath," ++ dir] | dir <- flags ghcOptRPaths ]