From 01f8e39032f9fd86a23e5bbb7dbf1aca3a3d114d Mon Sep 17 00:00:00 2001
From: Alp Mestanogullari <alpmestan@gmail.com>
Date: Wed, 15 May 2019 15:26:45 +0200
Subject: [PATCH] Hadrian: Fix problem with unlit path in settings file

e529c65e introduced a problem in the logic for generating the
path to the unlit command in the settings file, and this patches
fixes it.

This fixes many tests, the simplest of which is:

> _build/stage1/bin/ghc testsuite/tests/parser/should_fail/T8430.lhs

which failed because of a wrong path for unlit, and now fails for the right
reason, with the error message expected for this test.

This addresses #16659.
---
 hadrian/src/Rules/Generate.hs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index d69dd38016..c8f8cf15ca 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -5,6 +5,7 @@ module Rules.Generate (
     ) where
 
 import Base
+import qualified Context
 import Expression
 import Flavour
 import Hadrian.Oracles.TextFile (lookupValueOrError)
@@ -271,6 +272,7 @@ generateGhcPlatformH = do
 
 generateSettings :: Expr String
 generateSettings = do
+    ctx <- getContext
     settings <- traverse sequence $
         [ ("GCC extra via C opts", expr $ lookupValueOrError configFile "gcc-extra-via-c-opts")
         , ("C compiler command", expr $ settingsFileSetting SettingsFileSetting_CCompilerCommand)
@@ -293,7 +295,7 @@ generateSettings = do
         , ("dllwrap command", expr $ settingsFileSetting SettingsFileSetting_DllWrapCommand)
         , ("windres command", expr $ settingsFileSetting SettingsFileSetting_WindresCommand)
         , ("libtool command", expr $ settingsFileSetting SettingsFileSetting_LibtoolCommand)
-        , ("unlit command", ("$topdir/bin/" <>) <$> getBuilderPath Unlit)
+        , ("unlit command", ("$topdir/bin/" <>) <$> expr (programName (ctx { Context.package = unlit })))
         , ("cross compiling", expr $ yesNo <$> flag CrossCompiling)
         , ("target platform string", getSetting TargetPlatform)
         , ("target os", expr $ lookupValueOrError configFile "haskell-target-os")
-- 
GitLab