[Git][ghc/ghc][ghc-9.8] 3 commits: hadrian: Generate HSC2HS_EXTRAS variable in bindist installation

Zubin (@wz1000) gitlab at gitlab.haskell.org
Thu Feb 22 20:39:20 UTC 2024



Zubin pushed to branch ghc-9.8 at Glasgow Haskell Compiler / GHC


Commits:
2eca9c7a by Ben Gamari at 2024-02-22T18:31:44+05:30
hadrian: Generate 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.

The solution here is to substitute these variables in the configure
script (see mk/hsc2hs.in). This is then copied over a dummy wrapper in
the install rules.

Fixes #24050.

(cherry picked from commit efcbad2dfd242d0bc2c91da5390fe8456a536cc3)

- - - - -
d5246e19 by Matthew Pickering at 2024-02-22T18:31:58+05:30
ci: Show --info for installed compiler

(cherry picked from commit c540559cf188625bec668fa6cd94d4f94413d730)

- - - - -
f3225ed4 by Zubin Duggal at 2024-02-22T23:42:18+05:30
Accept change in MultiLayerModulesTH_Make

This test is flaky on darwin

Metric Decrease:
    MultiLayerModulesTH_Make

- - - - -


5 changed files:

- .gitlab/ci.sh
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/src/Rules/BinaryDist.hs
- + mk/hsc2hs.in


Changes:

=====================================
.gitlab/ci.sh
=====================================
@@ -575,6 +575,8 @@ function install_bindist() {
           --prefix="$instdir" \
           "${args[@]+"${args[@]}"}"
       make_install_destdir "$TOP"/destdir "$instdir"
+      # And check the `--info` of the installed compiler, sometimes useful in CI log.
+      "$instdir"/bin/ghc --info
       ;;
   esac
   popd


=====================================
distrib/configure.ac.in
=====================================
@@ -298,6 +298,7 @@ AC_SUBST(UseLibdw)
 FP_SETTINGS
 
 AC_CONFIG_FILES([config.mk])
+AC_CONFIG_FILES([mk/hsc2hs])
 AC_OUTPUT
 
 # We get caught by


=====================================
hadrian/bindist/Makefile
=====================================
@@ -222,13 +222,19 @@ install_man:
 	fi
 
 export SHELL
-install_wrappers: install_bin_libdir
+.PHONY: install_wrappers
+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 Copying hsc2hs wrapper
+	cp mk/hsc2hs wrappers/hsc2hs-ghc-$(ProjectVersion)
+
 PKG_CONFS = $(shell find "$(DESTDIR)$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed "s:   :\0xxx\0:g")
 update_package_db: install_bin install_lib
 	@echo "Installing C++ standard library virtual package"


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -361,6 +361,7 @@ bindistInstallFiles =
     , "mk" -/- "project.mk"
     , "mk" -/- "relpath.sh"
     , "mk" -/- "system-cxx-std-lib-1.0.conf.in"
+    , "mk" -/- "hsc2hs.in"
     , "mk" -/- "install_script.sh"
     , "README", "INSTALL" ]
 
@@ -425,17 +426,8 @@ 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=" <>) <$> settingList (ConfCcArgs Stage1)
-  ldFlags <- map ("--lflag=" <>) <$> settingList (ConfGccLinkerArgs Stage1)
-  wrapper <- drop 4 . lines <$> liftIO (readFile "utils/hsc2hs/hsc2hs.wrapper")
-  return $ unlines
-    ( "HSC2HS_EXTRA=\"" <> unwords (ccArgs ++ ldFlags) <> "\""
-    : "tflag=\"--template=$libdir/template-hsc.h\""
-    : "Iflag=\"-I$includedir/\""
-    : wrapper )
+hsc2hsWrapper = return "Copied from mk/hsc2hs"
 
 runGhcWrapper :: Action String
 runGhcWrapper = pure $ "exec \"$executablename\" -f \"$exedir/ghc\" ${1+\"$@\"}\n"


=====================================
mk/hsc2hs.in
=====================================
@@ -0,0 +1,41 @@
+HSC2HS_C="@SettingsCCompilerFlags@"
+
+HSC2HS_L="@SettingsCCompilerLinkFlags@"
+
+tflag="--template=$libdir/template-hsc.h"
+Iflag="-I$includedir/include/"
+
+for f in ${HSC2HS_C}; do
+  cflags="${cflags} --cflag=$f"
+done
+
+for f in ${HSC2HS_L}; do
+  lflags="${lflags} --lflag=$f"
+done
+
+HSC2HS_EXTRA="$cflags $lflags"
+
+read_response() {
+    response_file=$1
+    if [ -f "$response_file" ]; then
+        while read -r arg; do
+            case "$arg" in
+                -t*)          tflag=;;
+                --template=*) tflag=;;
+                @*)           read_response "${arg#"@"}" ;;
+                --)           break;;
+            esac
+        done < "$response_file"
+    fi
+}
+
+for arg do
+    case "$arg" in
+        -t*)          tflag=;;
+        --template=*) tflag=;;
+        @*)           read_response "${arg#"@"}" ;;
+        --)           break;;
+    esac
+done
+
+exec "$executablename" ${tflag:+"$tflag"} $HSC2HS_EXTRA ${1+"$@"} "$Iflag"



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f15dd7bdbed3fc251e39ca1908552ce1490d0d81...f3225ed4b3f3c4309f9342c5e40643eeb0cc45da

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/f15dd7bdbed3fc251e39ca1908552ce1490d0d81...f3225ed4b3f3c4309f9342c5e40643eeb0cc45da
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/20240222/7c55677e/attachment-0001.html>


More information about the ghc-commits mailing list