else
@echo 'cRelocatableBuild = False' >> $@
endif
- @echo 'cUseArchivesForGhci :: Bool' >> $@
-ifeq "$(UseArchivesForGhci)" "YES"
- @echo 'cUseArchivesForGhci = True' >> $@
-else
- @echo 'cUseArchivesForGhci = False' >> $@
-endif
@echo 'cLibFFI :: Bool' >> $@
ifeq "$(UseLibFFIForAdjustors)" "YES"
@echo 'cLibFFI = True' >> $@
endif
# If we're profiling GHC then we want lots of SCCs, so -auto-all
-# We also don't want to waste time building the non-profiling library,
-# either normally or for ghci. Unfortunately this means that we have to
-# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't
-# exist.
+# We also don't want to waste time building the non-profiling library.
+# Unfortunately this means that we have to tell ghc-pkg --force as it
+# gets upset when libHSghc-6.9.a doesn't exist.
ifeq "$(GhcProfiled)" "YES"
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
# We seem to still build the vanilla libraries even if we say
# their absence when we register the package. So for now, we just
# leave the vanilla libraries enabled.
# compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
-compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
endif
$(eval $(call build-package,compiler,stage2,1))
$(eval $(call build-package,compiler,stage3,2))
+# after build-package, because that adds --enable-library-for-ghci
+# to compiler_stage*_CONFIGURE_OPTS:
+# We don't build the GHCi library for the ghc package. We can load it
+# the .a file instead, and as object splitting isn't on for the ghc
+# package this isn't much slower.However, not building the package saves
+# a significant chunk of disk space.
+compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
+compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
+compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
+
# after build-package, because that sets compiler_stage1_HC_OPTS:
compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
locateOneObj :: [FilePath] -> String -> IO LibrarySpec
locateOneObj dirs lib
| not isDynamicGhcLib
- -- When the GHC package was not compiled as dynamic library
- -- (=DYNAMIC not set), we search for .o libraries.
- = do mb_libSpec <- if cUseArchivesForGhci
- then do mb_arch_path <- findFile mk_arch_path dirs
- case mb_arch_path of
- Just arch_path ->
- return (Just (Archive arch_path))
- Nothing ->
- return Nothing
- else do mb_obj_path <- findFile mk_obj_path dirs
- case mb_obj_path of
- Just obj_path ->
- return (Just (Object obj_path))
- Nothing ->
- return Nothing
- case mb_libSpec of
- Just ls -> return ls
- Nothing -> return (DLL lib)
-
+ -- When the GHC package was not compiled as dynamic library
+ -- (=DYNAMIC not set), we search for .o libraries or, if they
+ -- don't exist, .a libraries.
+ = findObject `orElse` findArchive `orElse` assumeDll
| otherwise
-- When the GHC package was compiled as dynamic library (=DYNAMIC set),
-- we search for .so libraries first.
- = do { mb_lib_path <- findFile mk_dyn_lib_path dirs
- ; case mb_lib_path of
- Just _ -> return (DLL dyn_lib_name)
- Nothing ->
- do { mb_obj_path <- findFile mk_obj_path dirs
- ; case mb_obj_path of
- Just obj_path -> return (Object obj_path)
- Nothing -> return (DLL lib) }} -- We assume
+ = findDll `orElse` findObject `orElse` findArchive `orElse` assumeDll
where
mk_obj_path dir = dir </> (lib <.> "o")
mk_arch_path dir = dir </> ("lib" ++ lib <.> "a")
dyn_lib_name = lib ++ "-ghc" ++ cProjectVersion
mk_dyn_lib_path dir = dir </> mkSOName dyn_lib_name
+ findObject = liftM (fmap Object) $ findFile mk_obj_path dirs
+ findArchive = liftM (fmap Archive) $ findFile mk_arch_path dirs
+ findDll = liftM (fmap DLL) $ findFile mk_dyn_lib_path dirs
+ assumeDll = return (DLL lib)
+ infixr `orElse`
+ f `orElse` g = do m <- f
+ case m of
+ Just x -> return x
+ Nothing -> g
-- ----------------------------------------------------------------------------
-- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
("Object splitting", String cSplitObjs),
("Have native code generator", String cGhcWithNativeCodeGen),
("Have llvm code generator", String cGhcWithLlvmCodeGen),
- ("Use archives for ghci", String (show cUseArchivesForGhci)),
("Support SMP", String cGhcWithSMP),
("Unregisterised", String cGhcUnregisterised),
("Tables next to code", String cGhcEnableTablesNextToCode),
UseLibFFIForAdjustors=YES
endif
-ifeq "$(findstring $(HostOS_CPP), darwin)" ""
-UseArchivesForGhci = NO
-else
-UseArchivesForGhci = YES
-endif
-
# On Windows we normally want to make a relocatable bindist, to we
# ignore flags like libdir
ifeq "$(Windows)" "YES"
return oc;
}
-#if defined(USE_ARCHIVES_FOR_GHCI)
HsInt
loadArchive( char *path )
{
/* We can't mmap from the archive directly, as object
files need to be 8-byte aligned but files in .ar
- archives are 2-byte aligned, and if we malloc the
- memory then we can be given memory above 2^32, so we
- mmap some anonymous memory and use that. We could
- do better here. */
+ archives are 2-byte aligned. When possible we use mmap
+ to get some anonymous memory, as on 64-bit platforms if
+ we use malloc then we can be given memory above 2^32.
+ In the mmap case we're probably wasting lots of space;
+ we could do better. */
+#ifdef USE_MMAP
image = mmapForLinker(imageSize, MAP_ANONYMOUS, -1);
+#else
+ image = stgMallocBytes(imageSize, "loadArchive(image)");
+#endif
n = fread ( image, 1, imageSize, f );
if (n != imageSize)
barf("loadObj: error whilst reading `%s'", path);
stgFree(file);
return 1;
}
-#else
-HsInt GNU_ATTRIBUTE(__noreturn__)
-loadArchive( char *path STG_UNUSED ) {
- barf("loadArchive: not enabled");
-}
-#endif
/* -----------------------------------------------------------------------------
* Load an obj (populate the global symbol table, but don't resolve yet)
rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
endif
-ifeq "$(UseArchivesForGhci)" "YES"
-rts_CC_OPTS += -DUSE_ARCHIVES_FOR_GHCI
-endif
-
# Mac OS X: make sure we compile for the right OS version
rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
$1_$2_CONFIGURE_OPTS += --enable-shared
endif
-ifeq "$$(GhcWithInterpreter) $$(UseArchivesForGhci)" "YES NO"
+ifeq "$$(GhcWithInterpreter)" "YES"
$1_$2_CONFIGURE_OPTS += --enable-library-for-ghci
else
$1_$2_CONFIGURE_OPTS += --disable-library-for-ghci
# Build the GHCi library
ifeq "$3" "v"
$1_$2_GHCI_LIB = $1/$2/build/HS$$($1_PACKAGE)-$$($1_$2_VERSION).$$($3_osuf)
+ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
# Don't put bootstrapping packages in the bindist
ifneq "$4" "0"
-ifeq "$$(UseArchivesForGhci)" "NO"
BINDIST_LIBS += $$($1_$2_GHCI_LIB)
endif
endif
$$($1_$2_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
"$$(LD)" -r -o $$@ $$(EXTRA_LD_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` $$($1_$2_EXTRA_OBJS)
-ifeq "$$(UseArchivesForGhci)" "NO"
+ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
+# Don't bother making ghci libs for bootstrapping packages
+ifneq "$4" "0"
+# $$(info Here $1 $2 $$($1_$2_BUILD_GHCI_LIB) Q1)
$(call all-target,$1_$2,$$($1_$2_GHCI_LIB))
endif
endif
+endif
endef
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (wrap $ forDeps Installed.libraryDirs),
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries),
- variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions)]
+ variablePrefix ++ "_DEP_LD_OPTS = " ++ unwords (forDeps Installed.ldOptions),
+ variablePrefix ++ "_BUILD_GHCI_LIB = " ++ boolToYesNo (withGHCiLib lbi)]
writeFile (distdir ++ "/package-data.mk") $ unlines xs
writeFile (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd
where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = map (\s -> "\'" ++ s ++ "\'")
+ boolToYesNo True = "YES"
+ boolToYesNo False = "NO"