Skip to content
Snippets Groups Projects
Commit 75c6ccf7 authored by Alp Mestanogullari's avatar Alp Mestanogullari Committed by Marge Bot
Browse files

fix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario

Before this patch, runghc would only run the GHC detection logic on Windows and
assume that it was invoked through a wrapper script on all other platforms.
This patch lifts this limitation and makes that logic work for the scenario
where someone is calling the runghc executable directly, without passing an
explicit path to GHC.
parent 338336d3
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,11 @@ main = do ...@@ -65,6 +65,11 @@ main = do
-- live, we check for the existence of ghc. If we can't find it, we assume that -- live, we check for the existence of ghc. If we can't find it, we assume that
-- we're building ghc from source, in which case we fall back on ghc-stage2. -- we're building ghc from source, in which case we fall back on ghc-stage2.
-- (See #1185.) -- (See #1185.)
--
-- In-tree Hadrian builds of GHC also happen to give us a wrapper-script-less
-- runghc. In those cases, 'getExecPath' returns the directory where runghc
-- lives, which is also where the 'ghc' executable lives, so the guessing logic
-- covers this scenario just as nicely.
findGhc :: FilePath -> IO FilePath findGhc :: FilePath -> IO FilePath
findGhc path = do findGhc path = do
let ghcDir = takeDirectory (normalise path) let ghcDir = takeDirectory (normalise path)
...@@ -207,5 +212,5 @@ getExecPath = try_size 2048 -- plenty, PATH_MAX is 512 under Win32. ...@@ -207,5 +212,5 @@ getExecPath = try_size 2048 -- plenty, PATH_MAX is 512 under Win32.
foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW" foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW"
c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32 c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32
#else #else
getExecPath = return Nothing getExecPath = Just <$> getExecutablePath
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment