diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2022-07-22 17:24:05 +0530 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-07-25 09:45:45 -0400 |
commit | 3bbde95769aa2986adb8bef7d718aa0e8731f9fd (patch) | |
tree | 216bd9b8aaeecee6cca21df8ac4148bf252c395d /driver | |
parent | b77d95f8a4b0f8a5025dbd5036c17ecf85ca3ab2 (diff) | |
download | haskell-3bbde95769aa2986adb8bef7d718aa0e8731f9fd.tar.gz |
Fix #21889, GHCi misbehaves with Ctrl-C on Windows
On Windows, we create multiple levels of wrappers for GHCi which ultimately
execute ghc --interactive. In order to handle console events properly, each of
these wrappers must call FreeConsole() in order to hand off event processing to
the child process. See #14150.
In addition to this, FreeConsole must only be called from interactive processes (#13411).
This commit makes two changes to fix this situation:
1. The hadrian wrappers generated using `hadrian/bindist/cwrappers/version-wrapper.c` call `FreeConsole`
if the CPP flag INTERACTIVE_PROCESS is set, which is set when we are generating a wrapper for GHCi.
2. The GHCi wrapper in `driver/ghci/` calls the `ghc-$VER.exe` executable which is not wrapped rather
than calling `ghc.exe` is is wrapped on windows (and usually non-interactive, so can't call `FreeConsole`:
Before:
ghci-$VER.exe calls ghci.exe which calls ghc.exe which calls ghc-$VER.exe
After:
ghci-$VER.exe calls ghci.exe which calls ghc-$VER.exe
Diffstat (limited to 'driver')
-rw-r--r-- | driver/ghci/ghci-wrapper.cabal.in | 4 | ||||
-rw-r--r-- | driver/ghci/ghci.c | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/driver/ghci/ghci-wrapper.cabal.in b/driver/ghci/ghci-wrapper.cabal.in index 5a422aab9b..2a5ff2bb15 100644 --- a/driver/ghci/ghci-wrapper.cabal.in +++ b/driver/ghci/ghci-wrapper.cabal.in @@ -26,3 +26,7 @@ Executable ghci C-Sources: -- the following get copied from ../utils by hadrian getLocation.c isMinTTY.c cwrapper.c + -- We need to call the versioned ghc executable because the unversioned + -- GHC executable is a wrapper that doesn't call FreeConsole and so + -- breaks an interactive process like GHCi. See #21889, #14150 and #13411 + CPP-Options: -DEXE_PATH="ghc-@ProjectVersion@" diff --git a/driver/ghci/ghci.c b/driver/ghci/ghci.c index a603655ec8..652770e39e 100644 --- a/driver/ghci/ghci.c +++ b/driver/ghci/ghci.c @@ -33,7 +33,7 @@ int main(int argc, char** argv) { } binDir = getExecutablePath(); - exePath = mkString("%s/ghc.exe", binDir); + exePath = mkString("%s/%s.exe", binDir, EXE_PATH); preArgv[0] = "--interactive"; /* If ghc.exe can't be found, we assume that we're building ghc from |