Commit 9142c238 authored by Ian Lynagh's avatar Ian Lynagh

Always enable the archive-loading code

If the GHCi .o lib doesn't exist, load the .a instead
parent 71d0e9a0
...@@ -135,12 +135,6 @@ ifeq "$(RelocatableBuild)" "YES" ...@@ -135,12 +135,6 @@ ifeq "$(RelocatableBuild)" "YES"
@echo 'cRelocatableBuild = True' >> $@ @echo 'cRelocatableBuild = True' >> $@
else else
@echo 'cRelocatableBuild = False' >> $@ @echo 'cRelocatableBuild = False' >> $@
endif
@echo 'cUseArchivesForGhci :: Bool' >> $@
ifeq "$(UseArchivesForGhci)" "YES"
@echo 'cUseArchivesForGhci = True' >> $@
else
@echo 'cUseArchivesForGhci = False' >> $@
endif endif
@echo 'cLibFFI :: Bool' >> $@ @echo 'cLibFFI :: Bool' >> $@
ifeq "$(UseLibFFIForAdjustors)" "YES" ifeq "$(UseLibFFIForAdjustors)" "YES"
...@@ -363,10 +357,9 @@ compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS ...@@ -363,10 +357,9 @@ compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
endif endif
# If we're profiling GHC then we want lots of SCCs, so -auto-all # 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, # 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 # Unfortunately this means that we have to tell ghc-pkg --force as it
# tell ghc-pkg --force as it gets upset when libHSghc-6.9.a doesn't # gets upset when libHSghc-6.9.a doesn't exist.
# exist.
ifeq "$(GhcProfiled)" "YES" ifeq "$(GhcProfiled)" "YES"
compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
# We seem to still build the vanilla libraries even if we say # We seem to still build the vanilla libraries even if we say
...@@ -375,7 +368,6 @@ compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all ...@@ -375,7 +368,6 @@ compiler_stage2_CONFIGURE_OPTS += --ghc-option=-auto-all
# their absence when we register the package. So for now, we just # their absence when we register the package. So for now, we just
# leave the vanilla libraries enabled. # leave the vanilla libraries enabled.
# compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
endif endif
...@@ -472,6 +464,16 @@ $(eval $(call build-package,compiler,stage1,0)) ...@@ -472,6 +464,16 @@ $(eval $(call build-package,compiler,stage1,0))
$(eval $(call build-package,compiler,stage2,1)) $(eval $(call build-package,compiler,stage2,1))
$(eval $(call build-package,compiler,stage3,2)) $(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: # after build-package, because that sets compiler_stage1_HC_OPTS:
compiler_stage1_HC_OPTS += $(GhcStage1HcOpts) compiler_stage1_HC_OPTS += $(GhcStage1HcOpts)
compiler_stage2_HC_OPTS += $(GhcStage2HcOpts) compiler_stage2_HC_OPTS += $(GhcStage2HcOpts)
......
...@@ -1106,41 +1106,28 @@ loadFrameworks pkg ...@@ -1106,41 +1106,28 @@ loadFrameworks pkg
locateOneObj :: [FilePath] -> String -> IO LibrarySpec locateOneObj :: [FilePath] -> String -> IO LibrarySpec
locateOneObj dirs lib locateOneObj dirs lib
| not isDynamicGhcLib | not isDynamicGhcLib
-- When the GHC package was not compiled as dynamic library -- When the GHC package was not compiled as dynamic library
-- (=DYNAMIC not set), we search for .o libraries. -- (=DYNAMIC not set), we search for .o libraries or, if they
= do mb_libSpec <- if cUseArchivesForGhci -- don't exist, .a libraries.
then do mb_arch_path <- findFile mk_arch_path dirs = findObject `orElse` findArchive `orElse` assumeDll
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)
| otherwise | otherwise
-- When the GHC package was compiled as dynamic library (=DYNAMIC set), -- When the GHC package was compiled as dynamic library (=DYNAMIC set),
-- we search for .so libraries first. -- we search for .so libraries first.
= do { mb_lib_path <- findFile mk_dyn_lib_path dirs = findDll `orElse` findObject `orElse` findArchive `orElse` assumeDll
; 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
where where
mk_obj_path dir = dir </> (lib <.> "o") mk_obj_path dir = dir </> (lib <.> "o")
mk_arch_path dir = dir </> ("lib" ++ lib <.> "a") mk_arch_path dir = dir </> ("lib" ++ lib <.> "a")
dyn_lib_name = lib ++ "-ghc" ++ cProjectVersion dyn_lib_name = lib ++ "-ghc" ++ cProjectVersion
mk_dyn_lib_path dir = dir </> mkSOName dyn_lib_name 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) -- Loading a dyanmic library (dlopen()-ish on Unix, LoadLibrary-ish on Win32)
......
...@@ -2285,7 +2285,6 @@ compilerInfo = [("Project name", String cProjectName), ...@@ -2285,7 +2285,6 @@ compilerInfo = [("Project name", String cProjectName),
("Object splitting", String cSplitObjs), ("Object splitting", String cSplitObjs),
("Have native code generator", String cGhcWithNativeCodeGen), ("Have native code generator", String cGhcWithNativeCodeGen),
("Have llvm code generator", String cGhcWithLlvmCodeGen), ("Have llvm code generator", String cGhcWithLlvmCodeGen),
("Use archives for ghci", String (show cUseArchivesForGhci)),
("Support SMP", String cGhcWithSMP), ("Support SMP", String cGhcWithSMP),
("Unregisterised", String cGhcUnregisterised), ("Unregisterised", String cGhcUnregisterised),
("Tables next to code", String cGhcEnableTablesNextToCode), ("Tables next to code", String cGhcEnableTablesNextToCode),
......
...@@ -190,12 +190,6 @@ else ...@@ -190,12 +190,6 @@ else
UseLibFFIForAdjustors=YES UseLibFFIForAdjustors=YES
endif endif
ifeq "$(findstring $(HostOS_CPP), darwin)" ""
UseArchivesForGhci = NO
else
UseArchivesForGhci = YES
endif
# On Windows we normally want to make a relocatable bindist, to we # On Windows we normally want to make a relocatable bindist, to we
# ignore flags like libdir # ignore flags like libdir
ifeq "$(Windows)" "YES" ifeq "$(Windows)" "YES"
......
...@@ -1670,7 +1670,6 @@ mkOc( char *path, char *image, int imageSize, ...@@ -1670,7 +1670,6 @@ mkOc( char *path, char *image, int imageSize,
return oc; return oc;
} }
#if defined(USE_ARCHIVES_FOR_GHCI)
HsInt HsInt
loadArchive( char *path ) loadArchive( char *path )
{ {
...@@ -1765,11 +1764,16 @@ loadArchive( char *path ) ...@@ -1765,11 +1764,16 @@ loadArchive( char *path )
/* We can't mmap from the archive directly, as object /* We can't mmap from the archive directly, as object
files need to be 8-byte aligned but files in .ar files need to be 8-byte aligned but files in .ar
archives are 2-byte aligned, and if we malloc the archives are 2-byte aligned. When possible we use mmap
memory then we can be given memory above 2^32, so we to get some anonymous memory, as on 64-bit platforms if
mmap some anonymous memory and use that. We could we use malloc then we can be given memory above 2^32.
do better here. */ In the mmap case we're probably wasting lots of space;
we could do better. */
#ifdef USE_MMAP
image = mmapForLinker(imageSize, MAP_ANONYMOUS, -1); image = mmapForLinker(imageSize, MAP_ANONYMOUS, -1);
#else
image = stgMallocBytes(imageSize, "loadArchive(image)");
#endif
n = fread ( image, 1, imageSize, f ); n = fread ( image, 1, imageSize, f );
if (n != imageSize) if (n != imageSize)
barf("loadObj: error whilst reading `%s'", path); barf("loadObj: error whilst reading `%s'", path);
...@@ -1817,12 +1821,6 @@ loadArchive( char *path ) ...@@ -1817,12 +1821,6 @@ loadArchive( char *path )
stgFree(file); stgFree(file);
return 1; 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) * Load an obj (populate the global symbol table, but don't resolve yet)
......
...@@ -246,10 +246,6 @@ ifeq "$(UseLibFFIForAdjustors)" "YES" ...@@ -246,10 +246,6 @@ ifeq "$(UseLibFFIForAdjustors)" "YES"
rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
endif endif
ifeq "$(UseArchivesForGhci)" "YES"
rts_CC_OPTS += -DUSE_ARCHIVES_FOR_GHCI
endif
# Mac OS X: make sure we compile for the right OS version # Mac OS X: make sure we compile for the right OS version
rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS) rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS)
rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS))
......
...@@ -25,7 +25,7 @@ ifeq "$$(filter dyn,$$(GhcLibWays))" "dyn" ...@@ -25,7 +25,7 @@ ifeq "$$(filter dyn,$$(GhcLibWays))" "dyn"
$1_$2_CONFIGURE_OPTS += --enable-shared $1_$2_CONFIGURE_OPTS += --enable-shared
endif endif
ifeq "$$(GhcWithInterpreter) $$(UseArchivesForGhci)" "YES NO" ifeq "$$(GhcWithInterpreter)" "YES"
$1_$2_CONFIGURE_OPTS += --enable-library-for-ghci $1_$2_CONFIGURE_OPTS += --enable-library-for-ghci
else else
$1_$2_CONFIGURE_OPTS += --disable-library-for-ghci $1_$2_CONFIGURE_OPTS += --disable-library-for-ghci
......
...@@ -102,19 +102,23 @@ endif ...@@ -102,19 +102,23 @@ endif
# Build the GHCi library # Build the GHCi library
ifeq "$3" "v" ifeq "$3" "v"
$1_$2_GHCI_LIB = $1/$2/build/HS$$($1_PACKAGE)-$$($1_$2_VERSION).$$($3_osuf) $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 # Don't put bootstrapping packages in the bindist
ifneq "$4" "0" ifneq "$4" "0"
ifeq "$$(UseArchivesForGhci)" "NO"
BINDIST_LIBS += $$($1_$2_GHCI_LIB) BINDIST_LIBS += $$($1_$2_GHCI_LIB)
endif endif
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) $$($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) "$$(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)) $(call all-target,$1_$2,$$($1_$2_GHCI_LIB))
endif endif
endif endif
endif
endef endef
...@@ -372,7 +372,8 @@ generate config_args distdir directory ...@@ -372,7 +372,8 @@ generate config_args distdir directory
variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions), variablePrefix ++ "_DEP_CC_OPTS = " ++ unwords (forDeps Installed.ccOptions),
variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (wrap $ forDeps Installed.libraryDirs), variablePrefix ++ "_DEP_LIB_DIRS = " ++ unwords (wrap $ forDeps Installed.libraryDirs),
variablePrefix ++ "_DEP_EXTRA_LIBS = " ++ unwords (forDeps Installed.extraLibraries), 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 ++ "/package-data.mk") $ unlines xs
writeFile (distdir ++ "/haddock-prologue.txt") $ writeFile (distdir ++ "/haddock-prologue.txt") $
if null (description pd) then synopsis pd if null (description pd) then synopsis pd
...@@ -380,3 +381,5 @@ generate config_args distdir directory ...@@ -380,3 +381,5 @@ generate config_args distdir directory
where where
escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) [] escape = foldr (\c xs -> if c == '#' then '\\':'#':xs else c:xs) []
wrap = map (\s -> "\'" ++ s ++ "\'") wrap = map (\s -> "\'" ++ s ++ "\'")
boolToYesNo True = "YES"
boolToYesNo False = "NO"
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