[Git][ghc/ghc][master] 7 commits: hadrian/bindist: Eliminate extraneous `dirname` invocation

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Mar 20 02:33:47 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
60023351 by Ben Gamari at 2024-03-19T22:33:10-04:00
hadrian/bindist: Eliminate extraneous `dirname` invocation

Previously we would call `dirname` twice per installed library file.
We now instead reuse this result. This helps appreciably on Windows, where
processes are quite expensive.

- - - - -
616ac300 by Ben Gamari at 2024-03-19T22:33:10-04:00
hadrian: Package mingw toolchain in expected location

This fixes #24525, a regression due to 41cbaf44a6ab5eb9fa676d65d32df8377898dc89.
Specifically, GHC expects to find the mingw32 toolchain in the binary distribution
root. However, after this patch it was packaged in the `lib/` directory.

- - - - -
de9daade by Ben Gamari at 2024-03-19T22:33:11-04:00
gitlab/rel_eng: More upload.sh tweaks

- - - - -
1dfe12db by Ben Gamari at 2024-03-19T22:33:11-04:00
rel_eng: Drop dead prepare_docs codepath

- - - - -
dd2d748b by Ben Gamari at 2024-03-19T22:33:11-04:00
rel_env/recompress_all: unxz before recompressing

Previously we would rather compress the xz *again*, before in addition
compressing it with the desired scheme.

Fixes #24545.

- - - - -
9d936c57 by Ben Gamari at 2024-03-19T22:33:11-04:00
mk-ghcup-metadata: Fix directory of testsuite tarball

As reported in #24546, the `dlTest` artifact should be extracted into
the `testsuite` directory.

- - - - -
6d398066 by Ben Gamari at 2024-03-19T22:33:11-04:00
ghcup-metadata: Don't populate dlOutput unless necessary

ghcup can apparently infer the output name of an artifact from its URL.
Consequently, we should only include the `dlOutput` field when it would
differ from the filename of `dlUri`.

Fixes #24547.

- - - - -


5 changed files:

- .gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
- .gitlab/rel_eng/recompress-all
- .gitlab/rel_eng/upload.sh
- hadrian/bindist/Makefile
- hadrian/src/Rules/BinaryDist.hs


Changes:

=====================================
.gitlab/rel_eng/mk-ghcup-metadata/mk_ghcup_metadata.py
=====================================
@@ -36,6 +36,7 @@ import os
 import yaml
 import gitlab
 from urllib.request import urlopen
+from urllib.parse import urlparse
 import hashlib
 import sys
 import json
@@ -80,7 +81,7 @@ source_artifact = Artifact('source-tarball'
 test_artifact = Artifact('source-tarball'
                         , 'ghc-{version}-testsuite.tar.xz'
                         , 'ghc-{version}-testsuite.tar.xz'
-                        , 'ghc-{version}' )
+                        , 'ghc-{version}/testsuite' )
 
 def debian(arch, n):
     return linux_platform(arch, "{arch}-linux-deb{n}".format(arch=arch, n=n))
@@ -156,13 +157,18 @@ def mk_one_metadata(release_mode, version, job_map, artifact):
     eprint(f"Bindist URL: {url}")
     eprint(f"Download URL: {final_url}")
 
-    #Download and hash from the release pipeline, this must not change anyway during upload.
+    # Download and hash from the release pipeline, this must not change anyway during upload.
     h = download_and_hash(url)
 
     res = { "dlUri": final_url
           , "dlSubdir": artifact.subdir.format(version=version)
-          , "dlOutput": artifact.output_name.format(version=version)
           , "dlHash" : h }
+
+    # Only add dlOutput if it is inconsistent with the filename inferred from the URL
+    output = artifact.output_name.format(version=version)
+    if Path(urlparse(final_url).path).name != output:
+        res["dlOutput"] = output
+
     eprint(res)
     return res
 


=====================================
.gitlab/rel_eng/recompress-all
=====================================
@@ -9,21 +9,22 @@ usage :
 
 %.gz : %.xz
 	echo "[xz->gz] $< to $@..."
-	xz -c $< | gzip -c > $@
+	xz -cd $< | gzip -c > $@
 
 %.bz2 : %.xz
 	echo "[xz->bz2] $< to $@..."
-	xz -c $< | bzip2 -c > $@
+	xz -cd $< | bzip2 -c > $@
 
 %.lz : %.xz
 	echo "[xz->lz] $< to $@..."
-	xz -c $< | lzip -c > $@
+	xz -cd $< | lzip -c > $@
 
 %.zip : %.tar.xz
 	echo "[tarxz->zip] $< to $@..."
-	tmp="$(mktemp tmp.XXX)" && \
+	tmp="$$(mktemp tmp.XXX)" && \
 		tar -C "$$tmp" -xf $< && \
 		cd "$$tmp" && \
 		zip -9 -r $@ * && \
+		cd .. && \
 		rm -R "$$tmp"
 


=====================================
.gitlab/rel_eng/upload.sh
=====================================
@@ -145,7 +145,7 @@ function purge_all() {
     curl -X PURGE http://downloads.haskell.org/~ghc/$dir
     curl -X PURGE http://downloads.haskell.org/~ghc/$dir/
     for i in *; do
-        purge_file $i
+        purge_file "$i"
     done
 }
 
@@ -158,43 +158,14 @@ function purge_file() {
     )
 
     for dir in ${dirs[@]}; do
-        curl -X PURGE http://downloads.haskell.org/$dir/$i
-        curl -X PURGE http://downloads.haskell.org/$dir/$i/
-        curl -X PURGE http://downloads.haskell.org/$dir/$i/docs/
+        curl -X PURGE http://downloads.haskell.org/$dir/$1
+        curl -X PURGE http://downloads.haskell.org/$dir/$1/
+        curl -X PURGE http://downloads.haskell.org/$dir/$1/docs/
     done
 }
 
 function prepare_docs() {
     echo "THIS COMMAND IS DEPRECATED, THE DOCS FOLDER SHOULD BE PREPARED BY THE FETCH SCRIPT"
-    local tmp
-    rm -Rf docs
-    if [ -z "$GHC_TREE" ]; then
-        tmp="$(mktemp -d)"
-        tar -xf "ghc-$ver-src.tar.xz" -C "$tmp"
-        GHC_TREE="$tmp/ghc-$ver"
-    fi
-    mkdocs="$GHC_TREE/distrib/mkDocs/mkDocs"
-    if [ ! -e "$mkdocs" ]; then
-        echo "Couldn't find GHC mkDocs at $mkdocs."
-        echo "Perhaps you need to override GHC_TREE?"
-        rm -Rf "$tmp"
-        exit 1
-    fi
-    windows_bindist="$(ls ghc-$ver-x86_64-unknown-mingw32.tar.xz | head -n1)"
-    linux_bindist="$(ls ghc-$ver-x86_64-deb9-linux.tar.xz | head -n1)"
-    echo "Windows bindist: $windows_bindist"
-    echo "Linux bindist: $linux_bindist"
-    $ENTER_FHS_ENV $mkdocs $linux_bindist $windows_bindist
-    if [ -d "$tmp" ]; then rm -Rf "$tmp"; fi
-
-    mkdir -p docs/html
-    tar -Jxf "$linux_bindist"
-    cp -R "ghc-$ver/docs/users_guide/build-html/users_guide docs/html/users_guide"
-    #cp -R ghc-$ver/utils/haddock/doc/haddock docs/html/haddock
-    rm -R "ghc-$ver"
-
-    tar -Jxf docs/libraries.html.tar.xz -C docs/html
-    mv docs/index.html docs/html
 }
 
 function recompress() {
@@ -213,7 +184,7 @@ function recompress() {
         needed+=( "$(basename $i .tar.xz).zip" )
     done
 
-    recompress-all -l ${needed[@]}
+    recompress-all -j10 ${needed[@]}
 }
 
 function upload_docs() {


=====================================
hadrian/bindist/Makefile
=====================================
@@ -176,18 +176,19 @@ install_lib: lib/settings
 	@dest="$(DESTDIR)$(ActualLibsDir)"; \
 	cd lib; \
 	for i in `$(FIND) . -type f`; do \
-		$(INSTALL_DIR) "$$dest/`dirname $$i`" ; \
+		dir="`dirname $$i`" ; \
+		$(INSTALL_DIR) "$$dest/$$dir" ; \
 		case $$i in \
 		  *.a) \
-		    $(INSTALL_DATA) $$i "$$dest/`dirname $$i`" ; \
+		    $(INSTALL_DATA) $$i "$$dest/$$dir" ; \
 		    $(RANLIB_CMD) "$$dest"/$$i ;; \
 		  *.dll) \
-		    $(INSTALL_PROGRAM) $$i "$$dest/`dirname $$i`" ; \
+		    $(INSTALL_PROGRAM) $$i "$$dest/$$dir" ; \
 		    $(STRIP_CMD) "$$dest"/$$i ;; \
 		  *.so) \
-		    $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \
+		    $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \
 		  *.dylib) \
-		    $(INSTALL_SHLIB) $$i "$$dest/`dirname $$i`" ;; \
+		    $(INSTALL_SHLIB) $$i "$$dest/$$dir" ;; \
 		  *.mjs) \
 		    $(INSTALL_SCRIPT) $$i "$$dest/`dirname $$i`" ;; \
 		  *) \


=====================================
hadrian/src/Rules/BinaryDist.hs
=====================================
@@ -135,7 +135,8 @@ bindistRules = do
         let ghcVersionPretty = "ghc-" ++ version ++ "-" ++ targetPlatform
         let prefix = cwd -/- root -/- "reloc-bindist" -/- ghcVersionPretty
         installTo Relocatable prefix
-
+        copyDirectory (root -/- "mingw") prefix
+        liftIO $ IO.removeDirectoryRecursive (prefix -/- "lib" -/- "mingw")
 
     phony "install" $ do
         need ["binary-dist-dir"]
@@ -145,8 +146,6 @@ bindistRules = do
         installTo NotRelocatable installPrefix
 
     phony "binary-dist-dir" $ do
-
-
         version        <- setting ProjectVersion
         targetPlatform <- setting TargetPlatformFull
         distDir        <- Context.distDir Stage1
@@ -309,7 +308,7 @@ bindistRules = do
 
     let buildBinDist compressor = do
           win_target <- isWinTarget
-          when win_target (error "normal binary-dist does not work for windows target, use `reloc-binary-dist-*` target instead.")
+          when win_target (error "normal binary-dist does not work for Windows targets, use `reloc-binary-dist-*` target instead.")
           buildBinDistX "binary-dist-dir" "bindist" compressor
         buildBinDistReloc = buildBinDistX "reloc-binary-dist-dir" "reloc-bindist"
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ff883896baa238f82da60e5f168bc93cabe48e4...6d398066b6084a971248da8ce37bc40c53a83525

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5ff883896baa238f82da60e5f168bc93cabe48e4...6d398066b6084a971248da8ce37bc40c53a83525
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/20240319/1a01ea83/attachment-0001.html>


More information about the ghc-commits mailing list