summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2021-04-27 10:57:05 +0800
committerBen Gamari <ben@smart-cactus.org>2021-05-31 11:59:28 -0400
commitd13aabe846ef8a0d056e7978669cc7c589f00346 (patch)
treee262d58c60ce7691fe325aa274ad27ecd9810312
parentec451cac39de919621c783fec809c26fb9f0d1c8 (diff)
downloadhaskell-d13aabe846ef8a0d056e7978669cc7c589f00346.tar.gz
[ci/darwin] use system provided iconv and curses
Also make sure to be able to build with non-apple-clang, while using apple's SDK on macOS (cherry picked from commit 839ee0c6127e04610af85143271cdafc94d9b2ae)
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--.gitlab/shell.nix34
-rw-r--r--libraries/base/configure.ac2
-rw-r--r--libraries/integer-gmp/gmp/ghc.mk5
4 files changed, 35 insertions, 10 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d5c9e2f07b..37fbecc903 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -503,7 +503,7 @@ validate-x86_64-darwin:
CPUS: 8
LANG: "en_US.UTF-8"
# WARNING: this is overridden in the shell.nix, see shell.nix!
- CONFIGURE_ARGS: "--with-intree-gmp"
+ CONFIGURE_ARGS: "--with-intree-gmp --with-curses-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib --with-iconv-includes=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include --with-iconv-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
# I wish we could just use the nix #! logic, but we can't --run and -i bash
# behave very differently. -i bash does not pass any nix related env vars
@@ -590,7 +590,7 @@ validate-aarch64-darwin:
CPUS: 8
LANG: "en_US.UTF-8"
# WARNING: this is overridden in the shell.nix, see shell.nix!
- CONFIGURE_ARGS: "--with-intree-gmp"
+ CONFIGURE_ARGS: "--with-intree-gmp --with-curses-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib --with-iconv-includes=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include --with-iconv-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
# I wish we could just use the nix #! logic, but we can't --run and -i bash
# behave very differently. -i bash does not pass any nix related env vars
diff --git a/.gitlab/shell.nix b/.gitlab/shell.nix
index 3fcc2f928b..9b675e053f 100644
--- a/.gitlab/shell.nix
+++ b/.gitlab/shell.nix
@@ -12,7 +12,8 @@
# we need to inject ncurses into --with-curses-libraries.
# the real fix is to teach terminfo to use libcurses on macOS.
- CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=${pkgs.ncurses.out}/lib";
+ # CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=${pkgs.ncurses.out}/lib";
+ CONFIGURE_ARGS = "--with-intree-gmp --with-curses-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib --with-iconv-includes=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include --with-iconv-libraries=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib";
# magic speedup pony :facepalm:
#
@@ -22,24 +23,45 @@
export NIX_LDFLAGS=$(for a in $NIX_LDFLAGS; do echo $a; done |sort|uniq|xargs)
export NIX_LDFLAGS_FOR_TARGET=$(for a in $NIX_LDFLAGS_FOR_TARGET; do echo $a; done |sort|uniq|xargs)
export NIX_LDFLAGS_FOR_TARGET=$(comm -3 <(for l in $NIX_LDFLAGS_FOR_TARGET; do echo $l; done) <(for l in $NIX_LDFLAGS; do echo $l; done))
+
+
+ # Impurity hack for GHC releases.
+ #################################
+ # We don't want binary releases to depend on nix, thus we'll need to make sure we don't leak in references.
+ # GHC externally depends only on iconv and curses. However we can't force a specific curses library for
+ # the terminfo package, as such we'll need to make sure we only look in the system path for the curses library
+ # and not pick up the tinfo from the nix provided ncurses package.
+ #
+ # We also need to force us to use the systems COREFOUNDATION, not the one that nix builds. Again this is impure,
+ # but it will allow us to have proper binary distributions.
+ #
+ # do not use nixpkgs provided core foundation
+ export NIX_COREFOUNDATION_RPATH=/System/Library/Frameworks
+ # drop curses from the LDFLAGS, we really want the system ones, not the nix ones.
+ export NIX_LDFLAGS=$(for lib in $NIX_LDFLAGS; do case "$lib" in *curses*);; *) echo -n "$lib ";; esac; done;)
+ export NIX_CFLAGS_COMPILE+=" -Wno-nullability-completeness -Wno-availability -Wno-expansion-to-defined -Wno-builtin-requires-header -Wno-unused-command-line-argument"
+
+ # unconditionally add the MacOSX.sdk and TargetConditional.h
+ export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
'';
nativeBuildInputs = (with pkgs; [
+ # This needs to come *before* ghc,
+ # otherwise we migth end up with the clang from
+ # the bootstrap GHC in PATH with higher priority.
+ clang_11
+ llvm_11
+
haskell.compiler.${compiler}
haskell.packages.${compiler}.cabal-install
haskell.packages.${compiler}.alex
haskell.packages.${compiler}.happy_1_19_12
- clang_11
- llvm_11
-
automake
autoconf
m4
gmp
- ncurses
- libiconv
zlib.out
zlib.dev
glibcLocales
diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac
index eae152e682..716e46cc05 100644
--- a/libraries/base/configure.ac
+++ b/libraries/base/configure.ac
@@ -99,7 +99,7 @@ dnl--------------------------------------------------------------------
AC_ARG_WITH([iconv-includes],
[AS_HELP_STRING([--with-iconv-includes],
[directory containing iconv.h])],
- [ICONV_INCLUDE_DIRS=$withval; CPPFLAGS="-I$withval $CPPFLAGS"],
+ [ICONV_INCLUDE_DIRS=$withval],
[ICONV_INCLUDE_DIRS=])
AC_ARG_WITH([iconv-libraries],
diff --git a/libraries/integer-gmp/gmp/ghc.mk b/libraries/integer-gmp/gmp/ghc.mk
index e4cea275eb..440114a135 100644
--- a/libraries/integer-gmp/gmp/ghc.mk
+++ b/libraries/integer-gmp/gmp/ghc.mk
@@ -129,9 +129,12 @@ libraries/integer-gmp/gmp/libgmp.a libraries/integer-gmp/gmp/gmp.h:
# Note: We must pass `TARGETPLATFORM` to the `--host` argument of GMP's
# `./configure`, not `HOSTPLATFORM`: the 'host' on which GMP will
# run is the 'target' platform of the compiler we're building.
+ # Note2: we pass --with-readline=no, to prevent getting an indirect
+ # dependency on ncurses through gmp. readline is only relevant
+ # for gmp test programs. (See gmp's configure)
cd libraries/integer-gmp/gmp/gmpbuild; \
CC=$(CCX) CXX=$(CCX) NM=$(NM) AR=$(AR_STAGE1) ./configure \
- --enable-shared=no --with-pic=yes \
+ --enable-shared=no --with-pic=yes --with-readline=no \
--host=$(TARGETPLATFORM) --build=$(BUILDPLATFORM)
$(MAKE) -C libraries/integer-gmp/gmp/gmpbuild MAKEFLAGS=
$(CP) libraries/integer-gmp/gmp/gmpbuild/gmp.h libraries/integer-gmp/gmp/