[cfe-commits] r65116 - in /cfe/trunk/tools/ccc: ccclib/HostInfo.py ccclib/ToolChain.py ccclib/Tools.py test/ccc/universal-hello.c

Daniel Dunbar daniel at zuster.org
Thu Feb 19 22:48:26 PST 2009


Author: ddunbar
Date: Fri Feb 20 00:48:26 2009
New Revision: 65116

URL: http://llvm.org/viewvc/llvm-project?rev=65116&view=rev
Log:
ccc: Use toolchain hook for default relocation model value.

Modified:
    cfe/trunk/tools/ccc/ccclib/HostInfo.py
    cfe/trunk/tools/ccc/ccclib/ToolChain.py
    cfe/trunk/tools/ccc/ccclib/Tools.py
    cfe/trunk/tools/ccc/test/ccc/universal-hello.c

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

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/HostInfo.py (original)
+++ cfe/trunk/tools/ccc/ccclib/HostInfo.py Fri Feb 20 00:48:26 2009
@@ -47,7 +47,7 @@
                                                   self.darwinVersion,
                                                   self.gccVersion)
 
-        return ToolChain.Generic_GCC_ToolChain(self.driver, arch)
+        return ToolChain.Darwin_GCC_ToolChain(self.driver, arch)
 
 class DarwinPPCHostInfo(DarwinHostInfo):
     def getArchName(self, args):

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

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Fri Feb 20 00:48:26 2009
@@ -86,6 +86,11 @@
     def isMathErrnoDefault(self):
         return True
 
+    def getRelocationModel(self, picEnabled, picDisabled):
+        if picEnabled:
+            return 'pic'
+        return 'static'
+
 class Darwin_X86_ToolChain(ToolChain):
     def __init__(self, driver, archName, darwinVersion, gccVersion):
         super(Darwin_X86_ToolChain, self).__init__(driver, archName)
@@ -224,6 +229,17 @@
     def isMathErrnoDefault(self):
         return False
 
+    def getRelocationModel(self, picEnabled, picDisabled):
+        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
@@ -251,3 +267,13 @@
             return self.clangTool
 
         return self.toolMap[action.phase.__class__]
+
+class Darwin_GCC_ToolChain(Generic_GCC_ToolChain):
+    def getRelocationModel(self, picEnabled, picDisabled):
+        if picEnabled:
+            return 'pic'
+        elif picDisabled:
+            return 'static'
+        else:
+            return 'dynamic-no-pic'
+

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

==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Fri Feb 20 00:48:26 2009
@@ -252,17 +252,11 @@
             picEnabled = (arglist.getLastArg(arglist.parser.f_PICOption) or
                           arglist.getLastArg(arglist.parser.f_picOption) or
                           arglist.getLastArg(arglist.parser.f_PIEOption) or
-                          arglist.getLastArg(arglist.parser.f_pieOption) or
-                          (not arglist.getLastArg(arglist.parser.m_kernelOption) and
-                          not arglist.getLastArg(arglist.parser.staticOption) and
-                          not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption)))
-
-            # FIXME: This needs to tie into a platform hook.
-            if (self.toolChain.archName == 'x86_64' or 
-                picEnabled):
-                cmd_args.append('--relocation-model=pic')
-            elif not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption):
-                cmd_args.append('--relocation-model=static')
+                          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)
+            cmd_args.append('--relocation-model=%s' % model)
 
             if arglist.getLastArg(arglist.parser.f_timeReportOption):
                 cmd_args.append('--time-passes')

Modified: cfe/trunk/tools/ccc/test/ccc/universal-hello.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/test/ccc/universal-hello.c?rev=65116&r1=65115&r2=65116&view=diff

==============================================================================
--- cfe/trunk/tools/ccc/test/ccc/universal-hello.c (original)
+++ cfe/trunk/tools/ccc/test/ccc/universal-hello.c Fri Feb 20 00:48:26 2009
@@ -8,7 +8,7 @@
 // RUN: xcc -ccc-print-phases -### -arch ppc -arch ppc %s | grep linker- | count 1 &&
 
 // Check that -ccc-clang-archs is honored.
-// RUN: xcc -ccc-clang-archs i386 -### -arch ppc -arch i386 %s 2>&1 | grep clang | count 1
+// RUN: xcc -ccc-clang-archs i386 -### -arch ppc -arch i386 %s 2>&1 | grep 'clang"' | count 1
 
 int main() {
   printf("Hello, World!\n");





More information about the cfe-commits mailing list