Update rules_haskell (#828)

- Includes -optP response file patch
- Removes noise around version macros
This commit is contained in:
Andreas Herrmann 2019-05-02 11:54:24 +02:00 committed by mergify[bot]
parent 6ac0931a25
commit 3f3bd4b1bb
3 changed files with 16 additions and 49 deletions

View File

@ -1,32 +0,0 @@
Some targets use a lot of space for -optP flags, so put them in a response file
diff --git a/haskell/private/actions/compile.bzl b/haskell/private/actions/compile.bzl
index 20c8720..7fca51c 100644
--- a/haskell/private/actions/compile.bzl
+++ b/haskell/private/actions/compile.bzl
@@ -213,7 +213,17 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, srcs, import_
set.mutable_insert(import_dirs, idir)
ghc_args += ["-i{0}".format(d) for d in set.to_list(import_dirs)]
- ghc_args += ["-optP" + f for f in cc.cpp_flags]
+
+ # Write the -optP flags to a response because they can be very long on Windows
+ # e.g. 27Kb for grpc-haskell
+ # Equivalent to: ghc_args += ["-optP" + f for f in cc.cpp_flags]
+ optp_args_file = hs.actions.declare_file("optp_args_%s" % hs.name)
+ optp_args = hs.actions.args()
+ optp_args.add_all(cc.cpp_flags)
+ optp_args.set_param_file_format("multiline")
+ hs.actions.write(optp_args_file, optp_args)
+ ghc_args += ["-optP@" + optp_args_file.path]
+
ghc_args += cc.include_args
locale_archive_depset = (
@@ -326,6 +336,7 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, srcs, import_
java.inputs,
locale_archive_depset,
depset(transitive = plugin_tool_inputs),
+ depset([optp_args_file]),
]),
input_manifests = plugin_tool_input_manifests,
objects_dir = objects_dir,

View File

@ -5,19 +5,19 @@ index 7fca51c..1e8b78e 100644
@@ -1,6 +1,6 @@
"""Actions for compiling Haskell source code"""
-load(":private/packages.bzl", "expose_packages", "pkg_info_to_ghc_args")
+load(":private/packages.bzl", "expose_packages", "pkg_info_to_ghc_args", "pkg_info_to_ghc_env_args")
-load(":private/packages.bzl", "expose_packages", "pkg_info_to_compile_flags")
+load(":private/packages.bzl", "expose_packages", "pkg_info_to_compile_flags", "pkg_info_to_ghc_env_args")
load("@bazel_skylib//lib:dicts.bzl", "dicts")
load("@bazel_skylib//lib:paths.bzl", "paths")
load(
@@ -149,18 +149,28 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, srcs, import_
@@ -150,18 +150,28 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, srcs, import_
if hs.toolchain.is_darwin:
ghc_args += ["-optl-Wl,-dead_strip_dylibs"]
compile_flags += ["-optl-Wl,-dead_strip_dylibs"]
- ghc_args.extend(
- pkg_info_to_ghc_args(
- compile_flags.extend(
- pkg_info_to_compile_flags(
- expose_packages(
+ ghc_args.extend(["-hide-all-packages"])
+ compile_flags.extend(["-hide-all-packages"])
+
+ package_env_file = hs.actions.declare_file("package_env_%s" % hs.name)
+ package_args = hs.actions.args()
@ -28,7 +28,7 @@ index 7fca51c..1e8b78e 100644
lib_info = None,
use_direct = True,
use_my_pkg_id = my_pkg_id,
custom_package_caches = None,
custom_package_databases = None,
version = version,
- ),
),
@ -36,12 +36,12 @@ index 7fca51c..1e8b78e 100644
+ package_args.add_all(package_env_args)
+ package_args.set_param_file_format("multiline")
+ hs.actions.write(package_env_file, package_args)
+ ghc_args.extend(["-package-env", package_env_file])
+ ghc_args.extend(other_args)
+ compile_flags.extend(["-package-env", package_env_file])
+ compile_flags.extend(other_args)
+
+ # Plugin arguments cannot be redirected via package environment files afaict.
ghc_args.extend(
pkg_info_to_ghc_args(
compile_flags.extend(
pkg_info_to_compile_flags(
expose_packages(
@@ -337,6 +347,7 @@ def _compilation_defaults(hs, cc, java, dep_info, plugin_dep_info, srcs, import_
locale_archive_depset,
@ -55,7 +55,7 @@ diff --git a/haskell/private/packages.bzl b/haskell/private/packages.bzl
index 91236fc..6d7a073 100644
--- a/haskell/private/packages.bzl
+++ b/haskell/private/packages.bzl
@@ -41,6 +41,42 @@ def pkg_info_to_ghc_args(pkg_info, for_plugin = False):
@@ -41,6 +41,42 @@ def pkg_info_to_compile_flags(pkg_info, for_plugin = False):
return args
@ -95,6 +95,6 @@ index 91236fc..6d7a073 100644
+
+ return package_env_args, other_args
+
def expose_packages(build_info, lib_info, use_direct, use_my_pkg_id, custom_package_caches, version):
def expose_packages(hs_info, lib_info, use_direct, use_my_pkg_id, custom_package_databases, version):
"""
Returns the information that is needed by GHC in order to enable haskell

View File

@ -27,8 +27,8 @@
# be resolvable from external workspaces otherwise.
rules_scala_version = "6f8ee3d951d2ac6154356314600f6edb4eb5df8b"
rules_haskell_version = "23eaaa8c85d908fb3ccc69b470d3730dcef165a0"
rules_haskell_sha256 = "9fab4f50a0ea0e02d98c918fdf0859cf0f6828b6dbf167c7acb1293cd2b37d65"
rules_haskell_version = "6c550c8eb7ce7950e702420be39d932b8b31ef22"
rules_haskell_sha256 = "aef68cf5d732b2fa9ae0efea344cb83cb0c16f0f08a8d6901776a0085fbe7a8b"
rules_nixpkgs_version = "40b5a9f23abca57f364c93245c7451206ef1a855"
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
@ -42,7 +42,6 @@ def daml_deps():
urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % rules_haskell_version],
patches = [
"@com_github_digital_asset_daml//bazel_tools:haskell-static-linking.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-optp-response.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-package-env.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-win-sys-includes.patch",
"@com_github_digital_asset_daml//bazel_tools:haskell-drop-fake-static.patch",