From c9e9e7f08de79e9a658b877547904cf01dad0584 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Mon, 30 May 2022 10:39:15 +0200 Subject: [PATCH 1/4] Handle include dir for GHC 9+ on Windows The GHC bindists changed the directory layout starting with version 9. --- haskell/c2hs.bzl | 3 ++- haskell/private/actions/process_hsc_file.bzl | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/haskell/c2hs.bzl b/haskell/c2hs.bzl index 96dfd5034..0fad061c1 100644 --- a/haskell/c2hs.bzl +++ b/haskell/c2hs.bzl @@ -95,7 +95,8 @@ def _c2hs_library_impl(ctx): """ # Include libdir in include path just like hsc2hs does. libdir=$({ghc} --print-libdir) - {c2hs} -C-I$libdir/include "$@" + # GHC >=9 on Windows stores the includes outside of libdir + {c2hs} -C-I$libdir/include -C-I$libdir/../include "$@" """.format( ghc = hs.tools.ghc.path, c2hs = c2hs_exe.path, diff --git a/haskell/private/actions/process_hsc_file.bzl b/haskell/private/actions/process_hsc_file.bzl index 07bdec299..cde44136c 100644 --- a/haskell/private/actions/process_hsc_file.bzl +++ b/haskell/private/actions/process_hsc_file.bzl @@ -60,17 +60,32 @@ def process_hsc_file(hs, cc, hsc_flags, hsc_inputs, hsc_file): if hs.env.get("PATH") == None and hs.toolchain.is_windows: hs.env["PATH"] = "" - hs.actions.run( + hs.actions.run_shell( inputs = depset(transitive = [ depset(cc.hdrs), depset([hsc_file]), depset(cc.files), depset(hsc_inputs), + depset(hs.toolchain.bindir), ]), input_manifests = cc.manifests, outputs = [hs_out], mnemonic = "HaskellHsc2hs", - executable = hs.tools.hsc2hs, + command = + # cpp (called via c2hs) gets very unhappy if the mingw bin dir is + # not in PATH so we add it to PATH explicitly. + """ + export PATH=$PATH:{mingw_bin} + + # Include libdir in include path just like hsc2hs does. + libdir=$({ghc} --print-libdir) + # GHC >=9 on Windows stores the includes outside of libdir + {hsc2hs} -C-I$libdir/include -C-I$libdir/../include "$@" + """.format( + mingw_bin = paths.dirname(cc.tools.cc) if hs.toolchain.is_windows else "", + ghc = hs.tools.ghc.path, + hsc2hs = hs.tools.hsc2hs.path, + ), arguments = [args], env = hs.env, ) From 11d697a34af87bc42cb253d78d569e5ae4d57ac0 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 31 May 2022 12:55:11 +0200 Subject: [PATCH 2/4] Remove non-existent `haddock-{interfaces,html}` for rts The rts package's haddock file is not shipped with GHC bindists. --- haskell/assets/ghc_9_0_2_win.patch | 7 +++---- haskell/assets/ghc_9_2_1_win.patch | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/haskell/assets/ghc_9_0_2_win.patch b/haskell/assets/ghc_9_0_2_win.patch index 6ae353507..340014dba 100644 --- a/haskell/assets/ghc_9_0_2_win.patch +++ b/haskell/assets/ghc_9_0_2_win.patch @@ -286,14 +286,13 @@ +haddock-html: ${pkgroot}/../docs/html/libraries/process --- lib/package.conf.d/rts-1.0.2.conf +++ lib/package.conf.d/rts-1.0.2.conf -@@ -78,5 +78,5 @@ ld-options: +@@ -77,6 +77,3 @@ + "-Wl,-u,hs_atomicread32" "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" - +- -haddock-interfaces: ${pkgroot}/../../docs/html/libraries/rts\rts.haddock -haddock-html: ${pkgroot}/../../docs/html/libraries/rts -+haddock-interfaces: ${pkgroot}/../docs/html/libraries/rts\rts.haddock -+haddock-html: ${pkgroot}/../docs/html/libraries/rts --- lib/package.conf.d/stm-2.5.0.0.conf +++ lib/package.conf.d/stm-2.5.0.0.conf @@ -34,5 +34,5 @@ dynamic-library-dirs: ${pkgroot}\x86_64-windows-ghc-9.0.2 diff --git a/haskell/assets/ghc_9_2_1_win.patch b/haskell/assets/ghc_9_2_1_win.patch index 584d77490..58cb4771b 100644 --- a/haskell/assets/ghc_9_2_1_win.patch +++ b/haskell/assets/ghc_9_2_1_win.patch @@ -286,14 +286,13 @@ +haddock-html: ${pkgroot}/../docs/html/libraries/process --- lib/package.conf.d/rts-1.0.2.conf +++ lib/package.conf.d/rts-1.0.2.conf -@@ -78,5 +78,5 @@ ld-options: +@@ -77,6 +77,3 @@ + "-Wl,-u,hs_atomicread32" "-Wl,-u,hs_atomicwrite8" "-Wl,-u,hs_atomicwrite16" "-Wl,-u,hs_atomicwrite32" "-Wl,-u,base_GHCziEventziWindows_processRemoteCompletion_closure" - +- -haddock-interfaces: ${pkgroot}/../../docs/html/libraries/rts\rts.haddock -haddock-html: ${pkgroot}/../../docs/html/libraries/rts -+haddock-interfaces: ${pkgroot}/../docs/html/libraries/rts\rts.haddock -+haddock-html: ${pkgroot}/../docs/html/libraries/rts --- lib/package.conf.d/stm-2.5.0.0.conf +++ lib/package.conf.d/stm-2.5.0.0.conf @@ -34,5 +34,5 @@ dynamic-library-dirs: ${pkgroot}\x86_64-windows-ghc-9.2.1 From ed9ca344e00f894efb0bd2c84c02bfb9c899d5e9 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Wed, 1 Jun 2022 10:20:33 +0200 Subject: [PATCH 3/4] Revert "Fix relocatable with Cabal-3.6.0.0" This reverts commit 20085b2af090645d1daae15dd910964dad255611. Without this flag, the pkgdb files are not correctly modified and absolute paths to sandbox directories are referenced. --- haskell/private/cabal_wrapper.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/haskell/private/cabal_wrapper.py b/haskell/private/cabal_wrapper.py index 9fbf82ee7..46b00ef73 100755 --- a/haskell/private/cabal_wrapper.py +++ b/haskell/private/cabal_wrapper.py @@ -191,10 +191,8 @@ def distdir_prefix(): # into the 'flag hash' field of generated interface files. We try to use a # reproducible path for the distdir to keep interface files reproducible. with mkdtemp(distdir_prefix()) as distdir: - enable_relocatable_flags = [] - if not is_windows and json_args["ghc_version"] != None and json_args["ghc_version"] < [9,2,1]: - # ToDo: not work relocatable from Cabal-3.6.0.0 buildin GHC 9.2.1 - enable_relocatable_flags = ["--enable-relocatable"] + enable_relocatable_flags = ["--enable-relocatable"] \ + if not is_windows else [] # Cabal really wants the current working directory to be directory # where the .cabal file is located. So we have no choice but to chance From 5400e3833067c69f65e8b9a3f48d10656b0c4989 Mon Sep 17 00:00:00 2001 From: Claudio Bley Date: Tue, 31 May 2022 13:55:03 +0200 Subject: [PATCH 4/4] Add GHC bindist libdir and prefix for 9.0.2 on darwin_amd64 --- haskell/ghc_bindist.bzl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/haskell/ghc_bindist.bzl b/haskell/ghc_bindist.bzl index c58aa1092..2a063256c 100644 --- a/haskell/ghc_bindist.bzl +++ b/haskell/ghc_bindist.bzl @@ -31,6 +31,7 @@ GHC_BINDIST_STRIP_PREFIX = \ }, "9.0.2": { "windows_amd64": "ghc-9.0.2-x86_64-unknown-mingw32", + "darwin_amd64": "ghc-9.0.2-x86_64-apple-darwin", }, "9.0.1": { "windows_amd64": "ghc-9.0.1-x86_64-unknown-mingw32", @@ -42,6 +43,9 @@ GHC_BINDIST_LIBDIR = \ "9.2.1": { "darwin_amd64": "lib/lib", }, + "9.0.2": { + "darwin_amd64": "lib/lib", + }, } GHC_BINDIST_DOCDIR = \