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
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.