From 683547003db810e84c2541da4030b066f639f3f5 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Tue, 22 Oct 2024 13:53:18 +0200
Subject: [PATCH] hadrian: make sure ghc-bin internal-interpreter is disabled
 for stage0 when not cross compiling

This patch disables internal-interpreter flag for stage0 ghc-bin when
not cross compiling, see added comment for explanation. Fixes #25406.

(cherry picked from commit fde12aba9bb2d3ba607548dfba648f2a5ee00b59)
---
 hadrian/src/Settings/Packages.hs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hadrian/src/Settings/Packages.hs b/hadrian/src/Settings/Packages.hs
index 5d9f38e300b..1425b9798a0 100644
--- a/hadrian/src/Settings/Packages.hs
+++ b/hadrian/src/Settings/Packages.hs
@@ -107,7 +107,16 @@ packageArgs = do
              , compilerStageOption ghcDebugAssertions ? arg "-DDEBUG" ]
 
           , builder (Cabal Flags) ? mconcat
-            [ expr ghcWithInterpreter `cabalFlag` "internal-interpreter"
+            [
+              -- When cross compiling, enable for stage0 to get ghci
+              -- support. But when not cross compiling, disable for
+              -- stage0, otherwise we introduce extra dependencies
+              -- like haskeline etc, and mixing stageBoot/stage0 libs
+              -- can cause extra trouble (e.g. #25406)
+              expr ghcWithInterpreter ?
+                ifM (expr cross)
+                  (arg "internal-interpreter")
+                  (notStage0 `cabalFlag` "internal-interpreter")
             , ifM stage0
                   -- We build a threaded stage 1 if the bootstrapping compiler
                   -- supports it.
-- 
GitLab