diff --git a/Cabal/ChangeLog.md b/Cabal/ChangeLog.md index 0eb9dff2cde2f8baf0237e8093e0cf726edbc369..20f081114e3e1a25405354152d3fd793d4acb5ba 100644 --- a/Cabal/ChangeLog.md +++ b/Cabal/ChangeLog.md @@ -80,6 +80,8 @@ `non`) and an optics to access the modules in a component of a `PackageDescription` by the `ComponentName`: `componentBuildInfo` and `componentModules` + * Linker `ld-options` are now passed to GHC as `-optl` options + ([#4925](https://github.com/haskell/cabal/pull/4925)). * Add `readGhcEnvironmentFile` to parse GHC environment files. * Drop support for GHC 7.4, since it is out of our support window (and has been for over a year!) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 3b4b96b066c3acbaaaa5eb28f7af792a441b2633..0d6659ece19e1f7fc501a58351b122d428ef6a79 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -581,7 +581,11 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do linkerOpts = mempty { ghcOptLinkOptions = PD.ldOptions libBi ++ [ "-static" - | withFullyStaticExe lbi ], + | withFullyStaticExe lbi ] + -- Pass extra `ld-options` given + -- through to GHC's linker. + ++ maybe [] programOverrideArgs + (lookupProgram ldProgram (withPrograms lbi)), ghcOptLinkLibs = extraLibs libBi, ghcOptLinkLibPath = toNubListR $ extraLibDirs libBi, ghcOptLinkFrameworks = toNubListR $ PD.frameworks libBi, @@ -1339,7 +1343,11 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do linkerOpts = mempty { ghcOptLinkOptions = PD.ldOptions bnfo ++ [ "-static" - | withFullyStaticExe lbi ], + | withFullyStaticExe lbi ] + -- Pass extra `ld-options` given + -- through to GHC's linker. + ++ maybe [] programOverrideArgs + (lookupProgram ldProgram (withPrograms lbi)), ghcOptLinkLibs = extraLibs bnfo, ghcOptLinkLibPath = toNubListR $ extraLibDirs bnfo, ghcOptLinkFrameworks = toNubListR $