Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build problems with GHC 9.x #1749

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions haskell/assets/ghc_9_0_2_win.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions haskell/assets/ghc_9_2_1_win.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion haskell/c2hs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions haskell/ghc_bindist.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -42,6 +43,9 @@ GHC_BINDIST_LIBDIR = \
"9.2.1": {
"darwin_amd64": "lib/lib",
},
"9.0.2": {
"darwin_amd64": "lib/lib",
},
}

GHC_BINDIST_DOCDIR = \
Expand Down
19 changes: 17 additions & 2 deletions haskell/private/actions/process_hsc_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 2 additions & 4 deletions haskell/private/cabal_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down