Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
7bc48677
Commit
7bc48677
authored
Apr 25, 2016
by
Andrey Mokhov
Browse files
Add CompilerMode Link.
See
#223
.
parent
98041b26
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/Builder.hs
View file @
7bc48677
...
...
@@ -15,11 +15,14 @@ import Oracles.LookupInPath
import
Oracles.WindowsPath
import
Stage
-- TODO: Add Link mode?
-- | A C or Haskell compiler can be used in two modes: for compiling sources
-- into object files, or for extracting source dependencies, e.g. by passing -M
-- command line option.
data
CompilerMode
=
Compile
|
FindDependencies
deriving
(
Show
,
Eq
,
Generic
)
-- | A compiler can typically be used in one of three modes:
-- 1) Compiling sources into object files.
-- 2) Extracting source dependencies, e.g. by passing -M command line argument.
-- 3) Linking object files & static libraries into an executable.
data
CompilerMode
=
Compile
|
FindDependencies
|
Link
deriving
(
Show
,
Eq
,
Generic
)
-- TODO: Do we really need HsCpp builder? Can't we use Cc instead?
-- | A 'Builder' is an external command invoked in separate process using 'Shake.cmd'
...
...
@@ -138,8 +141,7 @@ getBuilderPath = lift . builderPath
specified
::
Builder
->
Action
Bool
specified
=
fmap
(
not
.
null
)
.
builderPath
-- TODO: split into two functions: needBuilder (without laxDependencies) and
-- unsafeNeedBuilder (with the laxDependencies parameter)
-- TODO: Get rid of laxDependencies -- we no longer need it (use Shake's skip).
-- | Make sure a builder exists on the given path and rebuild it if out of date.
-- If 'laxDependencies' is True then we do not rebuild GHC even if it is out of
-- date (can save a lot of build time when changing GHC).
...
...
src/Rules/Program.hs
View file @
7bc48677
...
...
@@ -99,8 +99,7 @@ buildBinary rs context@(Context stage package _) bin = do
then
[
pkgPath
package
-/-
src
<.>
"hs"
|
src
<-
hSrcs
]
else
objs
need
$
binDeps
++
libs
-- TODO: Use Link mode instead of Compile.
buildWithResources
rs
$
Target
context
(
Ghc
Compile
stage
)
binDeps
[
bin
]
buildWithResources
rs
$
Target
context
(
Ghc
Link
stage
)
binDeps
[
bin
]
synopsis
<-
interpretInContext
context
$
getPkgData
Synopsis
putSuccess
$
renderProgram
(
"'"
++
pkgNameString
package
++
"' ("
++
show
stage
++
")."
)
...
...
src/Settings/Builders/Ghc.hs
View file @
7bc48677
...
...
@@ -18,8 +18,9 @@ import Settings.Builders.Common (cIncludeArgs)
-- $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
-- $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno
-- $$(addsuffix .$$(dyn_osuf)-boot,$$(basename $$@)))
-- TODO: Simplify
ghcBuilderArgs
::
Args
ghcBuilderArgs
=
stagedBuilder
(
Ghc
Compile
)
?
do
ghcBuilderArgs
=
(
stagedBuilder
(
Ghc
Compile
)
||^
stagedBuilder
(
Ghc
Link
))
?
do
output
<-
getOutput
stage
<-
getStage
way
<-
getWay
...
...
@@ -27,16 +28,6 @@ ghcBuilderArgs = stagedBuilder (Ghc Compile) ? do
let
buildObj
=
any
(
\
s
->
(
"//*."
++
s
way
)
?==
output
)
[
osuf
,
obootsuf
]
buildHi
=
any
(
\
s
->
(
"//*."
++
s
way
)
?==
output
)
[
hisuf
,
hibootsuf
]
buildProg
=
not
(
buildObj
||
buildHi
)
libs
<-
getPkgDataList
DepExtraLibs
gmpLibs
<-
if
stage
>
Stage0
&&
buildProg
then
do
-- TODO: get this data more gracefully
buildInfo
<-
lift
$
readFileLines
gmpBuildInfoPath
let
extract
s
=
case
stripPrefix
"extra-libraries: "
s
of
Nothing
->
[]
Just
value
->
words
value
return
$
concatMap
extract
buildInfo
else
return
[]
libDirs
<-
getPkgDataList
DepLibDirs
mconcat
[
commonGhcArgs
,
arg
"-H32m"
,
stage0
?
arg
"-O"
...
...
@@ -44,14 +35,29 @@ ghcBuilderArgs = stagedBuilder (Ghc Compile) ? do
,
arg
"-Wall"
,
arg
"-fwarn-tabs"
,
splitObjectsArgs
,
buildProg
?
arg
"-no-auto-link-packages"
,
buildProg
?
append
[
"-optl-l"
++
lib
|
lib
<-
libs
++
gmpLibs
]
,
buildProg
?
append
[
"-optl-L"
++
dir
|
dir
<-
libDirs
]
,
buildProg
?
ghcLinkArgs
,
not
buildProg
?
arg
"-c"
,
append
=<<
getInputs
,
buildHi
?
append
[
"-fno-code"
,
"-fwrite-interface"
]
,
not
buildHi
?
mconcat
[
arg
"-o"
,
arg
=<<
getOutput
]
]
ghcLinkArgs
::
Args
ghcLinkArgs
=
stagedBuilder
(
Ghc
Link
)
?
do
stage
<-
getStage
libs
<-
getPkgDataList
DepExtraLibs
gmpLibs
<-
if
stage
>
Stage0
then
do
-- TODO: get this data more gracefully
buildInfo
<-
lift
$
readFileLines
gmpBuildInfoPath
let
extract
s
=
case
stripPrefix
"extra-libraries: "
s
of
Nothing
->
[]
Just
value
->
words
value
return
$
concatMap
extract
buildInfo
else
return
[]
libDirs
<-
getPkgDataList
DepLibDirs
mconcat
[
arg
"-no-auto-link-packages"
,
append
[
"-optl-l"
++
lib
|
lib
<-
libs
++
gmpLibs
]
,
append
[
"-optl-L"
++
dir
|
dir
<-
libDirs
]
]
needTouchy
::
Action
()
needTouchy
=
whenM
windowsHost
$
need
[
fromJust
$
programPath
(
vanillaContext
Stage0
touchy
)]
...
...
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