Skip to content

Commit

Permalink
Pass --disable-ld-override when installing/compiling GHC
Browse files Browse the repository at this point in the history
Fixes #1032

Users can still run 'ghcup install ghc <ver> -- enable-ld-override'
  • Loading branch information
hasufell committed Mar 23, 2024
1 parent 63e714d commit 5f243d0
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions lib/GHCup/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ installUnpackedGHC path inst tver forceInstall addConfArgs
-- We also must make sure to preserve mtime to not confuse ghc-pkg.
liftE $ mergeGHCFileTree path inst tver forceInstall
| otherwise = do
PlatformRequest {..} <- lift getPlatformReq
pfreq@PlatformRequest {..} <- lift getPlatformReq

let ldOverride
| _tvVersion tver >= [vver|8.2.2|]
Expand All @@ -448,37 +448,21 @@ installUnpackedGHC path inst tver forceInstall addConfArgs
= []

lift $ logInfo "Installing GHC (this may take a while)"
env <- case _rPlatform of
-- https://github.com/haskell/ghcup-hs/issues/967
Linux Alpine
-- lets not touch LD for cross targets
| Nothing <- _tvTarget tver -> do
cEnv <- liftIO getEnvironment
spaths <- liftIO getSearchPath
has_ld_bfd <- isJust <$> liftIO (searchPath spaths "ld.bfd")
let ldSet = isJust $ lookup "LD" cEnv
-- only set LD if ld.bfd exists in PATH and LD is not set
-- already
if has_ld_bfd && not ldSet
then do
lift $ logInfo "Detected alpine linux... setting LD=ld.bfd"
pure $ Just (("LD", "ld.bfd") : cEnv)
else pure Nothing
_ -> pure Nothing
lEM $ execLogged "sh"
("./configure" : ("--prefix=" <> fromInstallDir inst)
("./configure" : "--disable-ld-override" : ("--prefix=" <> fromInstallDir inst)
: (maybe mempty (\x -> ["--target=" <> T.unpack x]) (_tvTarget tver) <> ldOverride <> (T.unpack <$> addConfArgs))
)
(Just $ fromGHCupPath path)
"ghc-configure"
env
Nothing
tmpInstallDest <- lift withGHCupTmpDir
lEM $ make ["DESTDIR=" <> fromGHCupPath tmpInstallDest, "install"] (Just $ fromGHCupPath path)
liftE $ catchWarn $ lEM @_ @'[ProcessError] $ darwinNotarization _rPlatform (fromGHCupPath tmpInstallDest)
liftE $ mergeGHCFileTree (tmpInstallDest `appendGHCupPath` dropDrive (fromInstallDir inst)) inst tver forceInstall
pure ()



mergeGHCFileTree :: ( MonadReader env m
, HasPlatformReq env
, HasDirs env
Expand Down Expand Up @@ -1313,6 +1297,8 @@ compileGHC targetGhc crossTarget vps bstrap jobs mbuildConfig patches aargs buil
(_tvTarget tver)
++ ["--prefix=" <> ghcdir]
++ (if isWindows then ["--enable-tarballs-autodownload"] else [])
-- https://github.com/haskell/ghcup-hs/issues/1032
++ ["--disable-ld-override"]
++ fmap T.unpack aargs
)
(Just workdir)
Expand Down

0 comments on commit 5f243d0

Please sign in to comment.