[cfe-commits] r65154 - in /cfe/trunk/tools/ccc: ccclib/ToolChain.py ccclib/Tools.py test/ccc/darwin-pic.c

Daniel Dunbar daniel at zuster.org
Fri Feb 20 12:52:47 PST 2009


Author: ddunbar
Date: Fri Feb 20 14:52:47 2009
New Revision: 65154

URL: http://llvm.org/viewvc/llvm-project?rev=65154&view=rev
Log:
Unbreak Darwin PIC handling; my refactoring yesterday was bogus.

Added:
    cfe/trunk/tools/ccc/test/ccc/darwin-pic.c
Modified:
    cfe/trunk/tools/ccc/ccclib/ToolChain.py
    cfe/trunk/tools/ccc/ccclib/Tools.py

Modified: cfe/trunk/tools/ccc/ccclib/ToolChain.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/ToolChain.py?rev=65154&r1=65153&r2=65154&view=diff

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Fri Feb 20 14:52:47 2009
@@ -92,10 +92,11 @@
             return True
         return False
 
-    def getRelocationModel(self, picEnabled, picDisabled):
-        if picEnabled:
-            return 'pic'
+    def getDefaultRelocationModel(self):
         return 'static'
+    
+    def getForcedPicModel(self):
+        return 
 
 class Darwin_X86_ToolChain(ToolChain):
     def __init__(self, driver, archName, darwinVersion, gccVersion):
@@ -235,17 +236,13 @@
     def isMathErrnoDefault(self):
         return False
 
-    def getRelocationModel(self, picEnabled, picDisabled):
+    def getDefaultRelocationModel(self):
+        return 'pic'
+    
+    def getForcedPicModel(self):
         if self.archName == 'x86_64':
             return 'pic'
 
-        if picEnabled:
-            return 'pic'
-        elif picDisabled:
-            return 'static'
-        else:
-            return 'dynamic-no-pic'
-
 class Generic_GCC_ToolChain(ToolChain):
     """Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
     perform all subcommands; this relies on gcc translating the

Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=65154&r1=65153&r2=65154&view=diff

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Fri Feb 20 14:52:47 2009
@@ -255,7 +255,16 @@
                           arglist.getLastArg(arglist.parser.f_pieOption))
             picDisabled = (arglist.getLastArg(arglist.parser.m_kernelOption) or
                            arglist.getLastArg(arglist.parser.staticOption))
-            model = self.toolChain.getRelocationModel(picEnabled, picDisabled)
+            model = self.toolChain.getForcedPicModel()
+            if not model:
+                if arglist.getLastArg(arglist.parser.m_dynamicNoPicOption):
+                    model = 'dynamic-no-pic'
+                elif picDisabled:
+                    model = 'static'
+                elif picEnabled:
+                    model = 'pic'
+                else:
+                    model = self.toolChain.getDefaultRelocationModel()
             cmd_args.append('--relocation-model=%s' % model)
 
             if arglist.getLastArg(arglist.parser.f_timeReportOption):

Added: cfe/trunk/tools/ccc/test/ccc/darwin-pic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/test/ccc/darwin-pic.c?rev=65154&view=auto

==============================================================================
--- cfe/trunk/tools/ccc/test/ccc/darwin-pic.c (added)
+++ cfe/trunk/tools/ccc/test/ccc/darwin-pic.c Fri Feb 20 14:52:47 2009
@@ -0,0 +1,11 @@
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - | grep 'L_g0$non_lazy_ptr-' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -fPIC | grep 'L_g0$non_lazy_ptr-' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -mdynamic-no-pic | grep 'L_g0$non_lazy_ptr,' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -static | grep 'non_lazy_ptr' | count 0 &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - | grep '_g0 at GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -fPIC | grep '_g0 at GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -mdynamic-no-pic | grep '_g0 at GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -static | grep '_g0 at GOTPCREL'
+
+int g0;
+int f0() { return g0; }





More information about the cfe-commits mailing list