Skip to content

Commit

Permalink
Ghc lib 8.8.0.20190723 (digital-asset#2279)
Browse files Browse the repository at this point in the history
* Upgrade ghc-lib

* Patch bazel_tools : hazel-include-paths patch, no-isystem patch.

* Provide "haskell_c2hs" for package name to cabal_haskell_package

* Package name haskell_c2hs => c2hs.

* Switch to less hacky patch for include dirs
  • Loading branch information
Shayne Fletcher authored and mergify[bot] committed Jul 25, 2019
1 parent 24b8a6d commit ee5079d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/haskell/BUILD.ghc-lib-parser
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ haskell_library(
"-I/compiler", "-I/compiler/utils"
],
package_name = "ghc-lib-parser",
version = "8.8.0.20190704-selective-optimizations-off",
version = "8.8.0.20190723",
)

cc_library(
Expand Down
8 changes: 4 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ HASKELL_LSP_COMMIT = "d73e2ccb518724e6766833ee3d7e73289cbe0018"

HASKELL_LSP_HASH = "36b92431039e6289eb709b8872f5010a57d4a45e637e1c1c945bdb3128586081"

GHC_LIB_VERSION = "8.8.0.20190704"
GHC_LIB_VERSION = "8.8.0.20190723"

http_archive(
name = "haskell_ghc__lib__parser",
build_file = "//3rdparty/haskell:BUILD.ghc-lib-parser",
sha256 = "4a427e093f1711b28b6cf9dd6123e94c9e45589992d67274af626ecfa720308e",
sha256 = "139c5b58d179a806640f8b56bc3fe8c70a893191dbfd111a593544e7ac71086b",
strip_prefix = "ghc-lib-parser-{}".format(GHC_LIB_VERSION),
urls = ["https://digitalassetsdk.bintray.com/ghc-lib/ghc-lib-parser-{}.tar.gz".format(GHC_LIB_VERSION)],
)
Expand Down Expand Up @@ -520,15 +520,15 @@ hazel_repositories(
# Read [Working on ghc-lib] for ghc-lib update
# instructions at
# https://github.com/DACH-NY/daml/blob/master/ghc-lib/working-on-ghc-lib.md.
hazel_ghclibs(GHC_LIB_VERSION, "4a427e093f1711b28b6cf9dd6123e94c9e45589992d67274af626ecfa720308e", "0e4eda986fd3af0e18a2c89719e584d21dce136bcfdad3d0a9effcc6b654c842") +
hazel_ghclibs(GHC_LIB_VERSION, "139c5b58d179a806640f8b56bc3fe8c70a893191dbfd111a593544e7ac71086b", "7cfbe3bd12fb38685b86096ad666790326020308138eaf49198631b8792f5b2a") +

# Support for Hlint:
# - Requires haskell-src-exts 1.21.0 so override hazel/packages.bzl.
# - To build the binary : `bazel build @haskell_hlint//:bin`
# - To build the library : `bazel build @haskell_hlint//:lib`
# We'll be using it via the library, not the binary.
hazel_hackage("haskell-src-exts", "1.21.0", "95dac187824edfa23b6a2363880b5e113df8ce4a641e8a0f76e6d45aaa699ff3") +
hazel_github_external("digital-asset", "hlint", "af5633e777d870819a58a1b1b53be678c0d9fa1a", "b8d91b9770ca6307705bb8449fd980579bb57d8abe84a9472c1431a2a277b87d") +
hazel_github_external("digital-asset", "hlint", "ba2fcd7d926ca6d365a4d0b2c6bc001f84d022b6", "c2693600d7b5912c763907d76eb91fc432a74355e5646313ba1097513340d8fe") +
hazel_github_external("awakesecurity", "proto3-wire", "43d8220dbc64ef7cc7681887741833a47b61070f", "1c3a7fbf4ab3308776675c6202583f9750de496757f3ad4815e81edd122d75e1") +
hazel_github_external("awakesecurity", "proto3-suite", "dd01df7a3f6d0f1ea36125a67ac3c16936b53da0", "59ea7b876b14991347918eefefe24e7f0e064b5c2cc14574ac4ab5d6af6413ca") +
hazel_hackage("happy", "1.19.10", "22eb606c97105b396e1c7dc27e120ca02025a87f3e44d2ea52be6a653a52caed") +
Expand Down
38 changes: 38 additions & 0 deletions bazel_tools/haskell-hazel-include-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
From 094c0a1a37f8131e457b24bdc2f37cd36bde00c0 Mon Sep 17 00:00:00 2001
From: Andreas Herrmann <andreas.herrmann@tweag.io>
Date: Wed, 24 Jul 2019 09:41:43 +0200
Subject: [PATCH] Hazel: Fix includeDirs

Hazel was adding bogus -I/<include-dir> flags, when instead it should be
-Iexternal/haskell_<package_name>/<include-dir>.
---
hazel/third_party/cabal2bazel/bzl/cabal_package.bzl | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
index 0e8238d8..1e177311 100644
--- a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
+++ b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl
@@ -453,6 +453,12 @@ def _get_build_attrs(
] +
install_includes,
)
- ghcopts += ["-I" + native.package_name() + "/" + d for d in build_info.includeDirs]
+ # repository_name starts with @, strip that bit off. Adding the include
+ # directories to the cc_library below alone is not sufficient. The includes
+ # attribute ends up in -isystem include flags. However, some Haskell
+ # libraries attempt to include headers using #include "" syntax instead of
+ # #include <>.
+ includeOpts = ["-I" + paths.join("external", native.repository_name()[1:], native.package_name(), i) for i in build_info.includeDirs]
+ ghcopts += includeOpts
for xs in deps.values():
xs.append(cbits_name)

@@ -474,6 +480,7 @@ def _get_build_attrs(
srcs = build_info.cSources,
includes = build_info.includeDirs,
copts = ([o for o in build_info.ccOptions if not o.startswith("-D")] +
+ includeOpts +
[
"-D__GLASGOW_HASKELL__=" + ghc_version_string,
"-w",
13 changes: 13 additions & 0 deletions bazel_tools/haskell-no-isystem.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/haskell/cc.bzl b/haskell/cc.bzl
index cd42613..6c3e53a 100644
--- a/haskell/cc.bzl
+++ b/haskell/cc.bzl
@@ -59,7 +59,7 @@ def cc_interop_info(ctx):
] + [
f
for include in cc_ctx.system_includes.to_list()
- for f in ["-isystem", include]
+ for f in ["-I", include]
],
)

8 changes: 8 additions & 0 deletions compiler/hie-core/src/Development/IDE/GHC/CPP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import Module
import DynFlags
import Panic
import FileCleanup
#ifndef GHC_STABLE
import LlvmCodeGen (LlvmVersion (..))
#endif

import System.Directory
import System.FilePath
Expand Down Expand Up @@ -130,7 +133,12 @@ getBackendDefs :: DynFlags -> IO [String]
getBackendDefs dflags | hscTarget dflags == HscLlvm = do
llvmVer <- figureLlvmVersion dflags
return $ case llvmVer of
#ifdef GHC_STABLE
Just n -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format n ]
#else
Just (LlvmVersion n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (n,0) ]
Just (LlvmVersionOld m n) -> [ "-D__GLASGOW_HASKELL_LLVM__=" ++ format (m,n) ]
#endif
_ -> []
where
format (major, minor)
Expand Down
5 changes: 5 additions & 0 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def daml_deps():
"@com_github_digital_asset_daml//bazel_tools:haskell-ghci-grpc.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell_public_ghci_repl_wrapper.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-windows-library-dirs.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-no-isystem.patch",
],
patch_args = ["-p1"],
sha256 = rules_haskell_sha256,
Expand All @@ -66,6 +67,10 @@ def daml_deps():
strip_prefix = "rules_haskell-{}/hazel".format(rules_haskell_version),
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % rules_haskell_version],
sha256 = rules_haskell_sha256,
patches = [
"@com_github_digital_asset_daml//bazel_tools:haskell-hazel-include-paths.patch",
],
patch_args = ["-p2"],
)

if "com_github_madler_zlib" not in native.existing_rules():
Expand Down

0 comments on commit ee5079d

Please sign in to comment.