valderman / haste-compiler

A GHC-based Haskell to JavaScript compiler
http://haste-lang.org
BSD 3-Clause "New" or "Revised" License
1.45k stars 115 forks source link

haste-boot hangs in ghc-prim with no output #385

Open WolframKahl opened 7 years ago

WolframKahl commented 7 years ago

Trying to use 0.6.0.0 from github, I encounter a situation where haste-boot appears to hang, at 100% CPU, while attempting to process ghc-prim. I have had it running for hours, with no difference: All the output I get is:

 $ haste-boot --local --with-haste-cabal=$(which haste-cabal)
Downloading Google Closure compiler...
Reading package info from "libraries/rts.pkg" ... done.

What I can easily find out about the running process:

$ ps ucax | grep 28927
kahl     28927 99.6  0.0  13744  2732 pts/129  R+   11:22   5:50 haste-cabal.bin
$ ls -la /proc/28927/cwd
lrwxrwxrwx 1 kahl users 0 Aug 29 11:29 /proc/28927/cwd -> /usr/local/packages/CalcCheck/build/haste-compiler/libraries/ghc-7.10/ghc-prim
 $ cat /proc/28927/cmdline 
/bin/bash/export/home/kahl/.haste/x86_64-linux-haste-0.6.0.0-ghc-7.10.3/haste-cabal/haste-cabal.bininstall--solvertopdown--with-hastec=/usr/local/packages/CalcCheck/bin/hastec--with-haste-pkg=/usr/local/packages/CalcCheck/bin/haste-pkg--libdir=/export/home/kahl/.haste--package-db=clear--package-db=global--hastec-option=-fforce-recomp

Hitting Ctrl-C on the haste-boot process gives me:

^Chaste-pkg: cannot find package ghc-prim
Reading package info from "ghc-prim-0.4.0.0.conf" ... done.
ghc-prim-0.4.0.0: Warning: library-dirs: /export/home/kahl/.haste/x86_64-linux-haste-0.6.0.0-ghc-7.10.3/ghc-prim-0.4.0.0-D2fxfF2ioP6IgtY1aDuBic doesn't exist or isn't a directory
ghc-prim-0.4.0.0: import-dirs: /export/home/kahl/.haste/x86_64-linux-haste-0.6.0.0-ghc-7.10.3/ghc-prim-0.4.0.0-D2fxfF2ioP6IgtY1aDuBic doesn't exist or isn't a directory (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/CString.hi","GHC/CString.p_hi","GHC/CString.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/Classes.hi","GHC/Classes.p_hi","GHC/Classes.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/Debug.hi","GHC/Debug.p_hi","GHC/Debug.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/IntWord64.hi","GHC/IntWord64.p_hi","GHC/IntWord64.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/Magic.hi","GHC/Magic.p_hi","GHC/Magic.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/PrimopWrappers.hi","GHC/PrimopWrappers.p_hi","GHC/PrimopWrappers.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/Tuple.hi","GHC/Tuple.p_hi","GHC/Tuple.dyn_hi"] (use --force to override)
ghc-prim-0.4.0.0: cannot find any of ["GHC/Types.hi","GHC/Types.p_hi","GHC/Types.dyn_hi"] (use --force to override)
^C

(This time I needed to hit Ctrl-C twice.)

I suspected that some of these messages were held back due to buffering issues, and tried:

diff --git a/src/haste-boot.hs b/src/haste-boot.hs
index acfc8f7..fac4a6f 100644
--- a/src/haste-boot.hs
+++ b/src/haste-boot.hs
@@ -18,6 +18,7 @@ import System.Console.GetOpt
 import GHC.Paths (libdir)
 import System.Info (os)
 import System.Directory (copyPermissions)
+import System.IO (stdout,stderr,BufferMode(LineBuffering))

 #if __GLASGOW_HASKELL__ < 800
 ghcMajor = "7.10"
@@ -146,6 +147,8 @@ data CabalOp = Configure | Build | Install | Clean

 main :: IO ()
 main = shell_ $ do
+  hSetBuffering stdout LineBuffering
+  hSetBuffering stderr LineBuffering
   when ("--help" `elem` cmdline || "-?" `elem` cmdline) $ do
     echo $ printHelp hdr specs
     exit

However, this makes no difference.

I previously had occasional access with haste-boot, but unfortunately cannot reproduce that now.

The main issue I see is that the process keeps running at 100% CPU for hours even though it presumably is already in an error state.

(Aside: Is it possible that somewhere a dependence on monads-tf is missing? I had messages about that; then did cabal install monads-tf, and then did not get those anymore so far.)

WolframKahl commented 7 years ago

It is now making progress: After

cd haste-compiler
cabal install

I first did

cd libraries
cd haste-prim
cabal install

cd ../haste-lib
cabal install

before doing

cd ../..
haste-boot --local --with-haste-cabal=$(which haste-cabal)

If this is the right procedure, the documentation should presumably be updated.

valderman commented 7 years ago

Which GHC version are you using? I can't reproduce this on 7.10, and 8.0 support is still in the pipeline.

WolframKahl commented 7 years ago

Always 7.10.

I have since discovered that:

rm -rf ~/.haste/x86_64-linux-haste-0.6.0.0-ghc-7.10.3
cd haste-compiler
cabal install

cd libraries/haste-prim
cabal install

cd ../haste-lib
cabal install

How can I replace ~/.haste with a global installation path?

One one machine I am behind a firewall, and cannot connect to the Internet: It would be nice to be able to give haste-boot options pointing to a pre-downloaded JS compiler so that it still can do a full installation without Internet connection. (I am installing everything from source.)