mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 17:28:46 +03:00
117f043698
* Update rules_haskell This updates to the latest rules_haskell, which fixes a few issues on Windows. Most importantly it flags a few Windows libraries as "system" libraries, preventing Hazel to fail because they are not provided through Bazel. * Fix the streaming-commons build on Windows This modifies our custom streaming-commons BUILD file to make it work on Windows. In particular it swaps some system libraries, passes the `-DWINDOWS` flag and enables the build of an extra module. * Clean up bazel_tools BUILD file This wraps a very long line for legibility. * Fix shared object issues on Windows * This fixes rules_haskell to use the correct Windows path separator on Windows. GHC expects the LD_LIBRARY_PATH variable to be a list of semi-colon separated paths, as opposed to a list of colon separated paths:51fd357119/compiler/ghci/Linker.hs (L1646-L1650)
* This fixes the name of Haskell shared objects on Windows. By default Bazel's cc_library generates '.so' files, whereas GHC expects a `.dll` (or a few other extensions, non of which are `.so`):51fd357119/rts/linker/PEi386.c (L684)
* Build daml-lf-ast on Windows CI
79 lines
2.9 KiB
Diff
79 lines
2.9 KiB
Diff
This fixes the name of Haskell shared objects on Windows. By default Bazel's
|
|
cc_library generates '.so' files, whereas GHC expects a `.dll` (or a few other
|
|
extensions, non of which are `.so`):
|
|
https://github.com/ghc/ghc/blob/51fd357119b357c52e990ccce9059c423cc49406/rts/linker/PEi386.c#L684
|
|
|
|
Drop this patch when this issue is closed:
|
|
https://github.com/tweag/rules_haskell/issues/811
|
|
|
|
diff --git a/haskell/private/path_utils.bzl b/haskell/private/path_utils.bzl
|
|
index e0af527..9b61fd2 100644
|
|
--- a/haskell/private/path_utils.bzl
|
|
+++ b/haskell/private/path_utils.bzl
|
|
@@ -160,6 +160,39 @@ def darwin_convert_to_dylibs(hs, libs):
|
|
new_libs.append(lib)
|
|
return new_libs
|
|
|
|
+def windows_convert_to_dlls(hs, libs):
|
|
+ """Convert .so dynamic libraries to .dll.
|
|
+
|
|
+ Bazel's cc_library rule will create .so files for dynamic libraries even
|
|
+ on Windows. GHC's builtin linker, which is used during compilation, GHCi,
|
|
+ or doctests, hard-codes the assumption that all dynamic libraries on Windows
|
|
+ end on .dll. This function serves as an adaptor and produces symlinks
|
|
+ from a .dll version to the .so version for every dynamic library
|
|
+ dependencies that does not end on .dll.
|
|
+
|
|
+ Args:
|
|
+ hs: Haskell context.
|
|
+ libs: List of library files dynamic or static.
|
|
+
|
|
+ Returns:
|
|
+ List of library files where all dynamic libraries end on .dll.
|
|
+ """
|
|
+ lib_prefix = "_dlls"
|
|
+ new_libs = []
|
|
+ for lib in libs:
|
|
+ if is_shared_library(lib) and lib.extension != "dll":
|
|
+ dll_name = paths.join(
|
|
+ target_unique_name(hs, lib_prefix),
|
|
+ lib.dirname,
|
|
+ "lib" + get_lib_name(lib) + ".dll",
|
|
+ )
|
|
+ dll = hs.actions.declare_file(dll_name)
|
|
+ ln(hs, lib, dll)
|
|
+ new_libs.append(dll)
|
|
+ else:
|
|
+ new_libs.append(lib)
|
|
+ return new_libs
|
|
+
|
|
def get_lib_name(lib):
|
|
"""Return name of library by dropping extension and "lib" prefix.
|
|
|
|
diff --git a/haskell/private/providers.bzl b/haskell/private/providers.bzl
|
|
index bc35217..d9d55dd 100644
|
|
--- a/haskell/private/providers.bzl
|
|
+++ b/haskell/private/providers.bzl
|
|
@@ -1,6 +1,7 @@
|
|
load(
|
|
":private/path_utils.bzl",
|
|
"darwin_convert_to_dylibs",
|
|
+ "windows_convert_to_dlls",
|
|
"is_shared_library",
|
|
"make_path",
|
|
)
|
|
@@ -144,6 +145,13 @@ def get_libs_for_ghc_linker(hs, transitive_cc_dependencies, path_prefix = None):
|
|
|
|
# Additionally ghc 8.4 requires library_deps here although 8.6 does not
|
|
ld_library_deps = library_deps + _ld_library_deps
|
|
+
|
|
+ elif hs.toolchain.is_windows:
|
|
+ # GHC's builtin linker requires .dll files on Windows.
|
|
+ library_deps = windows_convert_to_dlls(hs, _library_deps)
|
|
+
|
|
+ # copied over from Darwin 5 lines above
|
|
+ ld_library_deps = library_deps + _ld_library_deps
|
|
else:
|
|
library_deps = _library_deps
|
|
ld_library_deps = _ld_library_deps
|