[cfe-commits] r62078 - in /cfe/trunk/tools/ccc/ccclib: Driver.py HostInfo.py ToolChain.py Tools.py
Daniel Dunbar
daniel at zuster.org
Sun Jan 11 20:21:14 PST 2009
Author: ddunbar
Date: Sun Jan 11 22:21:12 2009
New Revision: 62078
URL: http://llvm.org/viewvc/llvm-project?rev=62078&view=rev
Log:
ccc: Generalize Darwin/Link tool based on Darwin version.
Modified:
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/HostInfo.py
cfe/trunk/tools/ccc/ccclib/ToolChain.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=62078&r1=62077&r2=62078&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Sun Jan 11 22:21:12 2009
@@ -58,6 +58,12 @@
return platform.system().lower()
+ def getHostReleaseName(self):
+ if self.cccHostRelease:
+ return self.cccHostRelease
+
+ return platform.release()
+
###
def run(self, argv):
@@ -74,7 +80,8 @@
# FIXME: How to handle override of host? ccc specific options?
# Abuse -b?
- self.cccHostBits = self.cccHostMachine = self.cccHostSystem = None
+ self.cccHostBits = self.cccHostMachine = None
+ self.cccHostSystem = self.cccHostRelease = None
while argv and argv[0].startswith('-ccc-'):
opt,argv = argv[0][5:],argv[1:]
@@ -88,6 +95,8 @@
self.cccHostMachine,argv = argv[0],argv[1:]
elif opt == 'host-system':
self.cccHostSystem,argv = argv[0],argv[1:]
+ elif opt == 'host-release':
+ self.cccHostRelease,argv = argv[0],argv[1:]
else:
raise ValueError,"Invalid ccc option: %r" % cccPrintOptions
Modified: cfe/trunk/tools/ccc/ccclib/HostInfo.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/HostInfo.py?rev=62078&r1=62077&r2=62078&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/HostInfo.py (original)
+++ cfe/trunk/tools/ccc/ccclib/HostInfo.py Sun Jan 11 22:21:12 2009
@@ -23,6 +23,17 @@
# Darwin
class DarwinHostInfo(HostInfo):
+ def __init__(self, driver):
+ super(DarwinHostInfo, self).__init__(driver)
+
+ # FIXME: Find right regex for this.
+ import re
+ m = re.match(r'([0-9]+)\.([0-9]+)\.([0-9]+)', driver.getHostReleaseName())
+ if not m:
+ raise RuntimeError,"Unable to determine Darwin version."
+ self.darwinVersion = tuple(map(int, m.groups()))
+ self.gccVersion = (4,2,1)
+
def useDriverDriver(self):
return True
@@ -31,7 +42,9 @@
def getToolChainForArch(self, arch):
if arch in ('i386', 'x86_64'):
- return ToolChain.Darwin10_X86_ToolChain(self.driver)
+ return ToolChain.Darwin_X86_ToolChain(self.driver,
+ self.darwinVersion,
+ self.gccVersion)
return ToolChain.Generic_GCC_ToolChain(self.driver)
Modified: cfe/trunk/tools/ccc/ccclib/ToolChain.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/ToolChain.py?rev=62078&r1=62077&r2=62078&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Sun Jan 11 22:21:12 2009
@@ -14,15 +14,16 @@
some particular action."""
abstract
-class Darwin10_X86_ToolChain(ToolChain):
- def __init__(self, driver):
- super(Darwin10_X86_ToolChain, self).__init__(driver)
+class Darwin_X86_ToolChain(ToolChain):
+ def __init__(self, driver, darwinVersion, gccVersion):
+ super(Darwin_X86_ToolChain, self).__init__(driver)
self.toolMap = {
Phases.PreprocessPhase : Tools.GCC_PreprocessTool(),
Phases.CompilePhase : Tools.GCC_CompileTool(),
Phases.PrecompilePhase : Tools.GCC_PrecompileTool(),
Phases.AssemblePhase : Tools.DarwinAssembleTool(),
- Phases.LinkPhase : Tools.Darwin10_X86_LinkTool(),
+ Phases.LinkPhase : Tools.Darwin_X86_LinkTool(darwinVersion,
+ gccVersion),
Phases.LipoPhase : Tools.LipoTool(),
}
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=62078&r1=62077&r2=62078&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Sun Jan 11 22:21:12 2009
@@ -144,10 +144,24 @@
output, outputType, args, arglist,
[])
-class Darwin10_X86_LinkTool(Tool):
- kCollect2Path = '/usr/libexec/gcc/i686-apple-darwin10/4.2.1/collect2'
- def __init__(self):
- super(Darwin10_X86_LinkTool, self).__init__('collect2')
+class Darwin_X86_LinkTool(Tool):
+ def __init__(self, darwinVersion, gccVersion):
+ super(Darwin_X86_LinkTool, self).__init__('collect2')
+ assert isinstance(darwinVersion, tuple) and len(darwinVersion) == 3
+ assert isinstance(gccVersion, tuple) and len(gccVersion) == 3
+ self.darwinVersion = darwinVersion
+ self.gccVersion = gccVersion
+
+ def getCollect2Path(self):
+ return '/usr/libexec/gcc/%s/collect2' % self.getToolChainDir()
+
+ def getToolChainDir(self):
+ return 'i686-apple-darwin%d/%s' % (self.darwinVersion[0],
+ '.'.join(map(str,self.gccVersion)))
+
+ def getMacosxVersionMin(self):
+ major,minor,minorminor = self.darwinVersion
+ return '%d.%d.%d' % (10, major-4, minor)
def addDarwinArch(self, cmd_args, arch, arglist):
# Derived from darwin_arch spec.
@@ -279,9 +293,7 @@
# following that; it must be getting over-ridden
# somewhere.
cmd_args.append('-macosx_version_min')
- # FIXME: De-hardcode.
- cmd_args.append('10.6.0')
- pass
+ cmd_args.append(self.getMacosxVersionMin())
else:
# addAll doesn't make sense here but this is what gcc
# does.
@@ -467,14 +479,15 @@
cmd_args.append('-lgomp')
# FIXME: Derive these correctly.
- if arglist.getValue(arch) == 'x86_64':
- cmd_args.extend(["-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64",
- "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64"])
- cmd_args.extend(["-L/usr/lib/i686-apple-darwin10/4.2.1",
- "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1",
- "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1",
- "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1",
- "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.."])
+ tcDir = self.getToolChainDir()
+ if arglist.getValue(arch) == 'x86_64':
+ cmd_args.extend(["-L/usr/lib/gcc/%s/x86_64" % tcDir,
+ "-L/usr/lib/gcc/%s/x86_64" % tcDir])
+ cmd_args.extend(["-L/usr/lib/%s" % tcDir,
+ "-L/usr/lib/gcc/%s" % tcDir,
+ "-L/usr/lib/gcc/%s" % tcDir,
+ "-L/usr/lib/gcc/%s/../../../%s" % (tcDir,tcDir),
+ "-L/usr/lib/gcc/%s/../../.." % tcDir])
for input in inputs:
cmd_args.extend(arglist.renderAsInput(input.source))
@@ -531,7 +544,7 @@
arglist.addAllArgs(cmd_args, arglist.parser.TOption)
arglist.addAllArgs(cmd_args, arglist.parser.FOption)
- jobs.addJob(Jobs.Command(self.kCollect2Path, cmd_args))
+ jobs.addJob(Jobs.Command(self.getCollect2Path(), cmd_args))
# FIXME: We need to add a dsymutil job here in some particular
# cases (basically whenever we have a c-family input we are
More information about the cfe-commits
mailing list