Skip to content

runghc can't find ghc-stage2 on a Windows build

(Originally reported on the ghc-devs mailing list.)

After completing a stage-2 GHC build on Windows, runghc does not work at all. Calling it on any file will result in the following error:

$ .\ghc\inplace\bin\runghc.exe Z.hs
runghc.exe: C:\Users\ryanscot\Documents\Software\ghc\inplace\bin\ghc:
rawSystem: does not exist (No such file or directory)

A workaround is to make a symlink to ghc-stage2 with ln -s ghc-stage2.exe ghc.exe in MSYS2. This leads me to believe that Windows' runghc is always looking for ghc even when it should be looking for ghc-stage2 in this particular scenario.

This code in runghc looks highly suspect:

let ghc = takeDirectory (normalise path) </> "ghc"
in uncurry (doIt ghc) $ getGhcArgs args'

It probably shouldn't be hardcoding the name "ghc" here. On Unix-like OSes, this doesn't appear to be an issue since runghc invokes a shell script that detects the proper ghc name and invokes the runghc executable. On the other hand, I believe on Windows calling runghc directly invokes the executable, so the proper name detection never happens.

What would be a proper fix for this? I'm tempted to just have runghc check for ghc-stage2's existence and fall back on ghc, but I'd like to get the opinions of people familiar with the build system so that the fix is robust.

Trac metadata
Trac field Value
Version 7.11
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Build System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC thomie
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information