From 7e0a7b85d243e8cc55bc43215f50a06a88d65a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Sat, 21 Jul 2018 00:31:59 +0200 Subject: [PATCH 1/2] Pass `ld-options` through to GHC. Fixes #4925 --- Cabal/Distribution/Simple/GHC.hs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 $ From 26f5b34efc946e04a4a02c8ffef1c62042a521bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Sat, 21 Jul 2018 01:08:36 +0200 Subject: [PATCH 2/2] Changelog: Add entry for `ld-options` being passed to ghc --- Cabal/ChangeLog.md | 2 ++ 1 file changed, 2 insertions(+) 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!)