From: Ian Lynagh Date: Sat, 18 Aug 2007 22:37:58 +0000 (+0000) Subject: Implement --info, and change how can_split is defined X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=d8e154531c4bb14e1ebe96b7d3c067430a363360 Implement --info, and change how can_split is defined We now get the value of can_split from the SplitObjs setting in the build system, rather than working out whether it should be possible based on the platform. --- diff --git a/compiler/Makefile b/compiler/Makefile index d0c68ab..e881216 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -215,6 +215,7 @@ $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk @echo "cBooterVersion = \"$(GhcVersion)\"" >> $(CONFIG_HS) @echo "cStage = STAGE" >> $(CONFIG_HS) @echo "cHscIfaceFileVersion = \"$(HscIfaceFileVersion)\"" >> $(CONFIG_HS) + @echo "cSplitObjs = \"$(SplitObjs)\"" >> $(CONFIG_HS) @echo "cGhcWithNativeCodeGen = \"$(GhcWithNativeCodeGen)\"" >> $(CONFIG_HS) @echo "cGhcUnregisterised = \"$(GhcUnregisterised)\"" >> $(CONFIG_HS) @echo "cGhcEnableTablesNextToCode = \"$(GhcEnableTablesNextToCode)\"" >> $(CONFIG_HS) diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index bd97d42..3ceface 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -49,6 +49,7 @@ module DynFlags ( -- misc stuff machdepCCOpts, picCCOpts, supportedLanguages, + compilerInfo, ) where #include "HsVersions.h" @@ -1634,18 +1635,21 @@ picCCOpts dflags -- Splitting can_split :: Bool -can_split = -#if defined(i386_TARGET_ARCH) \ - || defined(x86_64_TARGET_ARCH) \ - || defined(alpha_TARGET_ARCH) \ - || defined(hppa_TARGET_ARCH) \ - || defined(m68k_TARGET_ARCH) \ - || defined(mips_TARGET_ARCH) \ - || defined(powerpc_TARGET_ARCH) \ - || defined(rs6000_TARGET_ARCH) \ - || defined(sparc_TARGET_ARCH) - True -#else - False -#endif +can_split = cSplitObjs == "YES" + +-- ----------------------------------------------------------------------------- +-- Compiler Info + +compilerInfo :: [(String, String)] +compilerInfo = [("Project name", cProjectName), + ("Project version", cProjectVersion), + ("Booter version", cBooterVersion), + ("Stage", cStage), + ("Interface file version", cHscIfaceFileVersion), + ("Object splitting", cSplitObjs), + ("Have native code generator", cGhcWithNativeCodeGen), + ("Unregisterised", cGhcUnregisterised), + ("Tables next to code", cGhcEnableTablesNextToCode), + ("Win32 DLLs", cEnableWin32DLLs), + ("Leading underscore", cLeadingUnderscore)] diff --git a/compiler/main/Main.hs b/compiler/main/Main.hs index 3c94bf5..bc18dae 100644 --- a/compiler/main/Main.hs +++ b/compiler/main/Main.hs @@ -85,6 +85,8 @@ main = -- to find out what version of GHC it's using before package.conf -- exists, so starting the session fails. case cli_mode of + ShowInfo -> do showInfo + exitWith ExitSuccess ShowSupportedLanguages -> do showSupportedLanguages exitWith ExitSuccess ShowVersion -> do showVersion @@ -296,6 +298,7 @@ verifyOutputFiles dflags = do data CmdLineMode = ShowUsage -- ghc -? | PrintLibdir -- ghc --print-libdir + | ShowInfo -- ghc --info | ShowSupportedLanguages -- ghc --supported-languages | ShowVersion -- ghc -V/--version | ShowNumVersion -- ghc --numeric-version @@ -360,6 +363,7 @@ mode_flags = , ( "V" , PassFlag (setMode ShowVersion)) , ( "-version" , PassFlag (setMode ShowVersion)) , ( "-numeric-version", PassFlag (setMode ShowNumVersion)) + , ( "-info", PassFlag (setMode ShowInfo)) , ( "-supported-languages", PassFlag (setMode ShowSupportedLanguages)) ------- interfaces ---------------------------------------------------- @@ -449,6 +453,14 @@ showBanner cli_mode dflags = do hPutStr stderr " booted by GHC version " hPutStrLn stderr cBooterVersion +-- We print out a Read-friendly string, but a prettier one than the +-- Show instance gives us +showInfo :: IO () +showInfo = do + let sq x = " [" ++ x ++ "\n ]" + putStrLn $ sq $ concat $ intersperse "\n ," $ map show compilerInfo + exitWith ExitSuccess + showSupportedLanguages :: IO () showSupportedLanguages = do mapM_ putStrLn supportedLanguages exitWith ExitSuccess