ccc: Use toolchain hook for default relocation model value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65116 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-02-20 06:48:26 +00:00
Родитель f8ebb4154e
Коммит c4556d1151
4 изменённых файлов: 33 добавлений и 13 удалений

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

@ -47,7 +47,7 @@ class DarwinHostInfo(HostInfo):
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):

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

@ -86,6 +86,11 @@ class ToolChain(object):
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 @@ class Darwin_X86_ToolChain(ToolChain):
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 @@ class Generic_GCC_ToolChain(ToolChain):
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'

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

@ -252,17 +252,11 @@ class Clang_CompileTool(Tool):
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')

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

@ -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");