Commit efc95841 authored by Alec Theriault's avatar Alec Theriault Committed by Ben Gamari

Hadrian: support in-tree GMP

Summary:
This adds top-level configure flags '--with-intree-gmp' and
'--with-framework-preferred', both of which are especially relevant
on MacOS.

Besides gaining two new flags, Hadrian also had to be taught what to
do with the 'framework' in .cabal files.

Test Plan:
./boot && ./configure --with-intree-gmp && ./hadrian/build.sh
./boot && ./configure --with-gmp-framework-preferred && ./hadrian/build.sh # on macos

Reviewers: carter, snowleopard, alpmestan, hvr, goldfire, bgamari

Subscribers: rwbarton, erikd

GHC Trac Issues: #16001

Differential Revision: https://phabricator.haskell.org/D5417
parent daff24bc
......@@ -1780,8 +1780,22 @@ AC_DEFUN([FP_GMP],
[directory containing gmp library])],
[GMP_LIB_DIRS=$withval])
AC_ARG_ENABLE([intree-gmp],
[AC_HELP_STRING([--with-intree-gmp],
[force using the in-tree GMP])],
[GMP_FORCE_INTREE=YES],
[GMP_FORCE_INTREE=NO])
AC_ARG_ENABLE([gmp-framework-preferred],
[AC_HELP_STRING([--with-gmp-framework-preferred],
[on OSX, prefer the GMP framework to the gmp lib])],
[GMP_PREFER_FRAMEWORK=YES],
[GMP_PREFER_FRAMEWORK=NO])
AC_SUBST(GMP_INCLUDE_DIRS)
AC_SUBST(GMP_LIB_DIRS)
AC_SUBST(GMP_FORCE_INTREE)
AC_SUBST(GMP_PREFER_FRAMEWORK)
])# FP_GMP
# FP_CURSES
......
......@@ -118,8 +118,10 @@ curses-lib-dir = @CURSES_LIB_DIRS@
iconv-include-dir = @ICONV_INCLUDE_DIRS@
iconv-lib-dir = @ICONV_LIB_DIRS@
gmp-include-dir = @GMP_INCLUDE_DIRS@
gmp-lib-dir = @GMP_LIB_DIRS@
intree-gmp = @GMP_FORCE_INTREE@
gmp-framework-preferred = @GMP_PREFER_FRAMEWORK@
gmp-include-dir = @GMP_INCLUDE_DIRS@
gmp-lib-dir = @GMP_LIB_DIRS@
use-system-ffi = @UseSystemLibFFI@
ffi-include-dir = @FFIIncludeDir@
......
......@@ -280,7 +280,8 @@ resolveContextData context@Context {..} = do
, depIncludeDirs = forDeps Installed.includeDirs
, depCcOpts = forDeps Installed.ccOptions
, depLdOpts = forDeps Installed.ldOptions
, buildGhciLib = C.withGHCiLib lbi' }
, buildGhciLib = C.withGHCiLib lbi'
, frameworks = C.frameworks buildInfo }
-- | Look for a @.buildinfo@ in all of the specified directories, stopping on
-- the first one we find.
......
......@@ -64,6 +64,7 @@ data ContextData = ContextData
, depCcOpts :: [String]
, depLdOpts :: [String]
, buildGhciLib :: Bool
, frameworks :: [String]
} deriving (Eq, Generic, Show, Typeable)
instance Binary PackageData
......
......@@ -13,6 +13,8 @@ data Flag = ArSupportsAtFile
| CrossCompiling
| GccIsClang
| GhcUnregisterised
| GmpInTree
| GmpFrameworkPref
| LeadingUnderscore
| SolarisBrokenShld
| SplitObjectsBroken
......@@ -29,6 +31,8 @@ flag f = do
CrossCompiling -> "cross-compiling"
GccIsClang -> "gcc-is-clang"
GhcUnregisterised -> "ghc-unregisterised"
GmpInTree -> "intree-gmp"
GmpFrameworkPref -> "gmp-framework-preferred"
LeadingUnderscore -> "leading-underscore"
SolarisBrokenShld -> "solaris-broken-shld"
SplitObjectsBroken -> "split-objects-broken"
......
......@@ -45,6 +45,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
pkg <- getPackage
libs <- getContextData extraLibs
libDirs <- getContextData extraLibDirs
fmwks <- getContextData frameworks
dynamic <- requiresDynamic
darwin <- expr osxHost
......@@ -71,6 +72,7 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
, not (nonHsMainPackage pkg) ? arg "-rtsopts"
, pure [ "-l" ++ lib | lib <- libs ]
, pure [ "-L" ++ libDir | libDir <- libDirs ]
, darwin ? pure (concat [ ["-framework", fmwk] | fmwk <- fmwks ])
]
findHsDependencies :: Args
......
......@@ -136,14 +136,10 @@ packageArgs = do
[ builder Cc ? arg includeGmp
, builder (Cabal Setup) ? mconcat
[ -- TODO: This should respect some settings flag "InTreeGmp".
-- Depending on @IncludeDir@ and @LibDir@ is bound to fail, since
-- these are only set if the configure script was explicilty
-- called with GMP include and lib dirs. Their absense as such
-- does not imply @in-tree-gmp@.
-- (null gmpIncludeDir && null gmpLibDir) ?
-- arg "--configure-option=--with-intree-gmp"
arg ("--configure-option=CFLAGS=" ++ includeGmp)
[ flag GmpInTree ? arg "--configure-option=--with-intree-gmp"
, flag GmpFrameworkPref ?
arg "--configure-option=--with-gmp-framework-preferred"
, arg ("--configure-option=CFLAGS=" ++ includeGmp)
, arg ("--gcc-options=" ++ includeGmp) ] ]
---------------------------------- rts ---------------------------------
......
......@@ -10,6 +10,8 @@ ifeq "$(HaveFrameworkGMP)" ""
HaveFrameworkGMP = @HaveFrameworkGMP@
endif
GMP_FORCE_INTREE = @GMP_FORCE_INTREE@
GMP_PREFER_FRAMEWORK = @GMP_PREFER_FRAMEWORK@
GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
GMP_LIB_DIRS = @GMP_LIB_DIRS@
......@@ -27,13 +27,13 @@ AC_ARG_WITH([gmp-libraries],
[GMP_LIB_DIRS=$withval; LDFLAGS="-L$withval"],
[GMP_LIB_DIRS=])
AC_ARG_WITH([gmp-framework-preferred],
AC_ARG_ENABLE([gmp-framework-preferred],
[AC_HELP_STRING([--with-gmp-framework-preferred],
[on OSX, prefer the GMP framework to the gmp lib])],
[GMP_PREFER_FRAMEWORK=YES],
[GMP_PREFER_FRAMEWORK=NO])
AC_ARG_WITH([intree-gmp],
AC_ARG_ENABLE([intree-gmp],
[AC_HELP_STRING([--with-intree-gmp],
[force using the in-tree GMP])],
[GMP_FORCE_INTREE=YES],
......
......@@ -898,6 +898,8 @@ ICONV_LIB_DIRS = @ICONV_LIB_DIRS@
GMP_INCLUDE_DIRS = @GMP_INCLUDE_DIRS@
GMP_LIB_DIRS = @GMP_LIB_DIRS@
GMP_PREFER_FRAMEWORK = @GMP_PREFER_FRAMEWORK@
GMP_FORCE_INTREE = @GMP_FORCE_INTREE@
CURSES_LIB_DIRS = @CURSES_LIB_DIRS@
......
......@@ -90,6 +90,14 @@ ifneq "$$(GMP_LIB_DIRS)" ""
$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="$$(GMP_LIB_DIRS)"
endif
ifeq "$$(GMP_PREFER_FRAMEWORK)" "YES"
$1_$2_CONFIGURE_OPTS += --configure-option=--with-gmp-framework-preferred
endif
ifeq "$$(GMP_FORCE_INTREE)" "YES"
$1_$2_CONFIGURE_OPTS += --configure-option=--with-intree-gmp
endif
ifneq "$$(CURSES_LIB_DIRS)" ""
$1_$2_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="$$(CURSES_LIB_DIRS)"
endif
......
  • mentioned in merge request !138 (closed)

    Toggle commit list
  • I believe this broke the Windows build. I can't immediately see why. I think we will need to revert.

  • @bgamari Here's a potentially suspicious couple lines in the failing log:

    Configuring integer-gmp-1.0.2.0...
    configure: WARNING: unrecognized options: --with-compiler, --with-intree-gmp
    configure: loading site script /usr/local/etc/config.site
    checking build system type... x86_64-w64-mingw32
    checking host system type... x86_64-w64-mingw32
    checking target system type... x86_64-w64-mingw32
    checking for gcc... C:/GITLAB~1/builds/28891e3c/0/ghc/ghc/inplace/mingw/bin/gcc.exe
    checking whether the C compiler works... yes
    checking for C compiler default output file name... a.exe
    checking for suffix of executables... .exe
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C compiler... yes
    checking whether C:/GITLAB~1/builds/28891e3c/0/ghc/ghc/inplace/mingw/bin/gcc.exe accepts -g... yes
    checking for C:/GITLAB~1/builds/28891e3c/0/ghc/ghc/inplace/mingw/bin/gcc.exe option to accept ISO C89... none needed
    checking how to run the C preprocessor... C:/GITLAB~1/builds/28891e3c/0/ghc/ghc/inplace/mingw/bin/gcc.exe -E
    checking for grep that handles long lines and -e... /usr/bin/grep
    checking for egrep... /usr/bin/grep -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking minix/config.h usability... no
    checking minix/config.h presence... no
    checking for minix/config.h... no
    checking whether it is safe to define __EXTENSIONS__... yes
    checking for __gmpz_powm in -lgmp... yes
    checking for __gmpz_powm_sec in -lgmp... yes
    checking whether to use in-tree GMP... no
    checking gmp.h usability... yes
    checking gmp.h presence... yes
    checking for gmp.h... yes
    checking GMP version... 6.1.2
    configure: creating ./config.status
    config.status: creating integer-gmp.buildinfo
    config.status: creating config.mk
    config.status: creating include/HsIntegerGmp.h
    configure: WARNING: unrecognized options: --with-compiler, --with-intree-gmp
    "C:/GitLabRunner/builds/28891e3c/0/ghc/ghc/inplace/bin/ghc-pkg.exe" update -v0 --force  libraries/integer-gmp/dist-install/inplace-pkg-config

    Why is --with-intree-gmp unrecognized? I'll investigate.

  • Oh well I feel thoroughly foolish: AC_ARG_ENABLE([intree-gmp]...) means the option is called --enable-intree-gmp, not --with-intree-gmp. I'll prepare a patch.

  • mentioned in commit 85a1c25f

    Toggle commit list
  • @bgamari I think !222 (closed) might be the proper fix. We'll see if CI agrees.

  • mentioned in issue #16001 (closed)

    Toggle commit list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment