Skip to content

Commit

Permalink
Sleep before executing GHC configure script
Browse files Browse the repository at this point in the history
TODO: now the `threadDelay` appears to segfault. Terminal output:

```
WAIT
cwd: /root/.ghcup/tmp/ghcup-361d17ad/ghc-9.4.8-i386-unknown-linux
cmd: ["./configure","--prefix=/root/.ghcup/ghc/9.4.8","--disable-ld-override"]
env: Just [("LD","ld.bfd"),("GHCUP_CURL_OPTS","--silent"),("HOME","/root"),("HOSTNAME","1aaca70b41dc"),("LANG","C.UTF-8"),("NO_COLOR","1"),("OLDPWD","/"),("PATH","/root/.cabal/bin:/root/.ghcup:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"),("PWD","/src"),("SHLVL","1"),("TERM","xterm"),("ghcup_datadir","/src/./.")]
2147483647
2147483647
about to sleep
Segmentation fault (core dumped)
```
  • Loading branch information
runeksvendsen committed Feb 22, 2024
1 parent fc77459 commit 3c81bb4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/GHCup/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as E
import qualified Text.Megaparsec as MP
import Data.Int (Int32)


data GHCVer = SourceDist Version
Expand Down Expand Up @@ -465,11 +466,25 @@ installUnpackedGHC path inst tver forceInstall addConfArgs
pure $ Just (("LD", "ld.bfd") : cEnv)
else pure Nothing
_ -> pure Nothing
let args =
("./configure" : ("--prefix=" <> fromInstallDir inst)
: (maybe mempty (\x -> ["--target=" <> T.unpack x]) (_tvTarget tver) <> ldOverride <> (T.unpack <$> addConfArgs))
)
cwd = fromGHCupPath path
lEM $ liftIO $ do
putStrLn "WAIT"
putStrLn $ "cwd: " <> cwd
putStrLn $ "cmd: " <> show args
putStrLn $ "env: " <> show env
print (maxBound :: Int32)
print (fromIntegral (maxBound :: Int32) :: Int)
putStrLn "about to sleep"
threadDelay (fromIntegral (maxBound :: Int32))
putStrLn "done sleeping"
pure $ (Right () :: Either ProcessError ())
lEM $ execLogged "sh"
("./configure" : ("--prefix=" <> fromInstallDir inst)
: (maybe mempty (\x -> ["--target=" <> T.unpack x]) (_tvTarget tver) <> ldOverride <> (T.unpack <$> addConfArgs))
)
(Just $ fromGHCupPath path)
args
(Just cwd)
"ghc-configure"
env
tmpInstallDest <- lift withGHCupTmpDir
Expand Down

0 comments on commit 3c81bb4

Please sign in to comment.