diff --git a/bazel_tools/haskell-cc-toolchain.patch b/bazel_tools/haskell-cc-toolchain.patch deleted file mode 100644 index 3708c98aaa9..00000000000 --- a/bazel_tools/haskell-cc-toolchain.patch +++ /dev/null @@ -1,238 +0,0 @@ -diff --git a/haskell/CROSSTOOL.windows b/haskell/CROSSTOOL.windows -deleted file mode 100644 -index ae16776..0000000 ---- a/haskell/CROSSTOOL.windows -+++ /dev/null -@@ -1,49 +0,0 @@ --major_version: "local" --minor_version: "" -- --toolchain { -- toolchain_identifier: "ghc_windows_mingw64" -- abi_version: "local" -- abi_libc_version: "local" -- builtin_sysroot: "" -- compiler: "ghc-mingw-gcc" -- host_system_name: "local" -- needsPic: false -- target_libc: "mingw" -- target_cpu: "x64_windows" -- target_system_name: "local" -- -- artifact_name_pattern { -- category_name: 'executable' -- prefix: '' -- extension: '.exe' -- } -- -- tool_path { name: "ar" path: "mingw/bin/ar" } -- tool_path { name: "compat-ld" path: "mingw/bin/ld" } -- tool_path { name: "cpp" path: "mingw/bin/cpp" } -- tool_path { name: "dwp" path: "mingw/bin/dwp" } -- tool_path { name: "gcc" path: "mingw/bin/gcc" } -- tool_path { name: "gcov" path: "mingw/bin/gcov" } -- tool_path { name: "ld" path: "mingw/bin/ld" } -- tool_path { name: "nm" path: "mingw/bin/nm" } -- tool_path { name: "objcopy" path: "mingw/bin/objcopy" } -- tool_path { name: "objdump" path: "mingw/bin/objdump" } -- tool_path { name: "strip" path: "mingw/bin/strip" } -- cxx_builtin_include_directory: "mingw" -- cxx_flag: "-std=gnu++0x" -- -- # Needed to prevent Bazel from complaining about undeclared inclusions of -- # MingW headers. -- # -- # See: https://github.com/bazelbuild/bazel/issues/4605 -- unfiltered_cxx_flag: "-no-canonical-prefixes" -- unfiltered_cxx_flag: "-fno-canonical-system-headers" -- -- linker_flag: "-lstdc++" -- objcopy_embed_flag: "-I" -- objcopy_embed_flag: "binary" -- feature { name: "targets_windows" implies: "copy_dynamic_libraries_to_binary" enabled: true } -- feature { name: "copy_dynamic_libraries_to_binary" } -- linking_mode_flags { mode: DYNAMIC } --} -diff --git a/haskell/cc_toolchain_config.bzl b/haskell/cc_toolchain_config.bzl -new file mode 100644 -index 0000000..cb6b9c0 ---- /dev/null -+++ b/haskell/cc_toolchain_config.bzl -@@ -0,0 +1,107 @@ -+load( -+ "@bazel_tools//tools/build_defs/cc:action_names.bzl", -+ "ACTION_NAMES", -+) -+load( -+ "@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl", -+ "artifact_name_pattern", -+ "feature", -+ "flag_group", -+ "flag_set", -+ "tool_path", -+) -+ -+def _impl(ctx): -+ tool_paths = [ -+ tool_path( -+ name = "ar", -+ path = "mingw/bin/ar", -+ ), -+ tool_path( -+ name = "compat-ld", -+ path = "mingw/bin/ld", -+ ), -+ tool_path( -+ name = "cpp", -+ path = "mingw/bin/cpp", -+ ), -+ tool_path( -+ name = "dwp", -+ path = "mingw/bin/dwp", -+ ), -+ tool_path( -+ name = "gcc", -+ path = "mingw/bin/gcc", -+ ), -+ tool_path( -+ name = "gcov", -+ path = "mingw/bin/gcov", -+ ), -+ tool_path( -+ name = "ld", -+ path = "mingw/bin/ld", -+ ), -+ tool_path( -+ name = "nm", -+ path = "mingw/bin/nm", -+ ), -+ tool_path( -+ name = "objcopy", -+ path = "mingw/bin/objcopy", -+ ), -+ tool_path( -+ name = "objdump", -+ path = "mingw/bin/objdump", -+ ), -+ tool_path( -+ name = "strip", -+ path = "mingw/bin/strip", -+ ), -+ ] -+ artifact_name_patterns = [ -+ artifact_name_pattern( -+ category_name = "executable", -+ prefix = "", -+ extension = ".exe", -+ ), -+ ] -+ default_link_flags_feature = feature( -+ name = "default_link_flags", -+ enabled = True, -+ flag_sets = [ -+ flag_set( -+ actions = [ -+ ACTION_NAMES.cpp_link_executable, -+ ACTION_NAMES.cpp_link_dynamic_library, -+ ACTION_NAMES.cpp_link_nodeps_dynamic_library, -+ ], -+ flag_groups = [ -+ flag_group( -+ flags = [ -+ "-lstdc++", -+ ], -+ ), -+ ], -+ ), -+ ], -+ ) -+ return cc_common.create_cc_toolchain_config_info( -+ ctx = ctx, -+ toolchain_identifier = "ghc_windows_mingw64", -+ host_system_name = "local", -+ target_system_name = "local", -+ target_cpu = "x64_windows", -+ target_libc = "local", -+ compiler = "ghc-mingw-gcc", -+ abi_version = "local", -+ abi_libc_version = "local", -+ tool_paths = tool_paths, -+ artifact_name_patterns = artifact_name_patterns, -+ features = [default_link_flags_feature], -+ ) -+ -+cc_toolchain_config = rule( -+ implementation = _impl, -+ attrs = {}, -+ provides = [CcToolchainConfigInfo], -+) -diff --git a/haskell/ghc.BUILD b/haskell/ghc.BUILD -index 67a42b0..5c44e4f 100644 ---- a/haskell/ghc.BUILD -+++ b/haskell/ghc.BUILD -@@ -1,3 +1,5 @@ -+load("@io_tweag_rules_haskell//haskell:cc_toolchain_config.bzl", "cc_toolchain_config") -+ - package(default_visibility = ["//visibility:public"]) - - filegroup( -@@ -54,8 +56,8 @@ cc_library( - # Expose embedded MinGW toolchain when on Windows. - - filegroup( -- name = "empty", -- srcs = [], -+ name = "mingw", -+ srcs = glob(["mingw/**"]), - ) - - cc_toolchain_suite( -@@ -69,15 +71,20 @@ cc_toolchain_suite( - # Keep in sync with @bazel_tools//cpp:cc-compiler-x64_windows definition. - cc_toolchain( - name = "cc-compiler-mingw64", -- all_files = ":empty", -- ar_files = ":empty", -- as_files = ":empty", -- compiler_files = ":empty", -+ all_files = ":mingw", -+ ar_files = ":mingw", -+ as_files = ":mingw", -+ compiler_files = ":mingw", - cpu = "x64_windows", -- dwp_files = ":empty", -- linker_files = ":empty", -- objcopy_files = ":empty", -- strip_files = ":empty", -+ dwp_files = ":mingw", -+ dynamic_runtime_libs = [":mingw"], -+ linker_files = ":mingw", -+ objcopy_files = ":mingw", -+ static_runtime_libs = [":mingw"], -+ strip_files = ":mingw", - supports_param_files = 0, -+ toolchain_config = ":ghc_windows_mingw64_config", - toolchain_identifier = "ghc_windows_mingw64", - ) -+ -+cc_toolchain_config(name = "ghc_windows_mingw64_config") -diff --git a/haskell/ghc_bindist.bzl b/haskell/ghc_bindist.bzl -index 7766239..af55a1f 100644 ---- a/haskell/ghc_bindist.bzl -+++ b/haskell/ghc_bindist.bzl -@@ -182,7 +182,6 @@ def _ghc_bindist_impl(ctx): - # Avoid rule restart by resolving these labels early. See - # https://github.com/bazelbuild/bazel/blob/master/tools/cpp/lib_cc_configure.bzl#L17. - ghc_build = ctx.path(Label("//haskell:ghc.BUILD")) -- crosstool_windows = ctx.path(Label("//haskell:CROSSTOOL.windows")) - - version = ctx.attr.version - target = ctx.attr.target -@@ -230,7 +229,6 @@ grep -lZ {bindist_dir} bin/* | xargs -0 --verbose \\ - ghc_build, - executable = False, - ) -- ctx.template("CROSSTOOL", crosstool_windows, executable = False) - - _ghc_bindist = repository_rule( - _ghc_bindist_impl, diff --git a/bazel_tools/haskell-short-names.patch b/bazel_tools/haskell-short-names.patch deleted file mode 100644 index bc0e422323f..00000000000 --- a/bazel_tools/haskell-short-names.patch +++ /dev/null @@ -1,121 +0,0 @@ -diff --git a/haskell/haskell.bzl b/haskell/haskell.bzl -index 61994e4..7b05a9c 100644 ---- a/haskell/haskell.bzl -+++ b/haskell/haskell.bzl -@@ -243,6 +243,11 @@ haskell_library = rule( - default = False, - doc = "Create a static library, not both a static and a shared library.", - ), -+ package_name = attr.string( -+ doc = """Library name used in version macro generation. Only used -+ if the version attribute is defined, see version attribute -+ documentation. Optional, defaults to target name.""", -+ ), - version = attr.string( - doc = """Library version. Not normally necessary unless to build a library - originally defined as a Cabal package. If this is specified, CPP version macro will be generated.""", -diff --git a/haskell/private/actions/package.bzl b/haskell/private/actions/package.bzl -index 1c438e8..bdcdfdd 100644 ---- a/haskell/private/actions/package.bzl -+++ b/haskell/private/actions/package.bzl -@@ -81,7 +81,7 @@ def package( - (extra_lib_dirs, extra_libs) = _get_extra_libraries(dep_info) - - metadata_entries = { -- "name": my_pkg_id.name, -+ "name": my_pkg_id.package_name, - "version": my_pkg_id.version, - "id": pkg_id.to_string(my_pkg_id), - "key": pkg_id.to_string(my_pkg_id), -diff --git a/haskell/private/haskell_impl.bzl b/haskell/private/haskell_impl.bzl -index 2f107a3..e2db3f5 100644 ---- a/haskell/private/haskell_impl.bzl -+++ b/haskell/private/haskell_impl.bzl -@@ -313,8 +313,9 @@ def haskell_library_impl(ctx): - ctx, - [dep for plugin in ctx.attr.plugins for dep in plugin[GhcPluginInfo].deps], - ) -- version = ctx.attr.version if ctx.attr.version else None -- my_pkg_id = pkg_id.new(ctx.label, version) -+ package_name = getattr(ctx.attr, "package_name", None) -+ version = getattr(ctx.attr, "version", None) -+ my_pkg_id = pkg_id.new(ctx.label, package_name, version) - with_profiling = is_profiling_enabled(hs) - with_shared = False if hs.toolchain.is_windows else not ctx.attr.linkstatic - -@@ -445,7 +446,7 @@ def haskell_library_impl(ctx): - version_macros = set.empty() - if version != None: - version_macros = set.singleton( -- generate_version_macros(ctx, hs.name, version), -+ generate_version_macros(ctx, getattr(ctx.attr, "package_name", hs.name), version), - ) - - hs_info = HaskellInfo( -diff --git a/haskell/private/pkg_id.bzl b/haskell/private/pkg_id.bzl -index 0a3c5fa..a7cbec1 100644 ---- a/haskell/private/pkg_id.bzl -+++ b/haskell/private/pkg_id.bzl -@@ -27,7 +27,7 @@ def _to_string(my_pkg_id): - ), - ) - --def _new(label, version = None): -+def _new(label, package_name = None, version = None): - """Create a new package identifier. - - Package identifiers should be globally unique. This is why we use -@@ -35,15 +35,18 @@ def _new(label, version = None): - - Args: - label: The label of the rule declaring the package. -+ package_name: an optional override of the package name. - version: an optional version annotation. - - Returns: - string: GHC package ID to use. - - """ -+ name = label.name.replace("_", "-") - return struct( - label = label, -- name = label.name.replace("_", "-"), -+ name = name, -+ package_name = package_name if package_name else name, - version = version, - ) - -diff --git a/haskell/private/version_macros.bzl b/haskell/private/version_macros.bzl -index 35f913f..dbdcbb5 100644 ---- a/haskell/private/version_macros.bzl -+++ b/haskell/private/version_macros.bzl -@@ -1,17 +1,17 @@ - load(":private/set.bzl", "set") - --def generate_version_macros(ctx, name, version): -+def generate_version_macros(ctx, pkg_name, version): - """Generate a version macros header file. - - Args: - ctx: Rule context. Needs to define a _version_macros executable attribute. -- name: The package name. -+ pkg_name: The package name. - version: The package version. - - Returns: - Version macros header File. - """ -- version_macros_file = ctx.actions.declare_file("{}_version_macros.h".format(name)) -+ version_macros_file = ctx.actions.declare_file("{}_version_macros.h".format(ctx.attr.name)) - ctx.actions.run_shell( - inputs = [ctx.executable._version_macros], - outputs = [version_macros_file], -@@ -20,7 +20,7 @@ def generate_version_macros(ctx, name, version): - """, - arguments = [ - ctx.executable._version_macros.path, -- name, -+ pkg_name, - version, - version_macros_file.path, - ], diff --git a/bazel_tools/hazel-cc-toolchain.patch b/bazel_tools/hazel-cc-toolchain.patch deleted file mode 100644 index d5c38373f21..00000000000 --- a/bazel_tools/hazel-cc-toolchain.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/hazel/third_party/haskell/BUILD.zlib b/hazel/third_party/haskell/BUILD.zlib -index 623ecd5..a992510 100644 ---- a/hazel/third_party/haskell/BUILD.zlib -+++ b/hazel/third_party/haskell/BUILD.zlib -@@ -10,7 +10,7 @@ cc_library( - name = "zlib-cbits", - hdrs = glob(["cbits/*.h"]), - srcs = glob(["cbits/*.c"]), -- strip_include_prefix = "cbits", -+ includes = ["cbits"], - ) - - haskell_library( diff --git a/bazel_tools/hazel-configure.patch b/bazel_tools/hazel-configure.patch deleted file mode 100644 index e96bac84962..00000000000 --- a/bazel_tools/hazel-configure.patch +++ /dev/null @@ -1,207 +0,0 @@ -diff --git a/hazel/hazel_base_repository/cabal2bazel.hs b/hazel/hazel_base_repository/cabal2bazel.hs -index 282bb71..7723f0e 100644 ---- a/hazel/hazel_base_repository/cabal2bazel.hs -+++ b/hazel/hazel_base_repository/cabal2bazel.hs -@@ -13,23 +13,18 @@ module Main (main) where - - #if MIN_VERSION_Cabal(2,2,0) - import Distribution.PackageDescription.Parsec -- (readGenericPackageDescription, parseHookedBuildInfo, runParseResult) --import qualified Data.ByteString.Char8 as BS.C8 -+ (readGenericPackageDescription) - #else - import Distribution.PackageDescription.Parse -- (readGenericPackageDescription, parseHookedBuildInfo, ParseResult(..)) -+ (readGenericPackageDescription) - #endif - --import Distribution.Text (display, simpleParse) -+import Distribution.Text (simpleParse) - import Distribution.Verbosity (normal) - import System.Environment (getArgs) --import System.FilePath ((<.>)) --import System.Process (callProcess) - - import qualified Data.Map.Strict as Map --import qualified Distribution.Package as P - import qualified Distribution.PackageDescription as P --import qualified System.Directory as Directory - - import Description - import Flatten -@@ -43,7 +38,7 @@ main = do - Nothing -> error $ "Error parsing ghc version: " ++ show ghcVersionStr - Just v -> v - packageFlags = parseFlags flagArgs -- desc <- maybeConfigure $ flattenToDefaultFlags ghcVersion packageFlags gdesc -+ desc = flattenToDefaultFlags ghcVersion packageFlags gdesc - writeFile outFile $ show $ renderStatements - [Assign "package" $ packageDescriptionExpr desc] - -@@ -52,37 +47,3 @@ parseFlags = \case - "-flag-on":flag:etc -> Map.insert (P.mkFlagName flag) True (parseFlags etc) - "-flag-off":flag:etc -> Map.insert (P.mkFlagName flag) False (parseFlags etc) - _ -> Map.empty -- --maybeConfigure :: P.PackageDescription -> IO P.PackageDescription --maybeConfigure desc = whenConfiguring $ do -- callProcess "./configure" [] -- let buildInfoFile = display (P.packageName desc) <.> "buildinfo" -- buildInfoExists <- Directory.doesFileExist buildInfoFile -- if buildInfoExists -- then processBuildInfoFile buildInfoFile -- else return desc -- where --#if MIN_VERSION_Cabal(2,2,0) -- whenConfiguring m = case P.buildType desc of -- P.Configure -> m -- _ -> return desc -- -- processBuildInfoFile buildInfoFile = do -- cs <- BS.C8.readFile buildInfoFile -- case runParseResult (parseHookedBuildInfo cs) of -- (_warnings, Left (_maybeVersion, es)) -> -- error $ "Error reading buildinfo " ++ show buildInfoFile ++ ": " ++ show es -- (_warnings, Right hookedBI) -> -- return $ P.updatePackageDescription hookedBI desc --#else -- whenConfiguring m = case P.buildType desc of -- Just P.Configure -> m -- _ -> return desc -- -- processBuildInfoFile buildInfoFile = do -- cs <- readFile buildInfoFile -- case parseHookedBuildInfo cs of -- ParseFailed e -> error $ "Error reading buildinfo " ++ show buildInfoFile -- ++ ": " ++ show e -- ParseOk _ hookedBI -> return $ P.updatePackageDescription hookedBI desc --#endif -diff --git a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -index 16d5c3b..50a9890 100644 ---- a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -+++ b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -@@ -71,6 +71,44 @@ def _get_core_dependency_includes(ghc_workspace): - "unix": "{}//:unix-includes".format(ghc_workspace), - } - -+# Some packages, such as network, include the config.log and config.status -+# files, generated by the ./configure script, in their extraTmpFiles. These -+# files contain information specific to the build host, which defeates -+# distributed caching. Here we black-list any such files and exclude them -+# from the headers attribute to cc_library. -+_header_blacklist = [ -+ "autom4te.cache", -+ "config.log", -+ "config.status", -+] -+ -+def _configure(desc): -+ outputs = [ -+ f -+ for f in desc.extraTmpFiles -+ if f.split("/")[-1] not in _header_blacklist -+ ] -+ native.genrule( -+ name = "run-configure", -+ cmd = '\n'.join([ -+ # Run configure in it's containing directory, so that generated -+ # files are in the right location. Fixup a relative path to CC to -+ # take the new working directory into account (relative paths -+ # remain relative). -+ '( UP="$$(sed \'s/[^\\/]\\+/../g\' <<<"$$(dirname "$(location configure)")")" && \\', -+ ' fixpath() { case "$$1" in /*) echo "$$1" ;; *) echo "$$UP/$$1" ;; esac; } && \\', -+ ' cd "$$(dirname "$(location configure)")" && \\', -+ ' PATH="$$(fixpath "$$(dirname "$(CC)")"):$$PATH" CC="$$(fixpath "$(CC)")" CFLAGS="$(CC_FLAGS)" ./configure )', -+ ] + [ -+ 'mkdir -p $$(dirname $(location {out})) && cp $(rootpath {out}) $(location {out})'.format(out = out) -+ for out in outputs -+ ]), -+ tools = ["configure"], -+ toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"], -+ srcs = native.glob(["**"], exclude=outputs), -+ outs = outputs, -+ ) -+ - def _paths_module(desc): - return "Paths_" + desc.package.pkgName.replace("-", "_") - -@@ -389,23 +427,17 @@ def _get_build_attrs( - ) - globbed_headers = native.glob([ - paths.normalize(f) -- for f in desc.extraSrcFiles + desc.extraTmpFiles -- ]) -- -- # Some packages, such as network, include the config.log and config.status -- # files, generated by the ./configure script, in their extraTmpFiles. These -- # files contain information specific to the build host, which defeates -- # distributed caching. Here we black-list any such files and exclude them -- # from the headers attribute to cc_library. -- header_blacklist = [ -- "config.log", -- "config.status", -+ for f in desc.extraSrcFiles -+ ]) + [ -+ paths.normalize(f) -+ for f in desc.extraTmpFiles - ] -+ - headers = depset( - [ - hdr - for hdr in globbed_headers -- if hdr.split("/")[-1] not in header_blacklist -+ if hdr.split("/")[-1] not in _header_blacklist - ] + - install_includes, - ) -@@ -483,6 +515,9 @@ def cabal_haskell_package( - """ - name = description.package.pkgName - -+ if description.buildTypeRaw == "Configure": -+ _configure(description) -+ - cabal_paths( - name = _paths_module(description), - package = name.replace("-", "_"), -diff --git a/hazel/third_party/haskell/network.patch b/hazel/third_party/haskell/network.patch -new file mode 100644 -index 0000000..fe9551d ---- /dev/null -+++ b/hazel/third_party/haskell/network.patch -@@ -0,0 +1,22 @@ -+--- network.cabal.orig 2019-04-30 16:22:51.017832083 +0200 -++++ network.cabal 2019-04-30 16:33:48.037415801 +0200 -+@@ -71,8 +71,19 @@ -+ includes: HsNet.h HsNetDef.h -+ install-includes: HsNet.h HsNetDef.h -+ c-sources: cbits/HsNet.c -++ -++ if os(windows) -++ c-sources: cbits/initWinSock.c cbits/winSockErr.c cbits/asyncAccept.c -++ else -++ c-sources: cbits/ancilData.c -++ -+ ghc-options: -Wall -fwarn-tabs -+ -++ if !os(windows) -++ ghc-options: -D_GNU_SOURCE -++ ghc-prof-options: -D_GNU_SOURCE -++ cc-options: -D_GNU_SOURCE -++ -+ test-suite spec -+ hs-source-dirs: tests -+ main-is: Spec.hs -diff --git a/hazel/workspace.bzl b/hazel/workspace.bzl -index 936b352..707fb37 100644 ---- a/hazel/workspace.bzl -+++ b/hazel/workspace.bzl -@@ -101,6 +101,7 @@ cc_library( - pkgs = packages, - extra_pkgs = { - "unix-time": {"version": "0.4.5", "sha256": "fe7805c62ad682589567afeee265e6e230170c3941cdce479a2318d1c5088faf"}, -+ "network": {"version": "2.8.0.0", "sha256": "c8905268b7e3b4cf624a40245bf11b35274a6dd836a5d4d531b5760075645303", "patches": ["@ai_formation_hazel//third_party/haskell:network.patch"]}, - }, - ), - core_packages = core_packages, diff --git a/bazel_tools/hazel-short-names.patch b/bazel_tools/hazel-short-names.patch deleted file mode 100644 index e9ff08d2fef..00000000000 --- a/bazel_tools/hazel-short-names.patch +++ /dev/null @@ -1,395 +0,0 @@ -diff --git a/hazel/hazel.bzl b/hazel/hazel.bzl -index 964a304..e7e5f73 100644 ---- a/hazel/hazel.bzl -+++ b/hazel/hazel.bzl -@@ -56,7 +56,7 @@ def _core_library_repository_impl(ctx): - content = """ - load("@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_toolchain_library") - haskell_toolchain_library( -- name = "{pkg}", -+ name = "lib", - package = "{pkg}", - visibility = ["//visibility:public"], - ) -@@ -136,7 +136,7 @@ def hazel_repositories( - external dependencies corresponding to the given packages: - - @hazel_base_repository: The compiled "hazel" Haskell binary, along with - support files. -- - @haskell_{package}_{hash}: A build of the given Cabal package, one per entry -+ - @haskell_{package}: A build of the given Cabal package, one per entry - of the "packages" argument. (Note that Bazel only builds these - on-demand when needed by other rules.) This repository automatically - downloads the package's Cabal distribution from Hackage and parses the -diff --git a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -index 16d5c3b..348302e 100644 ---- a/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -+++ b/hazel/third_party/cabal2bazel/bzl/cabal_package.bzl -@@ -71,6 +71,8 @@ def _get_core_dependency_includes(ghc_workspace): - "unix": "{}//:unix-includes".format(ghc_workspace), - } - -+_lib_name = "lib" -+ - def _paths_module(desc): - return "Paths_" + desc.package.pkgName.replace("-", "_") - -@@ -238,12 +240,25 @@ def _get_build_attrs( - # build_files will contain a list of all files in the build directory. - build_files = [] - -- clib_name = name + "-cbits" - generated_modules = [_paths_module(desc)] - - # Keep track of chs modules, as later chs modules may depend on earlier ones. - chs_targets = [] - -+ # XXX: We would like to also shorten the library components cbits' name to -+ # 'cbits'. However, on Windows, where we only create static libraries, no -+ # dynamic libraries, this causes name clashes. Bazel does not mangle static -+ # library names, only dynamic library names. If a dynamic library is -+ # present, then rules_haskell will mangle the static library the same, so -+ # that one entry in the package configuration file's extra-libraries -+ # section covers both static and dynamic libraries. However, if no dynamic -+ # library is present, then no such mangling is performed. The -+ # extra-libraries field will then hold only one 'cbits' entry which can be -+ # ambiguous if the target depends on multuple cbits. -+ cbits_name = name + "-cbits" -+ if name == _lib_name: -+ cbits_name = desc.package.pkgName + "-cbits" -+ - for module in build_info.otherModules + extra_modules: - if module in generated_modules: - continue -@@ -266,7 +281,7 @@ def _get_build_attrs( - boot_module_map[module] = boot_out - build_files.append(boot_out) - elif info.type in ["chs"]: -- chs_name = name + "-" + module + "-chs" -+ chs_name = module + "-chs" - module_map[module] = chs_name - build_files.append(info.src) - c2hs_library( -@@ -274,7 +289,7 @@ def _get_build_attrs( - srcs = [info.src], - deps = ( - _get_extra_libs(build_info.extraLibs, extra_libs) + -- [clib_name] + -+ [cbits_name] + - chs_targets - ), - ) -@@ -326,7 +341,7 @@ def _get_build_attrs( - for m in (extra_modules_dict.get(condition, []) + - other_modules_dict.get(condition, [])): - if m == paths_module: -- deps[condition] += [":" + paths_module] -+ deps[condition] += [":paths"] - elif m in module_map: - srcs[condition] += [module_map[m]] - -@@ -411,7 +426,7 @@ def _get_build_attrs( - ) - ghcopts += ["-I" + native.package_name() + "/" + d for d in build_info.includeDirs] - for xs in deps.values(): -- xs.append(":" + clib_name) -+ xs.append(cbits_name) - - ghc_version_components = ghc_version.split(".") - if len(ghc_version_components) != 3: -@@ -426,7 +441,7 @@ def _get_build_attrs( - elibs_targets = _get_extra_libs(build_info.extraLibs, extra_libs) - - native.cc_library( -- name = clib_name, -+ name = cbits_name, - srcs = build_info.cSources, - includes = build_info.includeDirs, - copts = ([o for o in build_info.ccOptions if not o.startswith("-D")] + -@@ -484,7 +499,7 @@ def cabal_haskell_package( - name = description.package.pkgName - - cabal_paths( -- name = _paths_module(description), -+ name = "paths", - package = name.replace("-", "_"), - version = [int(v) for v in description.package.pkgVersion.split(".")], - data_dir = description.dataDir, -@@ -492,51 +507,54 @@ def cabal_haskell_package( - ) - - lib = description.library -- if lib and lib.libBuildInfo.buildable: -- if not lib.exposedModules: -- native.cc_library( -- name = name, -- visibility = ["//visibility:public"], -- linkstatic = select({ -- "@bazel_tools//src/conditions:windows": True, -- "//conditions:default": False, -- }), -- ) -- native.cc_library( -- name = name + "-cbits", -- visibility = ["//visibility:public"], -- linkstatic = select({ -- "@bazel_tools//src/conditions:windows": True, -- "//conditions:default": False, -- }), -- ) -- else: -- lib_attrs = _get_build_attrs( -- name, -- lib.libBuildInfo, -- description, -- "dist/build", -- lib.exposedModules, -- ghc_version, -- ghc_workspace, -- extra_libs, -- ) -- srcs = lib_attrs.pop("srcs") -- deps = lib_attrs.pop("deps") -+ if lib and lib.libBuildInfo.buildable and lib.exposedModules: -+ lib_attrs = _get_build_attrs( -+ _lib_name, -+ lib.libBuildInfo, -+ description, -+ "dist/build", -+ lib.exposedModules, -+ ghc_version, -+ ghc_workspace, -+ extra_libs, -+ ) -+ srcs = lib_attrs.pop("srcs") -+ deps = lib_attrs.pop("deps") - -- elibs_targets = _get_extra_libs(lib.libBuildInfo.extraLibs, extra_libs) -+ elibs_targets = _get_extra_libs(lib.libBuildInfo.extraLibs, extra_libs) - -- hidden_modules = [m for m in lib.libBuildInfo.otherModules if not m.startswith("Paths_")] -+ hidden_modules = [m for m in lib.libBuildInfo.otherModules if not m.startswith("Paths_")] - -- haskell_library( -- name = name, -- srcs = select(srcs), -- hidden_modules = hidden_modules, -- version = description.package.pkgVersion, -- deps = select(deps) + elibs_targets, -- visibility = ["//visibility:public"], -- **lib_attrs -- ) -+ haskell_library( -+ name = _lib_name, -+ srcs = select(srcs), -+ hidden_modules = hidden_modules, -+ package_name = description.package.pkgName, -+ version = description.package.pkgVersion, -+ deps = select(deps) + elibs_targets, -+ visibility = ["//visibility:public"], -+ **lib_attrs -+ ) -+ else: -+ # No exposed library modules. Generate an empty dummy library target. -+ native.cc_library( -+ name = _lib_name, -+ visibility = ["//visibility:public"], -+ linkstatic = select({ -+ "@bazel_tools//src/conditions:windows": True, -+ "//conditions:default": False, -+ }), -+ ) -+ -+ # No exposed library modules. Generate an empty dummy cbits target. -+ native.cc_library( -+ name = name + "-cbits", -+ visibility = ["//visibility:public"], -+ linkstatic = select({ -+ "@bazel_tools//src/conditions:windows": True, -+ "//conditions:default": False, -+ }), -+ ) - - for exe in description.executables: - if not exe.buildInfo.buildable: -@@ -546,7 +564,7 @@ def cabal_haskell_package( - # Avoid a name clash with the library. For stability, make this logic - # independent of whether the package actually contains a library. - if exe_name == name: -- exe_name = name + "_bin" -+ exe_name = "bin" - paths_mod = _paths_module(description) - attrs = _get_build_attrs( - exe_name, -diff --git a/hazel/third_party/haskell/BUILD.conduit b/hazel/third_party/haskell/BUILD.conduit -index a1213b6..a116b54 100644 ---- a/hazel/third_party/haskell/BUILD.conduit -+++ b/hazel/third_party/haskell/BUILD.conduit -@@ -7,7 +7,7 @@ load("@ai_formation_hazel//tools:mangling.bzl", "hazel_library") - load("@ai_formation_hazel//:tools/mangling.bzl", "hazel_workspace") - - haskell_library( -- name = "conduit", -+ name = "lib", - srcs = glob([ - "Data/*.hs", - "Data/**/*.hs", -@@ -31,6 +31,7 @@ haskell_library( - hazel_library("transformers-compat"), - hazel_library("vector"), - ], -+ package_name = "conduit", - version = "1.2.13.1", - ) - -diff --git a/hazel/third_party/haskell/BUILD.ghc-paths b/hazel/third_party/haskell/BUILD.ghc-paths -index 49aab10..cf5e39f 100644 ---- a/hazel/third_party/haskell/BUILD.ghc-paths -+++ b/hazel/third_party/haskell/BUILD.ghc-paths -@@ -11,11 +11,13 @@ ghc_paths_module( - name = "paths_module") - - haskell_library( -- name = "ghc-paths", -+ name = "lib", - srcs = [":paths_module"], - deps = [ - hazel_library("base"), - ], -+ package_name = "ghc-paths", -+ version = "0.1.0.9", - ) - - cc_import( -diff --git a/hazel/third_party/haskell/BUILD.text-metrics b/hazel/third_party/haskell/BUILD.text-metrics -index a86eef1..a20d513 100644 ---- a/hazel/third_party/haskell/BUILD.text-metrics -+++ b/hazel/third_party/haskell/BUILD.text-metrics -@@ -6,7 +6,7 @@ load("@io_tweag_rules_haskell//haskell:haskell.bzl", - load("@ai_formation_hazel//:hazel.bzl", "hazel_library") - - haskell_library( -- name = "text-metrics", -+ name = "lib", - srcs = ["Data/Text/Metrics.hs"], - deps = [ - hazel_library("base"), -@@ -14,6 +14,7 @@ haskell_library( - hazel_library("text"), - hazel_library("vector"), - ], -+ package_name = "text-metrics", - version = "0.3.0", - ) - -diff --git a/hazel/third_party/haskell/BUILD.vault b/hazel/third_party/haskell/BUILD.vault -index 8967875..a4eb484 100644 ---- a/hazel/third_party/haskell/BUILD.vault -+++ b/hazel/third_party/haskell/BUILD.vault -@@ -4,7 +4,7 @@ load("@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_library") - load("@ai_formation_hazel//:hazel.bzl", "hazel_library") - - haskell_library( -- name = "vault", -+ name = "lib", - srcs = [ - "src/Data/Unique/Really.hs", - "src/Data/Vault/IO.h", -@@ -29,6 +29,8 @@ haskell_library( - hazel_library("semigroups"), - hazel_library("unordered-containers"), - ], -+ package_name = "vault", -+ version = "0.3.1.1", - ) - - cc_import( -diff --git a/hazel/third_party/haskell/BUILD.wai-app-static b/hazel/third_party/haskell/BUILD.wai-app-static -index 65edca1..4b90ae7 100644 ---- a/hazel/third_party/haskell/BUILD.wai-app-static -+++ b/hazel/third_party/haskell/BUILD.wai-app-static -@@ -4,7 +4,7 @@ load("@io_tweag_rules_haskell//haskell:haskell.bzl", "haskell_library") - load("@ai_formation_hazel//:hazel.bzl", "hazel_library") - - haskell_library( -- name = "wai-app-static", -+ name = "lib", - srcs = glob([ - "Network/Wai/Application/Static.hs", - "Util.hs", -@@ -40,6 +40,7 @@ haskell_library( - hazel_library("warp"), - hazel_library("zlib"), - ], -+ package_name = "wai-app-static", - version = "3.1.6.2", - ) - -diff --git a/hazel/third_party/haskell/BUILD.zlib b/hazel/third_party/haskell/BUILD.zlib -index 623ecd5..9bc2eb0 100644 ---- a/hazel/third_party/haskell/BUILD.zlib -+++ b/hazel/third_party/haskell/BUILD.zlib -@@ -14,7 +14,7 @@ cc_library( - ) - - haskell_library( -- name = "zlib", -+ name = "lib", - srcs = glob([ - "Codec/Compression/*.hs", - "Codec/Compression/Zlib/*.hs", -@@ -26,4 +26,6 @@ haskell_library( - hazel_library("bytestring"), - hazel_library("ghc-prim"), - ], -+ package_name = "zlib", -+ version = "0.6.2", - ) -diff --git a/hazel/third_party/haskell/BUILD.zlib-bindings b/hazel/third_party/haskell/BUILD.zlib-bindings -index 5872eae..d70e991 100644 ---- a/hazel/third_party/haskell/BUILD.zlib-bindings -+++ b/hazel/third_party/haskell/BUILD.zlib-bindings -@@ -7,22 +7,24 @@ load("@io_tweag_rules_haskell//haskell:haskell.bzl", - load("@ai_formation_hazel//:hazel.bzl", "hazel_library") - - cc_library( -- name = "cbits", -+ name = "zlib-bindings-cbits", - hdrs = glob(["cbits/*.h"]), - srcs = glob(["cbits/*.c"]), - strip_include_prefix = "cbits", - ) - - haskell_library( -- name = "zlib-bindings", -+ name = "lib", - srcs = glob([ - "Codec/Zlib.hs", - "Codec/Zlib/Lowlevel.hs", - ]), - deps = [ -- ":cbits", -+ ":zlib-bindings-cbits", - hazel_library("base"), - hazel_library("bytestring"), - hazel_library("zlib"), - ], -+ package_name "zlib-bindings", -+ version = "0.1.1.5", - ) -diff --git a/hazel/tools/mangling.bzl b/hazel/tools/mangling.bzl -index 26e2506..8b1817f 100644 ---- a/hazel/tools/mangling.bzl -+++ b/hazel/tools/mangling.bzl -@@ -1,10 +1,10 @@ - def hazel_library(package_name): - """Returns the label of the haskell_library rule for the given package.""" -- return "@{}//:{}".format(hazel_workspace(package_name), package_name) -+ return "@{}//:lib".format(hazel_workspace(package_name)) - - def hazel_binary(package_name): - """Returns the label of the haskell_binary rule for the given package.""" -- return "@{}//:{}_bin".format(hazel_workspace(package_name), package_name) -+ return "@{}//:bin".format(hazel_workspace(package_name)) - - def hazel_cbits(package_name): - """Returns the label of the cc_library rule for the given package.""" diff --git a/deps.bzl b/deps.bzl index dce5530427e..73b43fc46d8 100644 --- a/deps.bzl +++ b/deps.bzl @@ -27,8 +27,8 @@ # be resolvable from external workspaces otherwise. rules_scala_version = "78104d8014d4e4fc8f905cd34b91dfabd9a268c8" -rules_haskell_version = "6c550c8eb7ce7950e702420be39d932b8b31ef22" -rules_haskell_sha256 = "aef68cf5d732b2fa9ae0efea344cb83cb0c16f0f08a8d6901776a0085fbe7a8b" +rules_haskell_version = "1d85570f2383e376e4b9406a0aa33961a2c0aece" +rules_haskell_sha256 = "32accba7d598453c1f3be8af2c7532d325323ad20bda54166b0e8a69c51b92e8" rules_nixpkgs_version = "5ffb8a4ee9a52bc6bc12f95cd64ecbd82a79bc82" load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") @@ -44,8 +44,6 @@ def daml_deps(): "@com_github_digital_asset_daml//bazel_tools:haskell-static-linking.patch", "@com_github_digital_asset_daml//bazel_tools:haskell-package-env.patch", "@com_github_digital_asset_daml//bazel_tools:haskell-drop-fake-static.patch", - "@com_github_digital_asset_daml//bazel_tools:haskell-short-names.patch", - "@com_github_digital_asset_daml//bazel_tools:haskell-cc-toolchain.patch", ], patch_args = ["-p1"], sha256 = rules_haskell_sha256, @@ -64,12 +62,6 @@ def daml_deps(): name = "ai_formation_hazel", strip_prefix = "rules_haskell-{}/hazel".format(rules_haskell_version), urls = ["https://github.com/tweag/rules_haskell/archive/%s.tar.gz" % rules_haskell_version], - patches = [ - "@com_github_digital_asset_daml//bazel_tools:hazel-configure.patch", - "@com_github_digital_asset_daml//bazel_tools:hazel-short-names.patch", - "@com_github_digital_asset_daml//bazel_tools:hazel-cc-toolchain.patch", - ], - patch_args = ["-p2"], sha256 = rules_haskell_sha256, )