Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
f3a77b2f
Commit
f3a77b2f
authored
Apr 21, 2011
by
Ian Lynagh
Browse files
Rename "extra-gcc-opts" to "settings", and start generalising it
parent
70f79a6c
Changes
13
Hide whitespace changes
Inline
Side-by-side
compiler/main/DriverPipeline.hs
View file @
f3a77b2f
...
...
@@ -1028,7 +1028,7 @@ runPhase cc_phase input_fn dflags
(
cmdline_include_paths
++
pkg_include_dirs
)
let
md_c_flags
=
machdepCCOpts
dflags
gcc_extra_viac_flags
<-
io
$
getE
xtraViaC
Opt
s
dflags
let
gcc_extra_viac_flags
=
e
xtra
Gcc
ViaC
Flag
s
dflags
let
pic_c_flags
=
picCCOpts
dflags
let
verbFlags
=
getVerbFlags
dflags
...
...
compiler/main/DynFlags.hs
View file @
f3a77b2f
...
...
@@ -61,7 +61,6 @@ module DynFlags (
getStgToDo
,
-- * Compiler configuration suitable for display to the user
Printable
(
..
),
compilerInfo
#
ifdef
GHCI
-- Only in stage 2 can we be sure that the RTS
...
...
@@ -484,10 +483,12 @@ data DynFlags = DynFlags {
-- Package flags
extraPkgConfs
::
[
FilePath
],
topDir
::
FilePath
,
-- filled in by SysTools
systemPackageConfig
::
FilePath
,
-- ditto
-- ^ The @-package-conf@ flags given on the command line, in the order
-- they appeared.
topDir
::
FilePath
,
-- filled in by SysTools
settings
::
[(
String
,
String
)],
-- filled in by SysTools
extraGccViaCFlags
::
[
String
],
-- filled in by SysTools
systemPackageConfig
::
FilePath
,
-- filled in by SysTools
packageFlags
::
[
PackageFlag
],
-- ^ The @-package@ and @-hide-package@ flags from the command-line
...
...
@@ -724,6 +725,8 @@ defaultDynFlags =
ghcUsagePath
=
panic
"defaultDynFlags: No ghciUsagePath"
,
ghciUsagePath
=
panic
"defaultDynFlags: No ghciUsagePath"
,
topDir
=
panic
"defaultDynFlags: No topDir"
,
settings
=
panic
"defaultDynFlags: No settings"
,
extraGccViaCFlags
=
panic
"defaultDynFlags: No extraGccViaCFlags"
,
systemPackageConfig
=
panic
"no systemPackageConfig: call GHC.setSessionDynFlags"
,
pgm_L
=
panic
"defaultDynFlags: No pgm_L"
,
pgm_P
=
panic
"defaultDynFlags: No pgm_P"
,
...
...
@@ -2140,11 +2143,10 @@ setOptHpcDir arg = upd $ \ d -> d{hpcDir = arg}
-- There are some options that we need to pass to gcc when compiling
-- Haskell code via C, but are only supported by recent versions of
-- gcc. The configure script decides which of these options we need,
--
and puts them in the file "extra-gcc
-opts" in $topdir
, which is
-- read before each via-C compilation. The advantage of
having these
-- in a separate file is that the file can be creat
ed at install-time
-- depending on the available gcc version, and even re-generated later
--
and puts them in the "settings" file in $topdir.
The advantage of
--
having these
in a separate file is that the file can be created at
--
install-time
depending on the available gcc version, and even
--
re-generated later
if gcc is upgraded.
--
-- The options below are not dependent on the version of gcc, only the
-- platform.
...
...
@@ -2222,30 +2224,35 @@ can_split = cSupportsSplitObjs == "YES"
-- -----------------------------------------------------------------------------
-- Compiler Info
data
Printable
=
String
String
|
FromDynFlags
(
DynFlags
->
String
)
compilerInfo
::
[(
String
,
Printable
)]
compilerInfo
=
[(
"Project name"
,
String
cProjectName
),
(
"Project version"
,
String
cProjectVersion
),
(
"Booter version"
,
String
cBooterVersion
),
(
"Stage"
,
String
cStage
),
(
"Build platform"
,
String
cBuildPlatformString
),
(
"Host platform"
,
String
cHostPlatformString
),
(
"Target platform"
,
String
cTargetPlatformString
),
(
"Have interpreter"
,
String
cGhcWithInterpreter
),
(
"Object splitting supported"
,
String
cSupportsSplitObjs
),
(
"Have native code generator"
,
String
cGhcWithNativeCodeGen
),
(
"Support SMP"
,
String
cGhcWithSMP
),
(
"Unregisterised"
,
String
cGhcUnregisterised
),
(
"Tables next to code"
,
String
cGhcEnableTablesNextToCode
),
(
"RTS ways"
,
String
cGhcRTSWays
),
(
"Leading underscore"
,
String
cLeadingUnderscore
),
(
"Debug on"
,
String
(
show
debugIsOn
)),
(
"LibDir"
,
FromDynFlags
topDir
),
(
"Global Package DB"
,
FromDynFlags
systemPackageConfig
),
(
"C compiler flags"
,
String
(
show
cCcOpts
)),
(
"Gcc Linker flags"
,
String
(
show
cGccLinkerOpts
)),
(
"Ld Linker flags"
,
String
(
show
cLdLinkerOpts
))
]
compilerInfo
::
DynFlags
->
[(
String
,
String
)]
compilerInfo
dflags
=
-- We always make "Project name" be first to keep parsing in
-- other languages simple, i.e. when looking for other fields,
-- you don't have to worry whether there is a leading '[' or not
(
"Project name"
,
cProjectName
)
-- Next come the settings, so anything else can be overridden
-- in the settings file (as "lookup" uses the first match for the
-- key)
:
settings
dflags
++
[(
"Project version"
,
cProjectVersion
),
(
"Booter version"
,
cBooterVersion
),
(
"Stage"
,
cStage
),
(
"Build platform"
,
cBuildPlatformString
),
(
"Host platform"
,
cHostPlatformString
),
(
"Target platform"
,
cTargetPlatformString
),
(
"Have interpreter"
,
cGhcWithInterpreter
),
(
"Object splitting supported"
,
cSupportsSplitObjs
),
(
"Have native code generator"
,
cGhcWithNativeCodeGen
),
(
"Support SMP"
,
cGhcWithSMP
),
(
"Unregisterised"
,
cGhcUnregisterised
),
(
"Tables next to code"
,
cGhcEnableTablesNextToCode
),
(
"RTS ways"
,
cGhcRTSWays
),
(
"Leading underscore"
,
cLeadingUnderscore
),
(
"Debug on"
,
show
debugIsOn
),
(
"LibDir"
,
topDir
dflags
),
(
"Global Package DB"
,
systemPackageConfig
dflags
),
(
"C compiler flags"
,
show
cCcOpts
),
(
"Gcc Linker flags"
,
show
cGccLinkerOpts
),
(
"Ld Linker flags"
,
show
cLdLinkerOpts
)
]
compiler/main/SysTools.lhs
View file @
f3a77b2f
...
...
@@ -26,7 +26,6 @@ module SysTools (
touch, -- String -> String -> IO ()
copy,
copyWithHeader,
getExtraViaCOpts,
-- Temporary-file management
setTmpDir,
...
...
@@ -162,6 +161,19 @@ initSysTools mbMinusB dflags0
-- NB: top_dir is assumed to be in standard Unix
-- format, '/' separated
; let settingsFile = top_dir </> "settings"
; settingsStr <- readFile settingsFile
; mySettings <- case maybeReadFuzzy settingsStr of
Just s ->
return s
Nothing ->
pgmError ("Can't parse " ++ show settingsFile)
; let getSetting key = case lookup key mySettings of
Just xs ->
return xs
Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
; let installed :: FilePath -> FilePath
installed file = top_dir </> file
installed_mingw_bin file = top_dir </> ".." </> "mingw" </> "bin" </> file
...
...
@@ -229,6 +241,8 @@ initSysTools mbMinusB dflags0
ghcUsagePath = ghc_usage_msg_path,
ghciUsagePath = ghci_usage_msg_path,
topDir = top_dir,
settings = mySettings,
extraGccViaCFlags = words myExtraGccViaCFlags,
systemPackageConfig = pkgconfig_path,
pgm_L = unlit_path,
pgm_P = cpp_path,
...
...
@@ -448,11 +462,6 @@ copyWithHeader dflags purpose maybe_header from to = do
hClose hout
hClose hin
getExtraViaCOpts :: DynFlags -> IO [String]
getExtraViaCOpts dflags = do
f <- readFile (topDir dflags </> "extra-gcc-opts")
return (words f)
-- | read the contents of the named section in an ELF object as a
-- String.
readElfSection :: DynFlags -> String -> FilePath -> IO (Maybe String)
...
...
compiler/utils/Util.lhs
View file @
f3a77b2f
...
...
@@ -66,6 +66,9 @@ module Util (
-- * Floating point
readRational,
-- * read helpers
maybeReadFuzzy,
-- * IO-ish utilities
createDirectoryHierarchy,
doesDirNameExist,
...
...
@@ -965,6 +968,17 @@ readRational top_s
_ -> error ("readRational: ambiguous parse:" ++ top_s)
-----------------------------------------------------------------------------
-- read helpers
maybeReadFuzzy :: Read a => String -> Maybe a
maybeReadFuzzy str = case reads str of
[(x, s)]
| all isSpace s ->
Just x
_ ->
Nothing
-----------------------------------------------------------------------------
-- Create a hierarchy of directories
...
...
configure.ac
View file @
f3a77b2f
...
...
@@ -931,7 +931,7 @@ if grep ' ' compiler/ghc.cabal.in 2>&1 >/dev/null; then
AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them])
fi
AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal ghc.spec
extra-gcc-opt
s docs/users_guide/ug-book.xml docs/users_guide/ug-ent.xml docs/index.html libraries/prologue.txt distrib/ghc.iss distrib/configure.ac])
AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal ghc.spec
setting
s docs/users_guide/ug-book.xml docs/users_guide/ug-ent.xml docs/index.html libraries/prologue.txt distrib/ghc.iss distrib/configure.ac])
AC_CONFIG_COMMANDS([mk/stamp-h],[echo timestamp > mk/stamp-h])
AC_OUTPUT
...
...
distrib/Makefile
View file @
f3a77b2f
...
...
@@ -34,7 +34,7 @@ install::
$(MAKE)
-C
gmp
install
DOING_BIN_DIST
=
YES
$(MAKE)
-C
docs install-docs
DOING_BIN_DIST
=
YES
$(MAKE)
-C
libraries/Cabal/doc install-docs
DOING_BIN_DIST
=
YES
$(INSTALL_DATA)
$(INSTALL_OPTS)
extra-gcc-opt
s
$(libdir)
$(INSTALL_DATA)
$(INSTALL_OPTS)
setting
s
$(libdir)
install
::
postinstall denounce
...
...
distrib/configure.ac.in
View file @
f3a77b2f
...
...
@@ -88,7 +88,7 @@ dnl ** how to invoke `ar' and `ranlib'
FP_PROG_AR_NEEDS_RANLIB
#
AC_CONFIG_FILES(
extra-gcc-opt
s mk/config.mk mk/install.mk)
AC_CONFIG_FILES(
setting
s mk/config.mk mk/install.mk)
AC_OUTPUT
# We get caught by
...
...
extra-gcc-opts.in
deleted
100644 → 0
View file @
70f79a6c
@GccExtraViaCOpts@
ghc.mk
View file @
f3a77b2f
...
...
@@ -750,7 +750,7 @@ TAGS: TAGS_compiler
# -----------------------------------------------------------------------------
# Installation
install
:
install_
package
s install_
lib
s install_libexecs install_headers
\
install
:
install_
lib
s install_
package
s install_libexecs install_headers
\
install_libexec_scripts install_bins install_topdirs
ifeq
"$(HADDOCK_DOCS)" "YES"
install
:
install_docs
...
...
@@ -904,7 +904,7 @@ $(eval $(call bindist,.,\
README
\
INSTALL
\
configure
config.sub
config.guess
install-sh
\
extra-gcc-opt
s.in
\
setting
s.in
\
packages
\
Makefile
\
mk/config.mk.in
\
...
...
@@ -933,7 +933,7 @@ $(eval $(call bindist,.,\
compiler/stage2/doc
\
$(wildcard
libraries/*/dist-install/doc/)
\
$(wildcard
libraries/*/*/dist-install/doc/)
\
$(filter-out
extra-gcc-opt
s,$(INSTALL_LIBS))
\
$(filter-out
setting
s,$(INSTALL_LIBS))
\
$(filter-out
%/project.mk
mk/config.mk
%/mk/install.mk,$(MAKEFILE_LIST))
\
mk/project.mk
\
mk/install.mk.in
\
...
...
@@ -954,7 +954,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk
unix-binary-dist-prep
:
"
$(RM)
"
$(RM_OPTS_REC)
bindistprep/
"
$(MKDIRHIER)
"
$(BIN_DIST_PREP_DIR)
set
-e
;
for
i
in
packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh
extra-gcc-opt
s.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL
;
do
ln
-s
../../
$$
i
$(BIN_DIST_PREP_DIR)
/
;
done
set
-e
;
for
i
in
packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh
setting
s.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL
;
do
ln
-s
../../
$$
i
$(BIN_DIST_PREP_DIR)
/
;
done
echo
"HADDOCK_DOCS =
$(HADDOCK_DOCS)
"
>>
$(BIN_DIST_MK)
echo
"LATEX_DOCS =
$(LATEX_DOCS)
"
>>
$(BIN_DIST_MK)
echo
"BUILD_DOCBOOK_HTML =
$(BUILD_DOCBOOK_HTML)
"
>>
$(BIN_DIST_MK)
...
...
@@ -1043,7 +1043,7 @@ SRC_DIST_DIRS = mk rules docs distrib bindisttest libffi includes utils docs rts
SRC_DIST_FILES
+=
\
configure.ac config.guess config.sub configure
\
aclocal.m4 README ANNOUNCE HACKING LICENSE Makefile install-sh
\
ghc.spec.in ghc.spec
extra-gcc-opt
s.in VERSION
\
ghc.spec.in ghc.spec
setting
s.in VERSION
\
boot boot-pkgs packages ghc.mk
SRC_DIST_TARBALL
=
$(SRC_DIST_NAME)
-src
.tar.bz2
...
...
@@ -1158,7 +1158,7 @@ distclean : clean
"
$(RM)
"
$(RM_OPTS)
config.cache config.status config.log mk/config.h mk/stamp-h
"
$(RM)
"
$(RM_OPTS)
mk/config.mk mk/are-validating.mk mk/project.mk
"
$(RM)
"
$(RM_OPTS)
mk/config.mk.old mk/project.mk.old
"
$(RM)
"
$(RM_OPTS)
extra-gcc-opt
s docs/users_guide/ug-book.xml
"
$(RM)
"
$(RM_OPTS)
setting
s docs/users_guide/ug-book.xml
"
$(RM)
"
$(RM_OPTS)
compiler/ghc.cabal compiler/ghc.cabal.old
"
$(RM)
"
$(RM_OPTS)
ghc/ghc-bin.cabal
"
$(RM)
"
$(RM_OPTS)
libraries/base/include/HsBaseConfig.h
...
...
ghc/Main.hs
View file @
f3a77b2f
...
...
@@ -358,9 +358,6 @@ showVersionMode = mkPreStartupMode ShowVersion
showNumVersionMode
=
mkPreStartupMode
ShowNumVersion
showSupportedExtensionsMode
=
mkPreStartupMode
ShowSupportedExtensions
printMode
::
String
->
Mode
printMode
str
=
mkPreStartupMode
(
Print
str
)
mkPreStartupMode
::
PreStartupMode
->
Mode
mkPreStartupMode
=
Left
...
...
@@ -383,8 +380,10 @@ showGhcUsageMode = mkPreLoadMode ShowGhcUsage
showGhciUsageMode
=
mkPreLoadMode
ShowGhciUsage
showInfoMode
=
mkPreLoadMode
ShowInfo
printWithDynFlagsMode
::
(
DynFlags
->
String
)
->
Mode
printWithDynFlagsMode
f
=
mkPreLoadMode
(
PrintWithDynFlags
f
)
printSetting
::
String
->
Mode
printSetting
k
=
mkPreLoadMode
(
PrintWithDynFlags
f
)
where
f
dflags
=
fromMaybe
(
panic
(
"Setting not found: "
++
show
k
))
$
lookup
k
(
compilerInfo
dflags
)
mkPreLoadMode
::
PreLoadMode
->
Mode
mkPreLoadMode
=
Right
.
Left
...
...
@@ -504,14 +503,30 @@ mode_flags =
,
Flag
"-supported-languages"
(
PassFlag
(
setMode
showSupportedExtensionsMode
))
,
Flag
"-supported-extensions"
(
PassFlag
(
setMode
showSupportedExtensionsMode
))
]
++
[
Flag
k'
(
PassFlag
(
setMode
mode
))
|
(
k
,
v
)
<-
compilerInfo
,
[
Flag
k'
(
PassFlag
(
setMode
(
printSetting
k
)))
|
k
<-
[
"Project version"
,
"Booter version"
,
"Stage"
,
"Build platform"
,
"Host platform"
,
"Target platform"
,
"Have interpreter"
,
"Object splitting supported"
,
"Have native code generator"
,
"Support SMP"
,
"Unregisterised"
,
"Tables next to code"
,
"RTS ways"
,
"Leading underscore"
,
"Debug on"
,
"LibDir"
,
"Global Package DB"
,
"C compiler flags"
,
"Gcc Linker flags"
,
"Ld Linker flags"
],
let
k'
=
"-print-"
++
map
(
replaceSpace
.
toLower
)
k
replaceSpace
' '
=
'-'
replaceSpace
c
=
c
mode
=
case
v
of
String
str
->
printMode
str
FromDynFlags
f
->
printWithDynFlagsMode
f
]
++
------- interfaces ----------------------------------------------------
[
Flag
"-show-iface"
(
HasArg
(
\
f
->
setMode
(
showInterfaceMode
f
)
...
...
@@ -649,9 +664,7 @@ showBanner _postLoadMode dflags = do
showInfo
::
DynFlags
->
IO
()
showInfo
dflags
=
do
let
sq
x
=
" ["
++
x
++
"
\n
]"
putStrLn
$
sq
$
concat
$
intersperse
"
\n
,"
$
map
(
show
.
flatten
)
compilerInfo
where
flatten
(
k
,
String
v
)
=
(
k
,
v
)
flatten
(
k
,
FromDynFlags
f
)
=
(
k
,
f
dflags
)
putStrLn
$
sq
$
intercalate
"
\n
,"
$
map
show
$
compilerInfo
dflags
showSupportedExtensions
::
IO
()
showSupportedExtensions
=
mapM_
putStrLn
supportedLanguagesAndExtensions
...
...
ghc/ghc-bin.cabal.in
View file @
f3a77b2f
...
...
@@ -14,7 +14,7 @@ Description:
XXX
Category: XXX
Data-Dir: ..
Data-Files:
extra-gcc-opt
s
Data-Files:
setting
s
Build-Type: Simple
Cabal-Version: >= 1.2
...
...
ghc/ghc.mk
View file @
f3a77b2f
...
...
@@ -108,15 +108,15 @@ all_ghc_stage1 : $(GHC_STAGE1)
all_ghc_stage2
:
$(GHC_STAGE2)
all_ghc_stage3
:
$(GHC_STAGE3)
$(INPLACE_LIB)/
extra-gcc-opts
:
extra-gcc-opt
s
$(INPLACE_LIB)/
settings
:
setting
s
"
$(CP)
"
$<
$@
# The GHC programs need to depend on all the helper programs they might call,
# and the settings files they use
$(GHC_STAGE1)
:
| $(UNLIT) $(INPLACE_LIB)/
extra-gcc-opt
s
$(GHC_STAGE2)
:
| $(UNLIT) $(INPLACE_LIB)/
extra-gcc-opt
s
$(GHC_STAGE3)
:
| $(UNLIT) $(INPLACE_LIB)/
extra-gcc-opt
s
$(GHC_STAGE1)
:
| $(UNLIT) $(INPLACE_LIB)/
setting
s
$(GHC_STAGE2)
:
| $(UNLIT) $(INPLACE_LIB)/
setting
s
$(GHC_STAGE3)
:
| $(UNLIT) $(INPLACE_LIB)/
setting
s
ifeq
"$(GhcUnregisterised)" "NO"
$(GHC_STAGE1)
:
| $(SPLIT)
...
...
@@ -137,7 +137,7 @@ endif
endif
INSTALL_LIBS
+=
extra-gcc-opt
s
INSTALL_LIBS
+=
setting
s
ifeq
"$(Windows)" "NO"
install
:
install_ghc_link
...
...
settings.in
0 → 100644
View file @
f3a77b2f
[("GCC extra via C opts", "@GccExtraViaCOpts@")]
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment