daml/bazel_tools/haskell-windows-extra-libraries.patch
Andreas Herrmann ebd1a7b70b
Add libstdc++ and ws2_32 to base on Windows (#7849)
These libraries have to appear on the linker command line after grpc and
gpr when linking against these. rules_haskell does currently not offer a
way to add extra libraries to the package configration file that are not
themselves Bazel targets. In case of libstdc++ and libws2_32 these are
system libraries that are not explicitly tracked by Bazel. As a
workaround we add these libraries to base's package configuration file.

changelog_begin
changelog_end

Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-10-30 15:37:20 +01:00

34 lines
1.4 KiB
Diff

Some packages, network in particular, require to link additional libraries to
avoid missing symbol errors when linking on Windows.
diff --git a/haskell/private/actions/package.bzl b/haskell/private/actions/package.bzl
index bcb83c73..46148f16 100644
--- a/haskell/private/actions/package.bzl
+++ b/haskell/private/actions/package.bzl
@@ -97,7 +97,12 @@ def package(
"library-dirs": ["${pkgroot}"] + extra_lib_dirs,
"dynamic-library-dirs": ["${pkgroot}"] + extra_dynamic_lib_dirs,
"hs-libraries": [pkg_id.library_name(hs, my_pkg_id)] if has_hs_library else [],
- "extra-libraries": extra_libs,
+ "extra-libraries": extra_libs + ([
+ "stdc++",
+ "crypt32",
+ "shlwapi",
+ "ws2_32",
+ ] if hs.toolchain.is_windows else []),
"depends": hs.package_ids,
"exposed-modules": exposed_modules,
})
diff --git a/haskell/assets/ghc_8_6_5_win_base.patch b/haskell/assets/ghc_8_6_5_win_base.patch
index d870deef..77edb1d2 100644
--- a/haskell/assets/ghc_8_6_5_win_base.patch
+++ b/haskell/assets/ghc_8_6_5_win_base.patch
@@ -5,7 +5,7 @@
hs-libraries: HSbase-4.12.0.0
extra-libraries:
- wsock32 user32 shell32 msvcrt mingw32 mingwex
-+ wsock32 user32 shell32 msvcrt mingw32 mingwex shlwapi
++ wsock32 ws2_32 user32 shell32 msvcrt mingw32 mingwex shlwapi stdc++
include-dirs: $topdir\base-4.12.0.0\include
includes:
HsBase.h