From: Ian Lynagh Date: Sat, 27 Nov 2010 17:30:00 +0000 (+0000) Subject: Always enable the archive-loading code X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=9142c238bd014c45e30fc79eee69fa6ab3f469d8 Always enable the archive-loading code If the GHCi .o lib doesn't exist, load the .a instead --- diff --git a/compiler/ghc.mk b/compiler/ghc.mk index 0f419c6..60a65d4 100644 --- a/compiler/ghc.mk +++ b/compiler/ghc.mk @@ -136,12 +136,6 @@ ifeq "$(RelocatableBuild)" "YES" 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' >> $@ @@ -363,10 +357,9 @@ compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS 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 @@ -375,7 +368,6 @@ compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all # 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 @@ -472,6 +464,16 @@ $(eval $(call build-package,compiler,stage1,0)) $(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) diff --git a/compiler/ghci/Linker.lhs b/compiler/ghci/Linker.lhs index cc90cb5..29228b1 100644 --- a/compiler/ghci/Linker.lhs +++ b/compiler/ghci/Linker.lhs @@ -1106,41 +1106,28 @@ loadFrameworks pkg 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) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index 7a4607a..df51f94 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -2285,7 +2285,6 @@ compilerInfo = [("Project name", String cProjectName), ("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), diff --git a/mk/config.mk.in b/mk/config.mk.in index 495b251..fd6ee47 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -190,12 +190,6 @@ else 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" diff --git a/rts/Linker.c b/rts/Linker.c index 657c2c3..6ce16d9 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1670,7 +1670,6 @@ mkOc( char *path, char *image, int imageSize, return oc; } -#if defined(USE_ARCHIVES_FOR_GHCI) HsInt loadArchive( char *path ) { @@ -1765,11 +1764,16 @@ 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); @@ -1817,12 +1821,6 @@ loadArchive( char *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) diff --git a/rts/ghc.mk b/rts/ghc.mk index 2bd67de..55a11ba 100644 --- a/rts/ghc.mk +++ b/rts/ghc.mk @@ -246,10 +246,6 @@ ifeq "$(UseLibFFIForAdjustors)" "YES" 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)) diff --git a/rules/build-package-data.mk b/rules/build-package-data.mk index 2ed47e1..9b8474a 100644 --- a/rules/build-package-data.mk +++ b/rules/build-package-data.mk @@ -25,7 +25,7 @@ ifeq "$$(filter dyn,$$(GhcLibWays))" "dyn" $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 diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk index d829a00..ed81d6d 100644 --- a/rules/build-package-way.mk +++ b/rules/build-package-way.mk @@ -102,19 +102,23 @@ endif # 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 diff --git a/utils/ghc-cabal/ghc-cabal.hs b/utils/ghc-cabal/ghc-cabal.hs index cce40c5..81b47db 100644 --- a/utils/ghc-cabal/ghc-cabal.hs +++ b/utils/ghc-cabal/ghc-cabal.hs @@ -372,7 +372,8 @@ generate config_args distdir directory 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 @@ -380,3 +381,5 @@ generate config_args distdir directory where escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) [] wrap = map (\s -> "\'" ++ s ++ "\'") + boolToYesNo True = "YES" + boolToYesNo False = "NO"