Commit df2e8675 authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Merge branch 'master' of http://darcs.haskell.org/ghc

parents c3ad38d7 2fb8da2b
Getting started with hacking on GHC
-----------------------------------
So you've decided to hack on GHC, congratulations! We hope you have a
rewarding experience. This file will point you in the direction of
information to help you get started right away.
The GHC Developer's Wiki
------------------------
The home for GHC Developers, with information on accessing the
latest sources, the bug tracker, and documentation on the
code:
http://hackage.haskell.org/trac/ghc
In particular, the wiki contains the following pages of interest to
new hackers:
Quick Start for developers
http://hackage.haskell.org/trac/ghc/wiki/Building/Hacking
This section on the wiki will get you up and running with a
serviceable build tree in no time.
Don't skip this! By default, GHC builds with all optimizations
and profiling; most hackers will want a quicker build, so creating
a mk/build.mk file and knowing how to rebuild only parts of GHC is
very important.
This is part of the "Building GHC" section of the wiki, which
has more detailed information on GHC's build system should you
need it.
Coding conventions
http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions
This wiki page explains the ground rules for code that is intended
to go into the mainline compiler source.
The GHC Commentary
http://hackage.haskell.org/trac/ghc/wiki/Commentary
Notes on the internals and architecture of GHC.
Mailing lists
-------------
Ask on glasgow-haskell-users@haskell.org if you have difficulties.
If you're working with the current darcs sources of GHC, then
cvs-ghc@haskell.org might be a more appropriate (developers hang
out here). See http://www.haskell.org/mailman/listinfo for
subscription.
Happy Hacking! --The GHC Team
Contributing to the Glasgow Haskell Compiler
============================================
So you've decided to hack on GHC, congratulations! We hope you have a
rewarding experience. This file will point you in the direction of
information to help you get started right away.
The GHC Developer's Wiki
========================
The home for GHC hackers is our Trac instance, located here:
<http://hackage.haskell.org/trac/ghc>
From here, you can file bugs (or look them up,) use the wiki, view the
`git` history, among other things. Of particular note is the building
page, which has the high level overview of the build process and how
to get the source:
<http://hackage.haskell.org/trac/ghc/wiki/Building>
Contributing patches to GHC in a hurry
======================================
Make sure your system has the necessary tools to compile GHC. You can
find an overview here:
<http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation>
Next, clone the repository and all the associated libraries:
```
$ git clone http://darcs.haskell.org/ghc.git/
$ cd ghc
$ ./sync-all --testsuite get
```
First copy `mk/build.mk.sample` to `mk/build.mk` and ensure it has
your preferred build settings. (You probably want to at least set
`BuildFlavour` to `quick`):
```
$ cp mk/build.mk.sample mk/build.mk
$ ... double-check mk/build.mk ...
```
Now build. If you have multiple cores, **you should always use them to
speed up compilation**:
```
$ ./boot
$ ./configure
$ make -jN # <N> is the number of cores you have.
```
You can use the `./inplace/bin/ghc-stage2` binary to play with the
newly built compiler.
Now, hack on your copy and rebuild (with `make`) as necessary.
Then start by making your commits however you want. When you're done, you
can use `git format-patch` to create a series of `.patch` files you
can give to us. In this example, we'll assume I'm on a `bugfix` branch
and want to submit my patches:
```
$ git branch
* bugfix
master
$ git format-patch master -o patches
...
$
```
Now create a trac ticket:
<http://hackage.haskell.org/trac/ghc/newticket?type=bug>
And attach the files in your `patches/` directory. Set the status from
*new* to *patch* and we'll review it as soon as we can!
Useful links:
=============
An overview of things like using git, the release process, filing bugs
and more can be located here:
<http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions>
You can find our coding conventions for the compiler and RTS here:
<http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle>
<http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions>
A high level overview of the bug tracker:
<http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions/BugTracker>
If you're going to contribute regularly, **learning how to use the
build system is important** and will save you lots of time. You should
read over this page carefully:
<http://hackage.haskell.org/trac/ghc/wiki/Building/Using>
How to communicate with us
==========================
GHC is a big project, so you'll surely need help. Luckily, we can
provide plenty through a variety of means!
## IRC
If you're an IRC user, be sure to drop by the official `#ghc` channel
on [freenode](http://freenode.org). Many (but not all) of the
developers and committers are actively there during a variety of
hours.
## Mailing lists
In the event IRC does not work or if you'd like a bigger audience, GHC
has several mailing lists for this purpose. The most important one is
[ghc-devs](http://www.haskell.org/pipermail/ghc-devs/), which is where
the developers actively hang out and discuss incoming changes and
problems.
There is no strict standard about where you post patches - either in
`ghc-devs` or in the bug tracker. Ideally, please put it in the bug
tracker with test cases or relevant information in a ticket, and set
the ticket status to `patch`. By doing this, we'll see the patch
quickly and be able to review. This will also ensure it doesn't get
lost. But if the change is small and self contained, feel free to
attach it to your email, and send it to `ghc-devs`.
Furthermore, if you're a developer (or want to become one!) you're
undoubtly also interested in the other mailing lists:
* [glasgow-haskell-users](http://www.haskell.org/mailman/listinfo/glasgow-haskell-users)
is where developers/users meet.
* [ghc-tickets](http://www.haskell.org/mailman/listinfo/ghc-tickets)
for email from Trac.
* [ghc-builds](http://www.haskell.org/mailman/listinfo/ghc-builds)
for nightly build emails.
* [ghc-commits](http://www.haskell.org/mailman/listinfo/ghc-commits)
for commit messages when someone pushes to the repository.
El fin
======
Happy Hacking! -- The GHC Team
......@@ -79,22 +79,51 @@ repos in sync with the [sync-all script] [7]. To get the latest changes:
$ ./sync-all pull
$ ./sync-all get
Contributors
============
Please see the list of [GHC contributors](http://www.haskell.org/ghc/contributors.html "www.haskell.org/ghc/contributors.html").
[1]: http://www.haskell.org/ghc/ "www.haskell.org/ghc/"
[2]: http://hackage.haskell.org/trac/ghc "hackage.haskell.org/trac/ghc"
[3]: http://hackage.haskell.org/trac/ghc/wiki/Building
"hackage.haskell.org/trac/ghc/wiki/Building"
[4]: http://www.haskell.org/happy/ "www.haskell.org/happy/"
[5]: http://www.haskell.org/alex/ "www.haskell.org/alex/"
[6]: http://www.haskell.org/haddock/ "www.haskell.org/haddock/"
[7]: http://hackage.haskell.org/trac/ghc/wiki/Building/SyncAll
"http://hackage.haskell.org/trac/ghc/wiki/Building/SyncAll"
[8]: http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation
"http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation"
[9]: http://www.haskell.org/cabal/ "http://www.haskell.org/cabal/"
Filing bugs and feature requests
================================
If you've encountered what you believe is a bug in GHC, or you'd like
to propose a feature request, please let us know! Submit a ticket in
our [bug tracker] [10] and we'll be sure to look into it. Remember:
**Filing a bug is the best way to make sure your issue isn't lost over
time**, so please feel free.
If you're an active user of GHC, you may also be interested in joining
the [glasgow-haskell-users] [11] mailing list, where developers and
GHC users discuss various topics and hang out.
Hacking & Developing GHC
========================
Once you've filed a bug, maybe you'd like to fix it yourself? That
would be great, and we'd surely love your company! If you're looking
to hack on GHC, check out the guidelines in the `HACKING.md` file in
this directory - they'll get you up to speed quickly.
Contributors & Acknowledgements
===============================
GHC in its current form wouldn't exist without the hard work of
[its many contributors] [12]. Over time, it has grown to include the
efforts and research of many institutions, highly talented people, and
groups from around the world. We'd like to thank them all, and invite
you to join!
[1]: http://www.haskell.org/ghc/ "www.haskell.org/ghc/"
[2]: http://hackage.haskell.org/trac/ghc "hackage.haskell.org/trac/ghc"
[3]: http://hackage.haskell.org/trac/ghc/wiki/Building
"hackage.haskell.org/trac/ghc/wiki/Building"
[4]: http://www.haskell.org/happy/ "www.haskell.org/happy/"
[5]: http://www.haskell.org/alex/ "www.haskell.org/alex/"
[6]: http://www.haskell.org/haddock/ "www.haskell.org/haddock/"
[7]: http://hackage.haskell.org/trac/ghc/wiki/Building/SyncAll
"http://hackage.haskell.org/trac/ghc/wiki/Building/SyncAll"
[8]: http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation
"http://hackage.haskell.org/trac/ghc/wiki/Building/Preparation"
[9]: http://www.haskell.org/cabal/ "http://www.haskell.org/cabal/"
[10]: http://hackage.haskell.org/trac/ghc/
"http://hackage.haskell.org/trac/ghc/"
[11]: http://www.haskell.org/pipermail/glasgow-haskell-users/
"http://www.haskell.org/pipermail/glasgow-haskell-users/"
[12]: http://hackage.haskell.org/trac/ghc/wiki/Contributors
"http://hackage.haskell.org/trac/ghc/wiki/Contributors"
......@@ -1965,16 +1965,16 @@ AC_DEFUN([XCODE_VERSION],[
#
AC_DEFUN([FIND_LLVM_PROG],[
FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3])
if test "$$1" != ""; then
if test "$$1" == ""; then
save_IFS=$IFS
IFS=":;"
for p in ${PATH}; do
if test -d "${p}"; then
if test -d "${p}"; then
$1=`${FindCmd} "${p}" -type f -perm +111 -maxdepth 1 -regex '.*/$3-[[0-9]]\.[[0-9]]' -or -type l -perm +111 -maxdepth 1 -regex '.*/$3-[[0-9]]\.[[0-9]]' | ${SortCmd} -n | tail -1`
if test -n "$1"; then
break
fi
fi
fi
done
IFS=$save_IFS
fi
......
......@@ -35,7 +35,7 @@ test_bindist:
mkdir bindisttest/a/b/c
cd bindisttest/a/b/c/ && $(BZIP2_CMD) -cd ../../../../$(BIN_DIST_TEST_TAR_BZ2) | $(TAR_CMD) -xf -
$(SHELL) bindisttest/checkBinaries.sh $(ProjectVersion)
ifeq "$(Windows)" "YES"
ifeq "$(Windows_Host)" "YES"
mv bindisttest/a/b/c/$(BIN_DIST_NAME) $(BIN_DIST_INST_DIR)
else
cd bindisttest/a/b/c/$(BIN_DIST_NAME) && ./configure --prefix=$(TOP)/$(BIN_DIST_INST_DIR) --with-gcc="$(WhatGccIsCalled)"
......
......@@ -131,8 +131,9 @@ sub boot_pkgs {
or die "Opening $package/ghc.mk failed: $!";
print GHCMK "${package}_PACKAGE = ${pkg}\n";
print GHCMK "${package}_dist-install_GROUP = libraries\n";
print GHCMK "\$(if \$(filter ${dir},\$(PKGS_THAT_BUILD_WITH_STAGE0)),\$(eval \$(call build-package,${package},dist-boot,0)))\n";
print GHCMK "\$(eval \$(call build-package,${package},dist-install,\$(if \$(filter ${dir},\$(PKGS_THAT_BUILD_WITH_STAGE2)),2,1)))\n";
print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE0)),\$(eval \$(call build-package,${package},dist-boot,0)))\n";
print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE1)),\$(eval \$(call build-package,${package},dist-install,1)))\n";
print GHCMK "\$(if \$(filter ${dir},\$(PACKAGES_STAGE2)),\$(eval \$(call build-package,${package},dist-install,2)))\n";
close GHCMK
or die "Closing $package/ghc.mk failed: $!";
......
......@@ -101,22 +101,10 @@ endif
@echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
@echo 'cRAWCPP_FLAGS :: String' >> $@
@echo 'cRAWCPP_FLAGS = "$(RAWCPP_FLAGS)"' >> $@
@echo 'cGHC_DRIVER_DIR :: String' >> $@
@echo 'cGHC_DRIVER_DIR = "$(GHC_DRIVER_DIR)"' >> $@
@echo 'cGHC_UNLIT_PGM :: String' >> $@
@echo 'cGHC_UNLIT_PGM = "$(GHC_UNLIT_PGM)"' >> $@
@echo 'cGHC_UNLIT_DIR :: String' >> $@
@echo 'cGHC_UNLIT_DIR = "$(GHC_UNLIT_DIR)"' >> $@
@echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
@echo 'cGHC_SPLIT_PGM :: String' >> $@
@echo 'cGHC_SPLIT_PGM = "$(GHC_SPLIT_PGM)"' >> $@
@echo 'cGHC_SPLIT_DIR :: String' >> $@
@echo 'cGHC_SPLIT_DIR = "$(GHC_SPLIT_DIR)"' >> $@
@echo 'cGHC_SYSMAN_PGM :: String' >> $@
@echo 'cGHC_SYSMAN_PGM = "$(GHC_SYSMAN)"' >> $@
@echo 'cGHC_SYSMAN_DIR :: String' >> $@
@echo 'cGHC_SYSMAN_DIR = "$(GHC_SYSMAN_DIR)"' >> $@
@echo 'cDEFAULT_TMPDIR :: String' >> $@
@echo 'cDEFAULT_TMPDIR = "$(DEFAULT_TMPDIR)"' >> $@
@echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
@echo 'cLibFFI :: Bool' >> $@
ifeq "$(UseLibFFIForAdjustors)" "YES"
@echo 'cLibFFI = True' >> $@
......@@ -258,33 +246,33 @@ compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
$$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --data-decl < $$< > $$@
compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --primop-tag < $$< > $$@
compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --primop-list < $$< > $$@
compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --has-side-effects < $$< > $$@
compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --out-of-line < $$< > $$@
compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --commutable < $$< > $$@
compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --code-size < $$< > $$@
compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --can-fail < $$< > $$@
compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --strictness < $$< > $$@
compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --fixity < $$< > $$@
compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --primop-primop-info < $$< > $$@
compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
# Usages aren't used any more; but the generator
# can still generate them if we want them back
compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
"$$(GENPRIMOP_INPLACE)" --usage < $$< > $$@
compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
"$$(genprimopcode_INPLACE)" --usage < $$< > $$@
endef
......@@ -409,10 +397,6 @@ compiler_stage1_REGISTER_PACKAGE = NO
endif
# haddocking only happens for stage2
compiler_stage1_DO_HADDOCK = NO
compiler_stage3_DO_HADDOCK = NO
# Don't do splitting for the GHC package, it takes too long and
# there's not much benefit.
compiler_stage1_SplitObjs = NO
......
......@@ -303,12 +303,12 @@ reallyInitDynLinker dflags =
-- (e) Link any MacOS frameworks
; let platform = targetPlatform dflags
; let framework_paths = case platformOS platform of
OSDarwin -> frameworkPaths dflags
_ -> []
; let frameworks = case platformOS platform of
OSDarwin -> cmdlineFrameworks dflags
_ -> []
; let framework_paths = if platformUsesFrameworks platform
then frameworkPaths dflags
else []
; let frameworks = if platformUsesFrameworks platform
then cmdlineFrameworks dflags
else []
-- Finally do (c),(d),(e)
; let cmdline_lib_specs = [ l | Just l <- classified_ld_inputs ]
++ libspecs
......@@ -389,13 +389,12 @@ preloadLib dflags lib_paths framework_paths lib_spec
Just mm -> preloadFailed mm lib_paths lib_spec
Framework framework ->
case platformOS (targetPlatform dflags) of
OSDarwin ->
do maybe_errstr <- loadFramework framework_paths framework
case maybe_errstr of
Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm framework_paths lib_spec
_ -> panic "preloadLib Framework"
if platformUsesFrameworks (targetPlatform dflags)
then do maybe_errstr <- loadFramework framework_paths framework
case maybe_errstr of
Nothing -> maybePutStrLn dflags "done"
Just mm -> preloadFailed mm framework_paths lib_spec
else panic "preloadLib Framework"
where
platform = targetPlatform dflags
......@@ -1156,9 +1155,9 @@ load_dyn dll = do r <- loadDLL dll
loadFrameworks :: Platform -> InstalledPackageInfo_ ModuleName -> IO ()
loadFrameworks platform pkg
= case platformOS platform of
OSDarwin -> mapM_ load frameworks
_ -> return ()
= if platformUsesFrameworks platform
then mapM_ load frameworks
else return ()
where
fw_dirs = Packages.frameworkDirs pkg
frameworks = Packages.frameworks pkg
......
......@@ -917,7 +917,7 @@ pprMatch ctxt (Match pats maybe_ty grhss)
(herald, other_pats)
= case ctxt of
FunRhs fun is_infix
| not is_infix -> (ppr fun, pats)
| not is_infix -> (pprPrefixOcc fun, pats)
-- f x y z = e
-- Not pprBndr; the AbsBinds will
-- have printed the signature
......@@ -928,7 +928,7 @@ pprMatch ctxt (Match pats maybe_ty grhss)
| otherwise -> (parens pp_infix, pats2)
-- (x &&& y) z = e
where
pp_infix = pprParendLPat pat1 <+> ppr fun <+> pprParendLPat pat2
pp_infix = pprParendLPat pat1 <+> pprInfixOcc fun <+> pprParendLPat pat2
LambdaExpr -> (char '\\', pats)
......
......@@ -61,6 +61,9 @@ moduleLayout = sdocWithPlatform $ \platform ->
Platform { platformArch = ArchARM {}, platformOS = OSAndroid } ->
text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
$+$ text "target triple = \"arm-unknown-linux-androideabi\""
Platform { platformArch = ArchARM {}, platformOS = OSiOS } ->
text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\""
$+$ text "target triple = \"arm-apple-darwin10\""
_ ->
-- FIX: Other targets
empty
......
......@@ -49,7 +49,8 @@ codeOutput :: DynFlags
-> ForeignStubs
-> [PackageId]
-> Stream IO RawCmmGroup () -- Compiled C--
-> IO (Bool{-stub_h_exists-}, Maybe FilePath{-stub_c_exists-})
-> IO (FilePath,
(Bool{-stub_h_exists-}, Maybe FilePath{-stub_c_exists-}))
codeOutput dflags this_mod location foreign_stubs pkg_deps cmm_stream
=
......@@ -74,13 +75,13 @@ codeOutput dflags this_mod location foreign_stubs pkg_deps cmm_stream
; let filenm = hscOutName dflags
; stubs_exist <- outputForeignStubs dflags this_mod location foreign_stubs
; case hscTarget dflags of {
HscInterpreted -> return ();
HscAsm -> outputAsm dflags filenm linted_cmm_stream;
HscC -> outputC dflags filenm linted_cmm_stream pkg_deps;
HscLlvm -> outputLlvm dflags filenm linted_cmm_stream;
HscInterpreted -> panic "codeOutput: HscInterpreted";
HscNothing -> panic "codeOutput: HscNothing"
}
; return stubs_exist
; return (filenm, stubs_exist)
}
doOutput :: String -> (Handle -> IO a) -> IO a
......
......@@ -108,7 +108,7 @@ compile = compile' (hscCompileNothing, hscCompileInteractive, hscCompileBatch)
compile' ::
(Compiler (HscStatus, ModIface, ModDetails),
Compiler (InteractiveStatus, ModIface, ModDetails),
Compiler (HscStatus, ModIface, ModDetails))
Compiler (FileOutputStatus, ModIface, ModDetails))
-> HscEnv
-> ModSummary -- ^ summary for module being compiled
-> Int -- ^ module N ...
......@@ -149,9 +149,8 @@ compile' (nothingCompiler, interactiveCompiler, batchCompiler)
output_fn <- getOutputFilename next_phase
Temporary basename dflags next_phase (Just location)
let dflags' = dflags { hscTarget = hsc_lang,
hscOutName = output_fn,
extCoreName = basename ++ ".hcr" }
let dflags' = dflags { hscOutName = output_fn,
extCoreName = basename ++ ".hcr" }
let hsc_env' = hsc_env { hsc_dflags = dflags' }
-- -fforce-recomp should also work with --make
......@@ -441,6 +440,10 @@ compileFile hsc_env stop_phase (src, mb_phase) = do
-- When linking, the -o argument refers to the linker's output.
-- otherwise, we use it as the name for the pipeline's output.
output
-- If we are dong -fno-code, then act as if the output is
-- 'Temporary'. This stops GHC trying to copy files to their
-- final location.
| HscNothing <- hscTarget dflags = Temporary
| StopLn <- stop_phase, not (isNoLink ghc_link) = Persistent
-- -o foo applies to linker
| Just o_file <- mb_o_file = SpecificFile o_file
......@@ -712,50 +715,47 @@ pipeLoop phase input_fn = do
getOutputFilename
:: Phase -> PipelineOutput -> String
-> DynFlags -> Phase{-next phase-} -> Maybe ModLocation -> IO FilePath
getOutputFilename stop_phase output basename
= func
where
func dflags next_phase maybe_location
| is_last_phase, Persistent <- output = persistent_fn
| is_last_phase, SpecificFile f <- output = return f
| keep_this_output = persistent_fn
| otherwise = newTempName dflags suffix
where
hcsuf = hcSuf dflags
odir = objectDir dflags
osuf = objectSuf dflags
keep_hc = gopt Opt_KeepHcFiles dflags
keep_s = gopt Opt_KeepSFiles dflags
keep_bc = gopt Opt_KeepLlvmFiles dflags
myPhaseInputExt HCc = hcsuf
myPhaseInputExt MergeStub = osuf
myPhaseInputExt StopLn = osuf
myPhaseInputExt other = phaseInputExt other
is_last_phase = next_phase `eqPhase` stop_phase
-- sometimes, we keep output from intermediate stages
keep_this_output =
case next_phase of
As | keep_s -> True
LlvmOpt | keep_bc -> True
HCc | keep_hc -> True
_other -> False
suffix = myPhaseInputExt next_phase
-- persistent object files get put in odir
persistent_fn
| StopLn <- next_phase = return odir_persistent
| otherwise = return persistent
persistent = basename <.> suffix
odir_persistent
| Just loc <- maybe_location = ml_obj_file loc
| Just d <- odir = d </> persistent
| otherwise = persistent
getOutputFilename stop_phase output basename dflags next_phase maybe_location
| is_last_phase, Persistent <- output = persistent_fn
| is_last_phase, SpecificFile f <- output = return f
| keep_this_output = persistent_fn
| otherwise = newTempName dflags suffix
where
hcsuf = hcSuf dflags
odir = objectDir dflags
osuf = objectSuf dflags
keep_hc = gopt Opt_KeepHcFiles dflags
keep_s = gopt Opt_KeepSFiles dflags
keep_bc = gopt Opt_KeepLlvmFiles dflags
myPhaseInputExt HCc = hcsuf
myPhaseInputExt MergeStub = osuf
myPhaseInputExt StopLn = osuf
myPhaseInputExt other = phaseInputExt other
is_last_phase = next_phase `eqPhase` stop_phase