[Git][ghc/ghc][wip/T24050] hadrian: Move hsc2hs wrapper generation to bindist installation

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Oct 4 13:24:30 UTC 2023



Ben Gamari pushed to branch wip/T24050 at Glasgow Haskell Compiler / GHC


Commits:
cb8b6d78 by Ben Gamari at 2023-10-04T09:24:21-04:00
hadrian: Move hsc2hs wrapper generation to bindist installation

We must generate the hsc2hs wrapper at bindist installation time since
it must contain `--lflag` and `--cflag` arguments which depend upon the
installation path.

Fixes #24050.

- - - - -


2 changed files:

- hadrian/bindist/Makefile
- hadrian/src/Rules/BinaryDist.hs


Changes:

=====================================
hadrian/bindist/Makefile
=====================================
@@ -235,13 +235,21 @@ install_man:
 
 export SHELL
 .PHONY: install_wrappers
-install_wrappers: install_bin_libdir
+install_wrappers: install_bin_libdir install_hsc2hs_wrapper
 	@echo "Installing wrapper scripts"
 	$(INSTALL_DIR) "$(DESTDIR)$(WrapperBinsDir)"
 	for p in `cd wrappers; $(FIND) . ! -type d`; do \
 	    mk/install_script.sh "$$p" "$(DESTDIR)/$(WrapperBinsDir)/$$p" "$(WrapperBinsDir)" "$(ActualBinsDir)" "$(ActualBinsDir)/$$p" "$(ActualLibsDir)" "$(docdir)" "$(includedir)"; \
 	done
 
+.PHONY: install_hsc2hs_wrapper
+install_hsc2hs_wrapper:
+	@echo "Installing hsc2hs wrapper"
+	echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> hsc2hs-wrapper
+	$(INSTALL_SCRIPT) hsc2hs-wrapper "$(DESTDIR)$(bindir)/hsc2hs"
+	rm -f hsc2hs-wrapper
+
+
 PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s:   :\0xxx\0:g")
 .PHONY: update_package_db
 update_package_db: install_bin install_lib


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -15,8 +15,6 @@ import Target
 import Utilities
 import qualified System.Directory.Extra as IO
 import Data.Either
-import GHC.Toolchain (ccProgram, tgtCCompiler, ccLinkProgram, tgtCCompilerLink)
-import GHC.Toolchain.Program (prgFlags)
 import qualified Data.Set as Set
 import Oracles.Flavour
 
@@ -428,7 +426,7 @@ pkgToWrappers pkg = do
       | pkg == runGhc -> pure $ map (prefix++) ["runghc", "runhaskell"]
         -- These are the packages which we want to expose to the user and hence
         -- there are wrappers installed in the bindist.
-      | pkg `elem` [hpcBin, haddock, hp2ps, hsc2hs, ghc, ghcPkg]
+      | pkg `elem` [hpcBin, haddock, hp2ps, ghc, ghcPkg]
                       -> (:[]) <$> (programName =<< programContext Stage1 pkg)
       | otherwise     -> pure []
 
@@ -437,7 +435,6 @@ wrapper "ghc"         = ghcWrapper
 wrapper "ghc-pkg"     = ghcPkgWrapper
 wrapper "ghci" = ghciScriptWrapper
 wrapper "haddock"     = haddockWrapper
-wrapper "hsc2hs"      = hsc2hsWrapper
 wrapper "runghc"      = runGhcWrapper
 wrapper "runhaskell"  = runGhcWrapper
 wrapper _             = commonWrapper
@@ -459,18 +456,6 @@ haddockWrapper = pure $ "exec \"$executablename\" -B\"$libdir\" -l\"$libdir\" ${
 commonWrapper :: Action String
 commonWrapper = pure $ "exec \"$executablename\" ${1+\"$@\"}\n"
 
--- echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(CONF_CC_OPTS_STAGE1)) $(addprefix --lflag=,$(CONF_GCC_LINKER_OPTS_STAGE1))"' >> "$(WRAPPER)"
-hsc2hsWrapper :: Action String
-hsc2hsWrapper = do
-  ccArgs <- map ("--cflag=" <>) . prgFlags . ccProgram . tgtCCompiler <$> targetStage Stage1
-  linkFlags <- map ("--lflag=" <>) . prgFlags . ccLinkProgram . tgtCCompilerLink <$> targetStage Stage1
-  wrapper <- drop 4 . lines <$> liftIO (readFile "utils/hsc2hs/hsc2hs.wrapper")
-  return $ unlines
-    ( "HSC2HS_EXTRA=\"" <> unwords (ccArgs ++ linkFlags) <> "\""
-    : "tflag=\"--template=$libdir/template-hsc.h\""
-    : "Iflag=\"-I$includedir/\""
-    : wrapper )
-
 runGhcWrapper :: Action String
 runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\n"
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb8b6d7825dd72316004725e3c33d07473867022

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/cb8b6d7825dd72316004725e3c33d07473867022
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20231004/980bc43f/attachment-0001.html>


More information about the ghc-commits mailing list