RE: when is compilation necessary
I assume you mean 'bar' in module Main? | Now, suppose I change Foo.hs so that "foo x = x + 2". If I | ghc --make on | Main, it will build Foo, then Bar, then Main, then link. Is | all of this necessary or can I (manually) just rebuild Foo | and then relink? Necessary with -O (because the defn of foo may be inlined in Bar). Not necessary without -O. GHC takes a look at Bar, in case foo's type has changed, but the "skipping" message says that it decided that nothing had changed. cam-02-unx:~/tmp$ ghc --make Main ghc-5.02.3: chasing modules from: Main Compiling A ( A.hs, A.o ) Skipping B ( B.hs, B.o ) Skipping Main ( Main.hs, ./Main.o ) ghc: linking ... Simon | suppose i have three modules: | | > module Foo(foo) where | > foo x = x + 1 | | > module Bar(bar) where | > import Foo | > bar x = foo (x+1) | | > module Main(main) where | > import Bar | > main = print (foo 5) | | Now, suppose I change Foo.hs so that "foo x = x + 2". If I | ghc --make on | Main, it will build Foo, then Bar, then Main, then link. Is | all of this necessary or can I (manually) just rebuild Foo | and then relink? | | -- | Hal Daume III | | "Computer science is no more about computers | hdaume@isi.edu | than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-| haskell-users |
On Thu, 20 Jun 2002, Simon Peyton-Jones wrote:
I assume you mean 'bar' in module Main?
Yes :)
| Now, suppose I change Foo.hs so that "foo x = x + 2". If I | ghc --make on | Main, it will build Foo, then Bar, then Main, then link. Is | all of this necessary or can I (manually) just rebuild Foo | and then relink?
Necessary with -O (because the defn of foo may be inlined in Bar). Not necessary without -O. GHC takes a look at Bar, in case foo's type has changed, but the "skipping" message says that it decided that nothing had changed.
So...suppose I compile with -O and it inlines foo into Bar. I then change foo to be "foo x = x + 2" and recompile --make Main without -O. Is there a possibility that result won't have the correct version of foo? - Hal
participants (2)
-
Hal Daume III -
Simon Peyton-Jones