diff --git a/Cabal/ChangeLog.md b/Cabal/ChangeLog.md index ae0ba7932fc..81cb7f3348a 100644 --- a/Cabal/ChangeLog.md +++ b/Cabal/ChangeLog.md @@ -77,6 +77,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 67a5c2d4d5c..6d9f15e1c64 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -577,7 +577,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, @@ -1274,7 +1278,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 $