From 5b606dcc53ae441624ad627069d00ea2e4366dad Mon Sep 17 00:00:00 2001 From: Cheng Shao <terrorjack@type.dance> Date: Mon, 7 Oct 2024 14:04:00 +0000 Subject: [PATCH] driver: fix -fexternal-interpreter flag for JS backend Previously, -fexternal-interpreter is broken for JS backend, since GHC would attempt to launch a non-existent ghc-iserv* executable. This commit fixes it by adjusting pattern matching order in setTopSessionDynFlags. (cherry picked from commit 621c753dee540be65208d1fdcd1728ba9f2b4320) --- compiler/GHC.hs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/compiler/GHC.hs b/compiler/GHC.hs index 992cf72c663..83388c6718f 100644 --- a/compiler/GHC.hs +++ b/compiler/GHC.hs @@ -679,6 +679,24 @@ setTopSessionDynFlags dflags = do -- Interpreter interp <- if + -- JavaScript interpreter + | ArchJavaScript <- platformArch (targetPlatform dflags) + -> do + s <- liftIO $ newMVar InterpPending + loader <- liftIO Loader.uninitializedLoader + let cfg = JSInterpConfig + { jsInterpNodeConfig = defaultNodeJsSettings + , jsInterpScript = topDir dflags </> "ghc-interp.js" + , jsInterpTmpFs = hsc_tmpfs hsc_env + , jsInterpTmpDir = tmpDir dflags + , jsInterpLogger = hsc_logger hsc_env + , jsInterpCodegenCfg = initStgToJSConfig dflags + , jsInterpUnitEnv = hsc_unit_env hsc_env + , jsInterpFinderOpts = initFinderOpts dflags + , jsInterpFinderCache = hsc_FC hsc_env + } + return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) + -- external interpreter | gopt Opt_ExternalInterpreter dflags -> do @@ -707,24 +725,6 @@ setTopSessionDynFlags dflags = do loader <- liftIO Loader.uninitializedLoader return (Just (Interp (ExternalInterp (ExtIServ (ExtInterpState conf s))) loader lookup_cache)) - -- JavaScript interpreter - | ArchJavaScript <- platformArch (targetPlatform dflags) - -> do - s <- liftIO $ newMVar InterpPending - loader <- liftIO Loader.uninitializedLoader - let cfg = JSInterpConfig - { jsInterpNodeConfig = defaultNodeJsSettings - , jsInterpScript = topDir dflags </> "ghc-interp.js" - , jsInterpTmpFs = hsc_tmpfs hsc_env - , jsInterpTmpDir = tmpDir dflags - , jsInterpLogger = hsc_logger hsc_env - , jsInterpCodegenCfg = initStgToJSConfig dflags - , jsInterpUnitEnv = hsc_unit_env hsc_env - , jsInterpFinderOpts = initFinderOpts dflags - , jsInterpFinderCache = hsc_FC hsc_env - } - return (Just (Interp (ExternalInterp (ExtJS (ExtInterpState cfg s))) loader lookup_cache)) - -- Internal interpreter | otherwise -> -- GitLab