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
......
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