Skip to content

Commit

Permalink
Upgrade to GHC 9.0.2 (digital-asset#12300)
Browse files Browse the repository at this point in the history
changelog_begin
changelog_end

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
  • Loading branch information
akrmn and cocreature authored Feb 1, 2022
1 parent 1238e1b commit e4764cc
Show file tree
Hide file tree
Showing 68 changed files with 1,424 additions and 1,175 deletions.
4 changes: 2 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,13 @@ haskell_register_ghc_nixpkgs(
"-Wwarn",
],
repositories = dev_env_nix_repos,
version = "8.10.7",
version = "9.0.2",
)

# Used by Windows
haskell_register_ghc_bindists(
compiler_flags = common_ghc_flags,
version = "8.10.7",
version = "9.0.2",
) if is_windows else None

nixpkgs_package(
Expand Down
74 changes: 50 additions & 24 deletions bazel-haskell-deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93
def daml_haskell_deps():
"""Load all Haskell dependencies of the DAML repository."""

# XXX: We do not have access to an integer-simple version of GHC on Windows.
# For the time being we build with GMP. See https://github.com/digital-asset/daml/issues/106
use_integer_simple = not is_windows

#
# Vendored Packages
#
Expand Down Expand Up @@ -247,14 +243,16 @@ haskell_library(
build_file_content = """
load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library")
load("@stackage//:packages.bzl", "packages")
deps = [p for p in packages["proto3-suite"].deps if p.name != "swagger2"]
haskell_cabal_library(
name = "proto3-suite",
version = packages["proto3-suite"].version,
srcs = glob(["src/**", "test-files/*.bin", "tests/*", "proto3-suite.cabal"]),
haddock = False,
deps = packages["proto3-suite"].deps,
deps = deps,
verbose = False,
visibility = ["//visibility:public"],
flags = ["-swagger"],
)
# XXX: haskell_cabal_binary inexplicably fails with
# realgcc.exe: error: CreateProcess: No such file or directory
Expand All @@ -264,13 +262,13 @@ haskell_binary(
name = "compile-proto-file",
srcs = ["tools/compile-proto-file/Main.hs"],
compiler_flags = ["-w", "-optF=-w"],
deps = [":proto3-suite"] + packages["proto3-suite"].deps,
deps = [":proto3-suite"] + deps,
visibility = ["//visibility:public"],
)
""",
sha256 = "b294ff0fe24c6c256dc8eca1d44c2a9a928b9a1bc70ddce6a1d059499edea119",
strip_prefix = "proto3-suite-0af901f9ef3b9719e08eae4fab8fd700d6c8047a",
urls = ["https://github.com/awakesecurity/proto3-suite/archive/0af901f9ef3b9719e08eae4fab8fd700d6c8047a.tar.gz"],
sha256 = "1649ebbe49ee34901ea920c860ad6f21188340a981c4c8d7521df101e75aa8ab",
strip_prefix = "proto3-suite-d4a288068587f8738c84465a9ca113a3fe845ffc",
urls = ["https://github.com/cocreature/proto3-suite/archive/d4a288068587f8738c84465a9ca113a3fe845ffc.tar.gz"],
patches = ["@com_github_digital_asset_daml//bazel_tools:haskell_proto3_suite_deriving_defaults.patch"],
patch_args = ["-p1"],
)
Expand Down Expand Up @@ -354,6 +352,30 @@ haskell_cabal_library(
urls = ["http://hackage.haskell.org/package/js-flot-{version}/js-flot-{version}.tar.gz".format(version = JS_FLOT_VERSION)],
)

http_archive(
name = "turtle",
build_file_content = """
load("@rules_haskell//haskell:cabal.bzl", "haskell_cabal_library")
load("@stackage//:packages.bzl", "packages")
haskell_cabal_library(
name = "turtle",
version = packages["turtle"].version,
srcs = glob(["**"]),
haddock = False,
deps = packages["turtle"].deps,
verbose = False,
visibility = ["//visibility:public"],
)
""",
patch_args = ["-p1"],
patches = [
"@com_github_digital_asset_daml//bazel_tools:haskell-turtle.patch",
],
sha256 = "ac5c352a2e2a4dec853623f24677f41cdd8cff1140741bf38c8e06f09551e009",
strip_prefix = "turtle-1.5.23",
urls = ["http://hackage.haskell.org/package/turtle-1.5.23/turtle-1.5.23.tar.gz"],
)

http_archive(
name = "xml-conduit",
build_file_content = """
Expand Down Expand Up @@ -457,15 +479,8 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
"hlint": ["ghc-lib"],
"shake": ["embed-files"],
"zip": ["disable-bzip2", "disable-zstd"],
"proto3-suite": ["-swagger"],
},
{
"blaze-textual": ["integer-simple"],
"cryptonite": ["-integer-gmp"],
"hashable": ["-integer-gmp"],
"integer-logarithms": ["-integer-gmp"],
"scientific": ["integer-simple"],
"text": ["integer-simple"],
} if use_integer_simple else {},
),
haddock = False,
local_snapshot = "//:stack-snapshot.yaml",
Expand Down Expand Up @@ -601,6 +616,13 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
] + (["unix"] if not is_windows else ["Win32"]),
components = {
"hpp": ["lib", "exe"],
"attoparsec": [
"lib:attoparsec",
"lib:attoparsec-internal",
],
},
components_dependencies = {
"attoparsec": """{"lib:attoparsec": ["lib:attoparsec-internal"]}""",
},
stack = "@stack_windows//:stack.exe" if is_windows else None,
vendored_packages = {
Expand All @@ -615,6 +637,7 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
"lsp-types": "@lsp-types//:lsp-types",
"proto3-suite": "@proto3-suite//:proto3-suite",
"shake": "@shake//:shake",
"turtle": "@turtle//:turtle",
"xml-conduit": "@xml-conduit//:xml-conduit",
"zip": "@zip//:zip",
},
Expand All @@ -625,19 +648,22 @@ exports_files(["stack.exe"], visibility = ["//visibility:public"])
extra_deps = {
"zlib": ["@com_github_madler_zlib//:libz"],
},
flags = {
"hashable": ["-integer-gmp"],
"integer-logarithms": ["-integer-gmp"],
"scientific": ["integer-simple"],
"text": ["integer-simple"],
} if use_integer_simple else {},
haddock = False,
local_snapshot = "//:ghcide-snapshot.yaml",
stack_snapshot_json = "//:ghcide_snapshot.json",
packages = [
"ghcide",
],
components = {"ghcide": ["lib", "exe"]},
components = {
"ghcide": ["lib", "exe"],
"attoparsec": [
"lib:attoparsec",
"lib:attoparsec-internal",
],
},
components_dependencies = {
"attoparsec": """{"lib:attoparsec": ["lib:attoparsec-internal"]}""",
},
stack = "@stack_windows//:stack.exe" if is_windows else None,
vendored_packages = {
"zip": "@zip//:zip",
Expand Down
55 changes: 55 additions & 0 deletions bazel_tools/haskell-ghc-includes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
diff --git a/haskell/c2hs.bzl b/haskell/c2hs.bzl
index 96dfd503..0fad061c 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/compile.bzl b/haskell/private/actions/compile.bzl
index ee5f3d02..a89e815b 100644
--- a/haskell/private/actions/compile.bzl
+++ b/haskell/private/actions/compile.bzl
@@ -82,16 +82,34 @@ 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),
]),
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 explicitely.
+ (
+ """
+ export PATH=$PATH:{mingw_bin}
+ """.format(mingw_bin = paths.dirname(cc.tools.cc)) if hs.toolchain.is_windows else ""
+ ) +
+ """
+ # 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(
+ ghc = hs.tools.ghc.path,
+ hsc2hs = hs.tools.hsc2hs.path,
+ ),
+
arguments = [args],
env = hs.env,
)
44 changes: 44 additions & 0 deletions bazel_tools/haskell-rts-docs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/haskell/assets/ghc_9_0_2_win.patch b/haskell/assets/ghc_9_0_2_win.patch
index 6ae35350..340014db 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 584d7749..58cb4771 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
33 changes: 33 additions & 0 deletions bazel_tools/haskell-turtle.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/src/Turtle/Prelude.hs b/src/Turtle/Prelude.hs
index 384fcb4..0e8d6b2 100644
--- a/src/Turtle/Prelude.hs
+++ b/src/Turtle/Prelude.hs
@@ -1237,10 +1237,14 @@ touch file = do
Nothing
(creationTime, _, _) <- Win32.getFileTime handle
systemTime <- Win32.getSystemTimeAsFileTime
+#if MIN_VERSION_Win32(2,12,0)
+ Win32.setFileTime handle (Just creationTime) (Just systemTime) (Just systemTime)
+#else
Win32.setFileTime handle creationTime systemTime systemTime
+#endif -- MIN_VERSION_Win32
#else
then touchFile (Filesystem.encodeString file)
-#endif
+#endif -- mingw32_HOST_OS
else output file empty )

{-| This type is the same as @"System.Directory".`System.Directory.Permissions`@
diff --git a/turtle.cabal b/turtle.cabal
index 14af73d..6691e91 100644
--- a/turtle.cabal
+++ b/turtle.cabal
@@ -85,7 +85,7 @@ Library
optional-args >= 1.0 && < 2.0 ,
unix-compat >= 0.4 && < 0.6
if os(windows)
- Build-Depends: Win32 >= 2.2.0.1 && < 2.9
+ Build-Depends: Win32 >= 2.2.0.1 && < 2.13
else
Build-Depends: unix >= 2.5.1.0 && < 2.8

10 changes: 5 additions & 5 deletions bazel_tools/haskell_proto3_suite_deriving_defaults.patch
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ So instead, we disable the warning on a per file basis.
The warning only exists in GHC >= 8.10 so we cannot
upstream this atm.
diff --git a/src/Proto3/Suite/DotProto/Generate.hs b/src/Proto3/Suite/DotProto/Generate.hs
index 566b8a9..fae46a4 100644
index ef16ba4..b62ee6b 100644
--- a/src/Proto3/Suite/DotProto/Generate.hs
+++ b/src/Proto3/Suite/DotProto/Generate.hs
@@ -127,6 +127,7 @@ renderHsModuleForDotProto extraInstanceFiles dotProto importCtxt = do
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
@@ -128,6 +128,7 @@ renderHsModuleForDotProto extraInstanceFiles dotProto importCtxt = do
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
{-# OPTIONS_GHC -fno-warn-missing-export-lists #-}
+ {-# OPTIONS_GHC -Wno-deriving-defaults #-}

-- | Generated by Haskell protocol buffer compiler. DO NOT EDIT!
Expand Down
1 change: 1 addition & 0 deletions ci/cron/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ da_haskell_binary(
"stm-conduit",
"text",
"time",
"typed-process",
"unordered-containers",
"utf8-string",
"vector",
Expand Down
Loading

0 comments on commit e4764cc

Please sign in to comment.