ROLLBACK: picCCOpts: -dynamic should not entail -optc-fPIC
authorSimon Marlow <marlowsd@gmail.com>
Mon, 21 Jun 2010 10:04:09 +0000 (10:04 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 21 Jun 2010 10:04:09 +0000 (10:04 +0000)
and add a comment to explain why it was wrong.  This fixes the dyn
test failures that sprang up recently.

compiler/main/DynFlags.hs

index 6cde987..581d810 100644 (file)
@@ -2205,7 +2205,12 @@ picCCOpts _dflags
     | otherwise
         = []
 #else
-    | opt_PIC
+      -- we need -fPIC for C files when we are compiling with -dynamic,
+      -- otherwise things like stub.c files don't get compiled
+      -- correctly.  They need to reference data in the Haskell
+      -- objects, but can't without -fPIC.  See
+      -- http://hackage.haskell.org/trac/ghc/wiki/Commentary/PositionIndependentCode
+    | opt_PIC || not opt_Static
         = ["-fPIC", "-U __PIC__", "-D__PIC__"]
     | otherwise
         = []