[Git][ghc/ghc][wip/T24050] hadrian: Generic HSC2HS_EXTRAS variable in bindist installation

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Wed Jan 31 16:14:42 UTC 2024



Matthew Pickering pushed to branch wip/T24050 at Glasgow Haskell Compiler / GHC


Commits:
b5d4b986 by Ben Gamari at 2024-01-31T16:14:34+00:00
hadrian: Generic HSC2HS_EXTRAS variable in 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 modify_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
 
+# Inject the right HSC2HS_EXTRA variable into the hsc2hs wrapper
+.PHONY: modify_hsc2hs_wrapper
+modify_hsc2hs_wrapper:
+	@echo "Installing hsc2hs wrapper"
+	echo 'HSC2HS_EXTRA="$(addprefix --cflag=,$(SettingsCCompilerFlags)) $(addprefix --lflag=,$(SettingsCCompilerLinkFlags))"' > wrappers/hsc2hs-tmp
+	cat wrappers/hsc2hs >> wrappers/hsc2hs-tmp
+	mv wrappers/hsc2hs-tmp wrappers/hsc2hs
+
 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
 
@@ -464,15 +462,11 @@ 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\""
+    ( "tflag=\"--template=$libdir/template-hsc.h\""
     : "Iflag=\"-I$includedir/\""
     : wrapper )
 



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5d4b9864e2949c07ac736f5c96423f34603ce37
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/20240131/297b3589/attachment-0001.html>


More information about the ghc-commits mailing list