Fix Windows linking issues (#13097)

I have to admit I still fdon’t fully understand why this sometimes
fails and sometimes doesn’t. It looks like some caching issue is
involved (e.g. currently builds in /d/a/2 succeed while builds in
/d/a/1 succed) but I’m not entirely sure that’s all.

This PR tries to address this in two ways:

1. Add the library when linking the Haskell bits instead of only on
the C library. I think this is required since we the final Haskell
binary is linked against the static cbits which does not carry a
reference to bcrypt but I’m not completely sure.
2. Rename the target to avoid interference with builds from before the
grpc upgrade. I suspect what is happening is that due to the lack of
sandboxing we sometimes end up picking up that library if it is in the
build tree from an older build instead of the new one.

changelog_begin
changelog_end
This commit is contained in:
Moritz Kiefer 2022-02-28 08:35:30 +01:00 committed by GitHub
parent 1783146c9e
commit 8a7aaa0c3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View File

@ -194,7 +194,7 @@ c2hs_suite(
compiler_flags = ["-XCPP", "-Wno-unused-imports", "-Wno-unused-record-wildcards"], compiler_flags = ["-XCPP", "-Wno-unused-imports", "-Wno-unused-record-wildcards"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"@grpc_haskell_core_cbits//:fat_cbits", "@grpc_haskell_core_cbits//:merged_cbits",
], ],
) )
""", """,
@ -217,7 +217,7 @@ c2hs_suite(
load("@com_github_digital_asset_daml//bazel_tools:fat_cc_library.bzl", "fat_cc_library") load("@com_github_digital_asset_daml//bazel_tools:fat_cc_library.bzl", "fat_cc_library")
fat_cc_library( fat_cc_library(
name = "fat_cbits", name = "merged_cbits",
input_lib = "cbits", input_lib = "cbits",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View File

@ -56,7 +56,7 @@ def _fat_cc_library_impl(ctx):
["-lstdc++"] + ["-lstdc++"] +
(["-framework", "CoreFoundation"] if is_darwin else []) + (["-framework", "CoreFoundation"] if is_darwin else []) +
# On Windows we have some extra deps. # On Windows we have some extra deps.
(["-lbcrypt", "-lDbgHelp", "-lws2_32"] if is_windows else []), (["-lws2_32"] if is_windows else []),
inputs = static_libs, inputs = static_libs,
env = {"PATH": ""}, env = {"PATH": ""},
) )

View File

@ -2,7 +2,7 @@ diff --git a/haskell/private/actions/package.bzl b/haskell/private/actions/packa
index fddf30fd..564da872 100644 index fddf30fd..564da872 100644
--- a/haskell/private/actions/package.bzl --- a/haskell/private/actions/package.bzl
+++ b/haskell/private/actions/package.bzl +++ b/haskell/private/actions/package.bzl
@@ -105,7 +105,12 @@ def package( @@ -105,7 +105,13 @@ def package(
"library-dirs": [pkgroot_lib_path] + extra_lib_dirs, "library-dirs": [pkgroot_lib_path] + extra_lib_dirs,
"dynamic-library-dirs": [pkgroot_lib_path] + extra_dynamic_lib_dirs, "dynamic-library-dirs": [pkgroot_lib_path] + extra_dynamic_lib_dirs,
"hs-libraries": [pkg_id.library_name(hs, my_pkg_id)] if has_hs_library else [], "hs-libraries": [pkg_id.library_name(hs, my_pkg_id)] if has_hs_library else [],
@ -12,6 +12,7 @@ index fddf30fd..564da872 100644
+ "crypt32", + "crypt32",
+ "shlwapi", + "shlwapi",
+ "ws2_32", + "ws2_32",
+ "bcrypt",
+ ] if hs.toolchain.is_windows else []), + ] if hs.toolchain.is_windows else []),
"depends": hs.package_ids, "depends": hs.package_ids,
# TODO[AH] Add haskell_module modules # TODO[AH] Add haskell_module modules