Commit 0701db12 authored by Edward Z. Yang's avatar Edward Z. Yang Committed by Ben Gamari

Updates to handle new Cabal

Specifically per-component macros and multiple libraries.

Contains Cabal submodule update.
Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: austin, bgamari

Reviewed By: austin, bgamari

Subscribers: hvr, thomie

Differential Revision: https://phabricator.haskell.org/D2059
parent b8b3e30a
......@@ -12,6 +12,7 @@
ghc_USES_CABAL = YES
ghc_PACKAGE = ghc-bin
ghc_EXECUTABLE = ghc
ghc_stage1_CONFIGURE_OPTS += --flags=stage1
ghc_stage2_CONFIGURE_OPTS += --flags=stage2
......
......@@ -12,6 +12,7 @@
iserv_USES_CABAL = YES
iserv_PACKAGE = iserv-bin
iserv_EXECUTABLE = iserv
ifeq "$(GhcDebugged)" "YES"
iserv_stage2_MORE_HC_OPTS += -debug
......
Subproject commit 9accafebff3743fc499fa6d565d55ba25326db28
Subproject commit 40d6f0afd5b86d698abb876d4f5ed0bb452b0c4b
......@@ -113,7 +113,7 @@ $1_$2_CONFIGURE_OPTS += $$(if $$(HAPPY),--with-happy="$$(HAPPY)")
ifneq "$$(BINDIST)" "YES"
ifneq "$$(NO_GENERATED_MAKEFILE_RULES)" "YES"
$1/$2/inplace-pkg-config : $1/$2/package-data.mk
$1/$2/build/autogen/cabal_macros.h : $1/$2/package-data.mk
$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h : $1/$2/package-data.mk
# This rule configures the package, generates the package-data.mk file
# for our build system, and registers the package for use in-place in
......
......@@ -35,7 +35,7 @@ $1_$2_DIST_GCC_CC_OPTS = \
$1_$2_DIST_CC_OPTS = \
$$(SRC_CC_OPTS) \
$$($1_CC_OPTS) \
-I$1/$2/build/autogen \
-I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
$$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
$$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
$$($1_$2_CC_OPTS) \
......@@ -75,8 +75,8 @@ $1_$2_ALL_HSC2HS_OPTS = \
--cflag=-D__GLASGOW_HASKELL__=$$(if $$(filter 0,$3),$$(GhcCanonVersion),$$(ProjectVersionInt)) \
$$($1_$2_HSC2HS_CC_OPTS) \
$$($1_$2_HSC2HS_LD_OPTS) \
--cflag=-I$1/$2/build/autogen \
$$(if $$($1_PACKAGE),--cflag=-include --cflag=$1/$2/build/autogen/cabal_macros.h) \
--cflag=-I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
$$(if $$($1_PACKAGE),--cflag=-include --cflag=$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h) \
$$($$(basename $$<)_HSC2HS_OPTS) \
$$(EXTRA_HSC2HS_OPTS)
......
......@@ -122,13 +122,16 @@ $1_$2_$3_MOST_HC_OPTS = \
$$(if $$($1_PACKAGE),$$($4_THIS_UNIT_ID) $$($1_$2_COMPONENT_ID))) \
$$(if $$($1_PACKAGE),-hide-all-packages) \
-i $$(if $$($1_$2_HS_SRC_DIRS),$$(foreach dir,$$($1_$2_HS_SRC_DIRS),-i$1/$$(dir)),-i$1) \
-i$1/$2/build -i$1/$2/build/autogen \
-I$1/$2/build -I$1/$2/build/autogen \
-i$1/$2/build \
-I$1/$2/build \
-i$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
-I$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen \
$$(foreach dir,$$(filter-out /%,$$($1_$2_INCLUDE_DIRS)),-I$1/$$(dir)) \
$$(foreach dir,$$(filter /%,$$($1_$2_INCLUDE_DIRS)),-I$$(dir)) \
$$(foreach inc,$$($1_$2_INCLUDE),-\#include "$$(inc)") \
$$(foreach opt,$$($1_$2_CPP_OPTS),-optP$$(opt)) \
$$(if $$($1_PACKAGE),-optP-include -optP$1/$2/build/autogen/cabal_macros.h) \
$$(if $$($1_PACKAGE),-optP-include \
-optP$1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/cabal_macros.h) \
$$($1_$2_$4_DEP_OPTS) \
$$($1_$2_HC_OPTS) \
$$(CONF_HC_OPTS_STAGE$4) \
......@@ -140,6 +143,14 @@ $1_$2_$3_MOST_HC_OPTS = \
$$(SRC_HC_WARNING_OPTS_STAGE$4) \
$$(EXTRA_HC_OPTS)
# What is going on with $1_EXECUTABLE? Recent version of Cabal
# place the cabal_macros.h for executables in build/exename/autogen
# rather than the traditional build/autogen. This is Right(TM)
# thing to do, but we have to accommodate it. Usually, it suffices
# to look in the PROGNAME, but for ghc the PROGNAME is ghc-stage1
# while Cabal puts it in 'ghc', so we $1_EXECUTABLE is for that
# case.
$1_$2_$3_MOST_DIR_HC_OPTS = \
$$($1_$2_$3_MOST_HC_OPTS) \
-odir $1/$2/build -hidir $1/$2/build -stubdir $1/$2/build
......
......@@ -28,7 +28,7 @@ endif
$1_$2_HS_SRCS := $$(foreach file,$$($1_$2_SLASH_MODS),\
$$(firstword \
$$(wildcard \
$$(foreach dir,$$($1_$2_HS_SRC_DIRS) $2/build/autogen,\
$$(foreach dir,$$($1_$2_HS_SRC_DIRS) $2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen,\
$1/$$(dir)/$$(file).hs $1/$$(dir)/$$(file).lhs)) \
$1/$2/build/$$(file).hs))
......
......@@ -117,10 +117,10 @@ $1/$2/build/%.$$($3_hcsuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_
$1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP)
$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@)))
$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP)
$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP)
$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
$1/$2/build/%.$$($3_osuf) : $1/$2/build/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP)
$1/$2/build/%.$$($3_osuf) : $1/$2/build/$$(or $$($1_EXECUTABLE),$$($1_$2_PROGNAME),.)/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$$$($1_$2_HC_DEP)
$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@)))
endif
......
......@@ -150,14 +150,16 @@ doCopy directory distDir
noGhcPrimHook f pd lbi us flags
= let pd'
| packageName pd == PackageName "ghc-prim" =
case library pd of
Just lib ->
case libraries pd of
[lib] ->
let ghcPrim = fromJust (simpleParse "GHC.Prim")
ems = filter (ghcPrim /=) (exposedModules lib)
lib' = lib { exposedModules = ems }
in pd { library = Just lib' }
Nothing ->
in pd { libraries = [lib'] }
[] ->
error "Expected a library, but none found"
_ ->
error "Expected a single library, but multiple found"
| otherwise = pd
in f pd' lbi us flags
modHook relocatableBuild f pd lbi us flags
......@@ -227,8 +229,8 @@ doRegister directory distDir ghc ghcpkg topdir
progs' <- configurePrograms [ghcProgram', ghcPkgProgram'] progs
instInfos <- dump (hcPkgInfo progs') verbosity GlobalPackageDB
let installedPkgs' = PackageIndex.fromList instInfos
let updateComponentConfig (cn, clbi, deps)
= (cn, updateComponentLocalBuildInfo clbi, deps)
let updateComponentConfig (clbi, deps)
= (updateComponentLocalBuildInfo clbi, deps)
updateComponentLocalBuildInfo clbi = clbi -- TODO: remove
ccs' = map updateComponentConfig (componentsConfigs lbi)
lbi' = lbi {
......@@ -308,7 +310,8 @@ generate directory distdir dll0Modules config_args
let pd = updatePackageDescription hooked_bi pd0
-- generate Paths_<pkg>.hs and cabal-macros.h
writeAutogenFiles verbosity pd lbi
withAllComponentsInBuildOrder pd lbi $ \_ clbi ->
writeAutogenFiles verbosity pd lbi clbi
-- generate inplace-pkg-config
withLibLBI pd lbi $ \lib clbi ->
......@@ -328,7 +331,7 @@ generate directory distdir dll0Modules config_args
comp = compiler lbi
libBiModules lib = (libBuildInfo lib, libModules lib)
exeBiModules exe = (buildInfo exe, ModuleName.main : exeModules exe)
biModuless = (maybeToList $ fmap libBiModules $ library pd)
biModuless = (map libBiModules $ libraries pd)
++ (map exeBiModules $ executables pd)
buildableBiModuless = filter isBuildable biModuless
where isBuildable (bi', _) = buildable bi'
......
......@@ -447,8 +447,8 @@ runit verbosity cli nonopts = do
(Just (Substring pkgarg_str m)) Nothing
["dot"] -> do
showPackageDot verbosity cli
["find-module", moduleName] -> do
let match = maybe (==moduleName) id (substringCheck moduleName)
["find-module", mod_name] -> do
let match = maybe (==mod_name) id (substringCheck mod_name)
listPackages verbosity cli Nothing (Just match)
["latest", pkgid_str] -> do
pkgid <- readGlobPkgId pkgid_str
......
......@@ -21,7 +21,7 @@ import SrcLoc
import Distribution.Simple.GHC ( componentGhcOptions )
import Distribution.Simple.Configure ( getPersistBuildConfig )
import Distribution.Simple.Program.GHC ( renderGhcOptions )
import Distribution.PackageDescription ( library, libBuildInfo )
import Distribution.PackageDescription ( libBuildInfo )
import Distribution.Simple.LocalBuildInfo
import qualified Distribution.Verbosity as V
......@@ -179,13 +179,10 @@ flagsFromCabal :: FilePath -> IO [String]
flagsFromCabal distPref = do
lbi <- getPersistBuildConfig distPref
let pd = localPkgDescr lbi
findLibraryConfig [] = Nothing
findLibraryConfig ((CLibName, clbi, _) : _) = Just clbi
findLibraryConfig (_ : xs) = findLibraryConfig xs
mLibraryConfig = findLibraryConfig (componentsConfigs lbi)
case (library pd, mLibraryConfig) of
(Just lib, Just clbi) ->
let bi = libBuildInfo lib
case maybeGetDefaultLibraryLocalBuildInfo lbi of
Just clbi ->
let CLib lib = getComponent pd (componentLocalName clbi)
bi = libBuildInfo lib
odir = buildDir lbi
opts = componentGhcOptions V.normal lbi bi clbi odir
in return $ renderGhcOptions (compiler lbi) (hostPlatform lbi) opts
......
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