Fix MacOS GHCi issues (#13066)

The trick is extremely simple actually, see the comment for details.
Pretty embarassed that it took me this long to figure it out but
better late than never I guess.

I also upgraded grpc to match our java version and dropped the comment
to keep it in sync with the nix version which we hopefully never need
now. Not strictly required but seemed nice to do at the same time.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2022-02-24 13:26:27 +01:00 committed by GitHub
parent 0583b1879f
commit 267526b627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 10 deletions

View File

@ -32,6 +32,10 @@ SHAKE_VERSION = "0.19.6"
ZIP_VERSION = "1.7.1"
GRPC_HASKELL_REV = "641f0bab046f2f03e5350a7c5f2044af1e19a5b1"
GRPC_HASKELL_SHA256 = "d850d804d7af779bb8717ebe4ea2ac74903a30adeb5262477a2e7a1536f4ca81"
GRPC_HASKELL_PATCHES = [
"@com_github_digital_asset_daml//bazel_tools:grpc-haskell-core-cpp-options.patch",
"@com_github_digital_asset_daml//bazel_tools:grpc-haskell-core-upgrade.patch",
]
XML_CONDUIT_VERSION = "1.9.1.1"
LSP_TYPES_VERSION = "1.4.0.0"
LSP_TYPES_SHA256 = "7ae8a3bad0e91d4a2af9b93e3ad207e3f4c3dace40d420e0592f6323ac93fb67"
@ -168,7 +172,6 @@ haskell_cabal_library(
http_archive(
name = "grpc_haskell_core",
build_file_content = """
load("@com_github_digital_asset_daml//bazel_tools:fat_cc_library.bzl", "fat_cc_library")
load("@com_github_digital_asset_daml//bazel_tools:haskell.bzl", "c2hs_suite")
load("@rules_haskell//haskell:defs.bzl", "haskell_library")
c2hs_suite(
@ -191,13 +194,32 @@ c2hs_suite(
compiler_flags = ["-XCPP", "-Wno-unused-imports", "-Wno-unused-record-wildcards"],
visibility = ["//visibility:public"],
deps = [
":fat_cbits",
"@grpc_haskell_core_cbits//:fat_cbits",
],
)
""",
patch_args = ["-p1"],
patches = GRPC_HASKELL_PATCHES,
sha256 = GRPC_HASKELL_SHA256,
strip_prefix = "gRPC-haskell-{}/core".format(GRPC_HASKELL_REV),
urls = ["https://github.com/awakesecurity/gRPC-haskell/archive/{}.tar.gz".format(GRPC_HASKELL_REV)],
)
# We need to make sure that the cbits are in a different directory
# to get GHCi on MacOS to pick the dynamic library. Otherwise it first looks in the directory
# and it sees libfatcbits.so which has the wrong ending and libfatcbits.a and ends up loading
# the static library which breaks. The GHCi wrapper from rules_haskell actually sets up
# libfatcbits.dylib properly so moving it outside ensures that this is the only option
# for GHCi and things work properly.
http_archive(
name = "grpc_haskell_core_cbits",
build_file_content = """
load("@com_github_digital_asset_daml//bazel_tools:fat_cc_library.bzl", "fat_cc_library")
fat_cc_library(
name = "fat_cbits",
input_lib = "cbits",
visibility = ["//visibility:public"],
)
cc_library(
name = "cbits",
@ -210,10 +232,7 @@ cc_library(
)
""",
patch_args = ["-p1"],
patches = [
"@com_github_digital_asset_daml//bazel_tools:grpc-haskell-core-cpp-options.patch",
"@com_github_digital_asset_daml//bazel_tools:grpc-haskell-core-upgrade.patch",
],
patches = GRPC_HASKELL_PATCHES,
sha256 = GRPC_HASKELL_SHA256,
strip_prefix = "gRPC-haskell-{}/core".format(GRPC_HASKELL_REV),
urls = ["https://github.com/awakesecurity/gRPC-haskell/archive/{}.tar.gz".format(GRPC_HASKELL_REV)],

View File

@ -217,12 +217,11 @@ def daml_deps():
)
if "com_github_grpc_grpc" not in native.existing_rules():
# This should be kept in sync with the grpc version we get from Nix.
http_archive(
name = "com_github_grpc_grpc",
strip_prefix = "grpc-1.43.0",
urls = ["https://github.com/grpc/grpc/archive/v1.43.0.tar.gz"],
sha256 = "9647220c699cea4dafa92ec0917c25c7812be51a18143af047e20f3fb05adddc",
strip_prefix = "grpc-1.44.0",
urls = ["https://github.com/grpc/grpc/archive/v1.44.0.tar.gz"],
sha256 = "8c05641b9f91cbc92f51cc4a5b3a226788d7a63f20af4ca7aaca50d92cc94a0d",
patches = [
"@com_github_digital_asset_daml//bazel_tools:grpc-bazel-mingw.patch",
],