Unbreak Darwin PIC handling; my refactoring yesterday was bogus.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65154 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py
index ea35de9..8c71789 100644
--- a/tools/ccc/ccclib/ToolChain.py
+++ b/tools/ccc/ccclib/ToolChain.py
@@ -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
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index a9db01a..9d3bd8e 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -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):