title: GHC not optimizing modules other than the main module
body: <p>I'm currently writing a multi-module program in Haskell. I've found a strange problem where my files aren't being optimized properly, even though I'm passing in <code>-O2</code> and so on. The files in question are shared 3D vector maths modules. When compiled individually to a .o, these modules are optimized correctly. When compiled as part of a larger program using --make, they are not optimized correctly. The core is quite different.</p>
  
  <p>I've put in some simple stripped-down test code into a vector.hs file:</p>
  
  <pre><code>data TestVector = TestVector !Double !Double !Double !Double
  
  addVec :: TestVector -&gt; TestVector -&gt; TestVector
  
  addVec (TestVector x1 y1 z1 w1) (TestVector x2 y2 z2 w2) =
    TestVector (x1 + x2) (y1 + y2) (z1 + z2) (w1 + w2)
  </code></pre>
  
  <p>And imported it from main...</p>
  
  <pre><code>import Vector
  </code></pre>
  
  <p>This code gets compiled differently as a standalone .hs file as opposed to when I build main.hs using <code>--make</code></p>
  
  <p>My command line is:</p>
  
  <pre><code>ghc -tmpdir tmp -hidir hi -odir obj -fext-core -fexcess-precision -funbox-strict-fields -threaded -rtsopts -fwarn-missing-signatures -Wall -O2 Main.hs -o main
  </code></pre>
  
  <p>Cheers</p>