From 5096ca2a4429f16faa9457289e579bf37f969aed Mon Sep 17 00:00:00 2001 From: Andreas Herrmann Date: Mon, 7 Oct 2019 18:27:00 +0200 Subject: [PATCH] Use cc_wrapper in Cabal rules --- haskell/cabal.bzl | 1 + haskell/private/cabal_wrapper.sh.tpl | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/haskell/cabal.bzl b/haskell/cabal.bzl index c1e25139bb..63feebfab2 100644 --- a/haskell/cabal.bzl +++ b/haskell/cabal.bzl @@ -109,6 +109,7 @@ def _prepare_cabal_inputs(hs, cc, unix, dep_info, cc_info, component, package_id "%{ghc_pkg}": hs.tools.ghc_pkg.path, "%{runghc}": hs.tools.runghc.path, "%{ar}": cc.tools.ar, + "%{cc}": cc.tools.cc, "%{strip}": cc.tools.strip, # XXX Workaround # https://github.com/bazelbuild/bazel/issues/5980. diff --git a/haskell/private/cabal_wrapper.sh.tpl b/haskell/private/cabal_wrapper.sh.tpl index 4be5ce9626..d9add4ed5a 100644 --- a/haskell/private/cabal_wrapper.sh.tpl +++ b/haskell/private/cabal_wrapper.sh.tpl @@ -84,6 +84,7 @@ done shift 1 ar=$(realpath %{ar}) +cc=$(realpath %{cc}) strip=$(realpath %{strip}) distdir=$(mktemp -d) libdir="$pkgroot/${name}_iface" @@ -99,6 +100,15 @@ trap cleanup EXIT %{ghc_pkg} recache --package-db=$package_database +WITH_GCC= +if [[ %{is_windows} != True ]]; then + # Use the cc-wrapper for Cabal builds. + # Note, we cannot currently use it on Windows because the solution to the + # following issue is not released, yet. + # https://github.com/bazelbuild/bazel/issues/9390 + WITH_GCC="--with-gcc=$cc" +fi + ENABLE_RELOCATABLE= if [[ %{is_windows} != True ]]; then ENABLE_RELOCATABLE=--enable-relocatable @@ -119,6 +129,7 @@ $execroot/%{runghc} $setup configure \ --with-compiler=$execroot/%{ghc} \ --with-hc-pkg=$execroot/%{ghc_pkg} \ --with-ar=$ar \ + $WITH_GCC \ --with-strip=$strip \ --enable-deterministic \ $ENABLE_RELOCATABLE \