Skip to content

Commit

Permalink
Remove libffi hack from ghc-lib (digital-asset#2703)
Browse files Browse the repository at this point in the history
We currently use a custom cabal file for ghc-lib that has libffi in
the extra-libraries section so Hazel adds the headers. Forcing GHC to
use the bundled libffi should hopefully remove the need for this hack
which simplifies things.
  • Loading branch information
cocreature authored and mergify[bot] committed Aug 30, 2019
1 parent d5c6d93 commit 8f56205
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
4 changes: 2 additions & 2 deletions 3rdparty/haskell/BUILD.ghc-lib-parser
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ haskell_library(
hazel_library("process"),
hazel_library("hpc"),
"ghc-lib-parser-cbits"
] + ([hazel_library("Win32")] if is_windows else ["@libffi_nix//:ffi", hazel_library("unix")]),
] + ([hazel_library("Win32")] if is_windows else [hazel_library("unix")]),
compiler_flags = [
"-XHaskell2010",
"-XNoImplicitPrelude",
Expand All @@ -58,7 +58,7 @@ haskell_library(
cc_library(
name = "ghc-lib-parser-cbits",
visibility = ["//visibility:public"],
deps = ["@haskell_rts//:lib"] + ([hazel_library("Win32")] if is_windows else ["@libffi_nix//:ffi", hazel_cbits("unix"), hazel_library("unix")]) + [
deps = ["@haskell_rts//:lib"] + ([hazel_library("Win32")] if is_windows else [hazel_cbits("unix"), hazel_library("unix")]) + [
hazel_cbits("ghc-prim"),
hazel_cbits("base"),
hazel_cbits("containers"),
Expand Down
23 changes: 0 additions & 23 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ hazel_repositories(
hazel_default_extra_libs,
{
"z": "@com_github_madler_zlib//:z",
"ffi": "" if is_windows else "@libffi_nix//:ffi",
"bz2": "@bzip2//:bz2",
},
),
Expand Down Expand Up @@ -690,28 +689,6 @@ nixpkgs_package(
repositories = dev_env_nix_repos,
)

nixpkgs_package(
name = "libffi_nix",
attribute_path = "libffi.dev",
build_file_content = """
package(default_visibility = ["//visibility:public"])
filegroup(
name = "include",
srcs = glob(["include/**/*.h"]),
)
cc_library(
name = "ffi",
hdrs = [":include"],
strip_include_prefix = "include",
)
""",
nix_file = "//nix:bazel.nix",
nix_file_deps = common_nix_file_deps,
repositories = dev_env_nix_repos,
)

# A repository that generates the Go SDK imports, see
# ./bazel_tools/go_sdk/README.md
local_repository(
Expand Down
8 changes: 8 additions & 0 deletions bazel_tools/ghc-lib-no-ffi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--- a/ghc-lib.cabal 2019-08-30 09:14:05.199708631 +0200
+++ b/ghc-lib.cabal 2019-08-30 09:14:13.923814400 +0200
@@ -652,5 +652,3 @@
X86.Ppr
X86.RegInfo
X86.Regs
- extra-libraries:
- ffi
1 change: 1 addition & 0 deletions bazel_tools/ghci-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

ENV_FILE=$1
ARGS_FILE=$2
RULES_HASKELL_EXEC_ROOT=$(dirname $(readlink ${BUILD_WORKSPACE_DIRECTORY}/bazel-out))/
echo "{ENV}" > "$ENV_FILE"
echo "{ARGS}" > "$ARGS_FILE"
1 change: 0 additions & 1 deletion nix/bazel.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ let shared = rec {
imagemagick
jdk8
jq
libffi
nodejs
patchelf
postgresql
Expand Down
1 change: 1 addition & 0 deletions nix/ghc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ let
inherit (pkgs) buildLlvmPackages;
enableIntegerSimple = true;
enableRelocatedStaticLibs = true;
libffi = null;
};

packages = pkgs.callPackage "${toString pkgs.path}/pkgs/development/haskell-modules" {
Expand Down
2 changes: 2 additions & 0 deletions util.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def hazel_ghclibs(version, shaParser, shaLibrary):
"url": "https://digitalassetsdk.bintray.com/ghc-lib/ghc-lib-" + version + ".tar.gz",
"stripPrefix": "ghc-lib-" + version,
"sha256": shaLibrary,
"patches": ["@com_github_digital_asset_daml//bazel_tools:ghc-lib-no-ffi.patch"],
"patch_args": ["-p1"],
},
),
]
Expand Down

0 comments on commit 8f56205

Please sign in to comment.