Fix broken -fPIC on Darwin/PPC (#7442)
authorPHO <pho@cielonegro.org>
Sat, 24 Nov 2012 11:07:27 +0000 (20:07 +0900)
committerPHO <pho@cielonegro.org>
Sat, 24 Nov 2012 11:07:27 +0000 (20:07 +0900)
The workaround described in note [darwin-x86-pic] applies to Darwin/PPC too.

compiler/cmm/CmmPipeline.hs

index 4e9a90a..159a31d 100644 (file)
@@ -183,10 +183,12 @@ cpsTop hsc_env proc =
         -- the entry point.
         splitting_proc_points = hscTarget dflags /= HscAsm
                              || not (tablesNextToCode dflags)
-                             || usingDarwinX86Pic -- Note [darwin-x86-pic]
-        usingDarwinX86Pic = platformArch platform == ArchX86
-                         && platformOS platform == OSDarwin
-                         && gopt Opt_PIC dflags
+                             || usingInconsistentPicReg -- Note [darwin-x86-pic]
+        usingInconsistentPicReg = ( platformArch platform == ArchX86 ||
+                                    platformArch platform == ArchPPC
+                                  )
+                               && platformOS platform == OSDarwin
+                               && gopt Opt_PIC dflags
 
 {- Note [darwin-x86-pic]
 
@@ -205,6 +207,12 @@ points, then at the join point we don't have a consistent value for
 Hence, on x86/Darwin, we have to split proc points, and then each proc
 point will get its own PIC initialisation sequence.
 
+The situation is the same for ppc/Darwin. We use essentially the same
+sequence to load the program counter onto reg:
+
+    bcl  20,31,1f
+ 1: mflr reg
+
 This isn't an issue on x86/ELF, where the sequence is
 
     call 1f