зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
f8ebb4154e
Коммит
c4556d1151
|
@ -47,7 +47,7 @@ class DarwinHostInfo(HostInfo):
|
||||||
self.darwinVersion,
|
self.darwinVersion,
|
||||||
self.gccVersion)
|
self.gccVersion)
|
||||||
|
|
||||||
return ToolChain.Generic_GCC_ToolChain(self.driver, arch)
|
return ToolChain.Darwin_GCC_ToolChain(self.driver, arch)
|
||||||
|
|
||||||
class DarwinPPCHostInfo(DarwinHostInfo):
|
class DarwinPPCHostInfo(DarwinHostInfo):
|
||||||
def getArchName(self, args):
|
def getArchName(self, args):
|
||||||
|
|
|
@ -86,6 +86,11 @@ class ToolChain(object):
|
||||||
def isMathErrnoDefault(self):
|
def isMathErrnoDefault(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def getRelocationModel(self, picEnabled, picDisabled):
|
||||||
|
if picEnabled:
|
||||||
|
return 'pic'
|
||||||
|
return 'static'
|
||||||
|
|
||||||
class Darwin_X86_ToolChain(ToolChain):
|
class Darwin_X86_ToolChain(ToolChain):
|
||||||
def __init__(self, driver, archName, darwinVersion, gccVersion):
|
def __init__(self, driver, archName, darwinVersion, gccVersion):
|
||||||
super(Darwin_X86_ToolChain, self).__init__(driver, archName)
|
super(Darwin_X86_ToolChain, self).__init__(driver, archName)
|
||||||
|
@ -224,6 +229,17 @@ class Darwin_X86_ToolChain(ToolChain):
|
||||||
def isMathErrnoDefault(self):
|
def isMathErrnoDefault(self):
|
||||||
return False
|
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):
|
class Generic_GCC_ToolChain(ToolChain):
|
||||||
"""Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
|
"""Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
|
||||||
perform all subcommands; this relies on gcc translating the
|
perform all subcommands; this relies on gcc translating the
|
||||||
|
@ -251,3 +267,13 @@ class Generic_GCC_ToolChain(ToolChain):
|
||||||
return self.clangTool
|
return self.clangTool
|
||||||
|
|
||||||
return self.toolMap[action.phase.__class__]
|
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
|
picEnabled = (arglist.getLastArg(arglist.parser.f_PICOption) or
|
||||||
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
|
||||||
arglist.getLastArg(arglist.parser.f_pieOption) or
|
arglist.getLastArg(arglist.parser.f_pieOption))
|
||||||
(not arglist.getLastArg(arglist.parser.m_kernelOption) and
|
picDisabled = (arglist.getLastArg(arglist.parser.m_kernelOption) or
|
||||||
not arglist.getLastArg(arglist.parser.staticOption) and
|
arglist.getLastArg(arglist.parser.staticOption))
|
||||||
not arglist.getLastArg(arglist.parser.m_dynamicNoPicOption)))
|
model = self.toolChain.getRelocationModel(picEnabled, picDisabled)
|
||||||
|
cmd_args.append('--relocation-model=%s' % model)
|
||||||
# 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')
|
|
||||||
|
|
||||||
if arglist.getLastArg(arglist.parser.f_timeReportOption):
|
if arglist.getLastArg(arglist.parser.f_timeReportOption):
|
||||||
cmd_args.append('--time-passes')
|
cmd_args.append('--time-passes')
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// RUN: xcc -ccc-print-phases -### -arch ppc -arch ppc %s | grep linker- | count 1 &&
|
// RUN: xcc -ccc-print-phases -### -arch ppc -arch ppc %s | grep linker- | count 1 &&
|
||||||
|
|
||||||
// Check that -ccc-clang-archs is honored.
|
// 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() {
|
int main() {
|
||||||
printf("Hello, World!\n");
|
printf("Hello, World!\n");
|
||||||
|
|
Загрузка…
Ссылка в новой задаче