@@ -120,17 +120,17 @@ linkOrLoadComponent
120120      --  for foreign libs in the three cases where we use `withFullyStaticExe` below?
121121      linkerOpts rpaths = 
122122        mempty 
123-           { ghcOptLinkOptions  = 
124-               PD. ldOptions bi 
125-                  ++  [  " -static " 
126-                     |  withFullyStaticExe lbi 
127-                    ] 
128-                  --  Pass extra `ld-options` given
129-                  --  through to GHC's linker.
130-                  ++   maybe 
131-                    [] 
132-                    programOverrideArgs
133-                    (lookupProgram ldProgram (withPrograms lbi))
123+           { ghcOptExtraDefault  = 
124+               [  " -static-external " 
125+               |  withFullyStaticExe lbi 
126+               ] 
127+           , ghcOptLinkOptions  = 
128+               --  Pass extra `ld-options` given
129+               --  through to GHC's linker.
130+               maybe 
131+                 [] 
132+                 programOverrideArgs
133+                 (lookupProgram ldProgram (withPrograms lbi))
134134          , ghcOptLinkLibs = 
135135              if  withFullyStaticExe lbi
136136                then  extraLibsStatic bi
@@ -226,7 +226,7 @@ linkOrLoadComponent
226226                CLib  lib ->  do 
227227                  let  libWays =  wantedLibWays isIndef
228228                  rpaths <-  get_rpaths (Set. fromList libWays)
229-                   linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths libWays
229+                   linkLibrary buildTargetDir cleanedExtraLibDirs cleanedExtraLibDirsStatic  pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths libWays
230230                CFLib  flib ->  do 
231231                  let  flib_way =  wantedFLibWay (withDynFLib flib)
232232                  rpaths <-  get_rpaths (Set. singleton flib_way)
@@ -241,6 +241,8 @@ linkLibrary
241241  --  ^  The library target build directory 
242242  ->  [SymbolicPath  Pkg  (Dir  Lib )]
243243  --  ^  The list of extra lib dirs that exist (aka "cleaned") 
244+   ->  [SymbolicPath  Pkg  (Dir  Lib )]
245+   --  ^  The list of extra static lib dirs that exist (aka "cleaned") 
244246  ->  PackageDescription 
245247  --  ^  The package description containing this library 
246248  ->  Verbosity 
@@ -256,7 +258,7 @@ linkLibrary
256258  ->  [BuildWay ]
257259  --  ^  Wanted build ways and corresponding build options 
258260  ->  IO   () 
259- linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays =  do 
261+ linkLibrary buildTargetDir cleanedExtraLibDirs cleanedExtraLibDirsStatic  pkg_descr verbosity runGhcProg lib lbi clbi extraSources rpaths wantedWays =  do 
260262  let 
261263    common =  configCommonFlags $  configFlags lbi
262264    mbWorkDir =  flagToMaybe $  setupWorkingDir common
@@ -432,8 +434,7 @@ linkLibrary buildTargetDir cleanedExtraLibDirs pkg_descr verbosity runGhcProg li
432434        , ghcOptInputFiles =  toNubListR $  map  coerceSymbolicPath staticObjectFiles
433435        , ghcOptOutputFile =  toFlag staticLibFilePath
434436        , ghcOptLinkLibs =  extraLibs libBi
435-         , --  TODO: Shouldn't this use cleanedExtraLibDirsStatic instead?
436-           ghcOptLinkLibPath =  toNubListR $  cleanedExtraLibDirs
437+         , ghcOptLinkLibPath =  toNubListR $  cleanedExtraLibDirsStatic
437438        }
438439
439440  staticObjectFiles <-  getObjFiles StaticWay 
0 commit comments