ccc: Implement macosx-version-min conditions (including a bug fix).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-01-12 05:02:38 +00:00
Родитель 9c257c3922
Коммит 4a0ba1aac1
1 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -163,6 +163,19 @@ class Darwin_X86_LinkTool(Tool):
major,minor,minorminor = self.darwinVersion major,minor,minorminor = self.darwinVersion
return '%d.%d.%d' % (10, major-4, minor) return '%d.%d.%d' % (10, major-4, minor)
def getMacosxVersionTuple(self, arglist):
arg = arglist.getLastArg(arglist.parser.m_macosxVersionMinOption)
if arg:
version = arglist.getValue(arg)
components = version.split('.')
try:
return tuple(map(int, components))
except:
raise ArgumentError,"invalid version number %r" % version
else:
major,minor,minorminor = self.darwinVersion
return (10, major-4, minor)
def addDarwinArch(self, cmd_args, arch, arglist): def addDarwinArch(self, cmd_args, arch, arglist):
# Derived from darwin_arch spec. # Derived from darwin_arch spec.
cmd_args.append('-arch') cmd_args.append('-arch')
@ -411,6 +424,7 @@ class Darwin_X86_LinkTool(Tool):
cmd_args.extend(arglist.render(output)) cmd_args.extend(arglist.render(output))
macosxVersion = self.getMacosxVersionTuple(arglist)
if (not arglist.getLastArg(arglist.parser.AOption) and if (not arglist.getLastArg(arglist.parser.AOption) and
not arglist.getLastArg(arglist.parser.nostdlibOption) and not arglist.getLastArg(arglist.parser.nostdlibOption) and
not arglist.getLastArg(arglist.parser.nostartfilesOption)): not arglist.getLastArg(arglist.parser.nostartfilesOption)):
@ -420,7 +434,7 @@ class Darwin_X86_LinkTool(Tool):
if arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption): if arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption):
cmd_args.append('-ldylib1.o') cmd_args.append('-ldylib1.o')
else: else:
if self.macosxVersionCmp('<', '10.5', arglist): if macosxVersion < (10,5):
cmd_args.append('-ldylib1.o') cmd_args.append('-ldylib1.o')
else: else:
cmd_args.append('-ldylib1.10.5.o') cmd_args.append('-ldylib1.10.5.o')
@ -457,7 +471,7 @@ class Darwin_X86_LinkTool(Tool):
if arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption): if arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption):
cmd_args.append('-lcrt1.o') cmd_args.append('-lcrt1.o')
else: else:
if self.macosxVersionCmp('<', '10.5', arglist): if macosxVersion < (10,5):
cmd_args.append('-lcrt1.o') cmd_args.append('-lcrt1.o')
else: else:
cmd_args.append('-lcrt1.10.5.o') cmd_args.append('-lcrt1.10.5.o')
@ -467,7 +481,7 @@ class Darwin_X86_LinkTool(Tool):
if arglist.getLastArg(arglist.parser.sharedLibgccOption): if arglist.getLastArg(arglist.parser.sharedLibgccOption):
if not arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption): if not arglist.getLastArg(arglist.parser.m_iphoneosVersionMinOption):
if self.macosxVersionCmp('<', '10.5', arglist): if macosxVersion < (10,5):
# FIXME: gcc does a library search for this # FIXME: gcc does a library search for this
# file, this will be be broken currently. # file, this will be be broken currently.
cmd_args.append('crt3.o') cmd_args.append('crt3.o')
@ -518,16 +532,15 @@ class Darwin_X86_LinkTool(Tool):
elif (arglist.getLastArg(arglist.parser.sharedLibgccOption) or elif (arglist.getLastArg(arglist.parser.sharedLibgccOption) or
arglist.getLastArg(arglist.parser.f_exceptionsOption) or arglist.getLastArg(arglist.parser.f_exceptionsOption) or
arglist.getLastArg(arglist.parser.f_gnuRuntimeOption)): arglist.getLastArg(arglist.parser.f_gnuRuntimeOption)):
if self.macosxVersionCmp('<', '10.5', arglist): if macosxVersion < (10,5):
cmd_args.append('-lgcc_s.10.4') cmd_args.append('-lgcc_s.10.4')
else: else:
cmd_args.append('-lgcc_s.10.5') cmd_args.append('-lgcc_s.10.5')
cmd_args.append('-lgcc') cmd_args.append('-lgcc')
else: else:
if (self.macosxVersionCmp('<', '10.5', arglist) and if macosxVersion < (10,5) and macosxVersion >= (10,3,9):
self.macosxVersionCmp('>=', '10.3.9', arglist)):
cmd_args.append('-lgcc_s.10.4') cmd_args.append('-lgcc_s.10.4')
else: if macosxVersion >= (10,5):
cmd_args.append('-lgcc_s.10.5') cmd_args.append('-lgcc_s.10.5')
cmd_args.append('-lgcc') cmd_args.append('-lgcc')
@ -551,11 +564,6 @@ class Darwin_X86_LinkTool(Tool):
# compiling, I think). Find out why this is the condition, and # compiling, I think). Find out why this is the condition, and
# implement. See link_command spec for more details. # implement. See link_command spec for more details.
def macosxVersionCmp(self, cmp, version, arglist):
import sys
print >>sys.stderr, 'FIXME: macosxVersionCmp unimplemented.'
return False
class LipoTool(Tool): class LipoTool(Tool):
def __init__(self): def __init__(self):
super(LipoTool, self).__init__('lipo') super(LipoTool, self).__init__('lipo')