New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clash won't run when not compiled with usual ghc #82

Closed
ggreif opened this Issue Oct 6, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@ggreif
Contributor

ggreif commented Oct 6, 2015

I managed to build clash with a development version of ghc (ghc-7.11.20150407 happened to be lying around) involving minimal changes. Alas, on starting it I got

$ /home/ggreif/.cabal/bin/clash --interactive
Can't parse "/home/ggreif/lib/ghc-7.11.20150928/platformConstants"

(Please note the differing versions.) The reason is that

ghcLibDir :: IO FilePath
ghcLibDir = do (libDir,exitCode) <- getProcessOutput "ghc --print-libdir"
    ...

queries the canonical ghc that is installed, which may have a different libdir than the ghc that built clash. Then the platformConstants file might be incompatible. The problem will also manifest itself when somebody installs a newer ghc without rebuilding clash itself.

I suggest doing

ghcLibDir :: IO FilePath
ghcLibDir = do (libDir,exitCode) <- getProcessOutput $ "ghc-" ++ TOOL_VERSION_ghc ++ " --print-libdir"

to access the specific version of ghc that was used to build clash.

Then I discovered that the functions ghcLibDir and getProcessOutput are duplicated:

$ git grep getProcessOutput
clash-ghc/src-bin/Main.hs:getProcessOutput :: String -> IO (String, ExitCode)
clash-ghc/src-bin/Main.hs:getProcessOutput command =
clash-ghc/src-ghc/CLaSH/GHC/LoadModules.hs:getProcessOutput :: String -> IO (String, ExitCode)
clash-ghc/src-ghc/CLaSH/GHC/LoadModules.hs:getProcessOutput command =

This could be refactored. Any suggestion which one to keep? Should I create a new common module?

@christiaanb

This comment has been minimized.

Show comment
Hide comment
@christiaanb

christiaanb Oct 6, 2015

Contributor

I prefer a new common module in the src-ghc dir. Perhaps CLaSH.GHC.Util.?

Contributor

christiaanb commented Oct 6, 2015

I prefer a new common module in the src-ghc dir. Perhaps CLaSH.GHC.Util.?

@ggreif

This comment has been minimized.

Show comment
Hide comment
@ggreif

ggreif Oct 6, 2015

Contributor

no need. I can export

module CLaSH.GHC.LoadModules
  ( loadModules
  , ghcLibDir
  )

and use from Main.hs. Easy.

Contributor

ggreif commented Oct 6, 2015

no need. I can export

module CLaSH.GHC.LoadModules
  ( loadModules
  , ghcLibDir
  )

and use from Main.hs. Easy.

@christiaanb

This comment has been minimized.

Show comment
Hide comment
@christiaanb

christiaanb Oct 6, 2015

Contributor

Fixed by: d58e41f

Thanks

Contributor

christiaanb commented Oct 6, 2015

Fixed by: d58e41f

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment