forked from OSchip/llvm-project
Implement Darwin/ARM behavior for defaulting to -fno-builtin-str{cat,cpy}.
llvm-svn: 81425
This commit is contained in:
parent
243ac566e2
commit
2ffe029a61
|
@ -370,6 +370,8 @@ OPTION("-fast", fast, Flag, f_Group, INVALID, "", 0, 0, 0)
|
|||
OPTION("-fasynchronous-unwind-tables", fasynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fblocks", fblocks, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fbootclasspath=", fbootclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fbuiltin-strcat", fbuiltin_strcat, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fbuiltin-strcpy", fbuiltin_strcpy, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fbuiltin", fbuiltin, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fclasspath=", fclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fcolor-diagnostics", fcolor_diagnostics, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
|
@ -410,6 +412,8 @@ OPTION("-fnested-functions", fnested_functions, Flag, f_Group, INVALID, "", 0, 0
|
|||
OPTION("-fnext-runtime", fnext_runtime, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-asynchronous-unwind-tables", fno_asynchronous_unwind_tables, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-blocks", fno_blocks, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-builtin-strcat", fno_builtin_strcat, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-builtin-strcpy", fno_builtin_strcpy, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-builtin", fno_builtin, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-caret-diagnostics", fno_caret_diagnostics, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
OPTION("-fno-color-diagnostics", fno_color_diagnostics, Flag, f_Group, INVALID, "", 0, 0, 0)
|
||||
|
|
|
@ -662,6 +662,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
||||
}
|
||||
|
||||
// Default to -fno-builtin-str{cat,cpy} on Darwin for ARM.
|
||||
if (getToolChain().getTriple().getOS() == llvm::Triple::Darwin &&
|
||||
(getToolChain().getTriple().getArch() == llvm::Triple::arm ||
|
||||
getToolChain().getTriple().getArch() == llvm::Triple::thumb)) {
|
||||
if (!Args.hasArg(options::OPT_fbuiltin_strcat))
|
||||
CmdArgs.push_back("-fno-builtin-strcat");
|
||||
if (!Args.hasArg(options::OPT_fbuiltin_strcpy))
|
||||
CmdArgs.push_back("-fno-builtin-strcpy");
|
||||
}
|
||||
|
||||
if (Arg *A = Args.getLastArg(options::OPT_traditional,
|
||||
options::OPT_traditional_cpp))
|
||||
D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
|
||||
|
@ -919,6 +929,14 @@ void darwin::CC1::AddCC1Args(const ArgList &Args,
|
|||
!Args.hasArg(options::OPT_mdynamic_no_pic))
|
||||
CmdArgs.push_back("-fPIC");
|
||||
|
||||
if (getToolChain().getTriple().getArch() == llvm::Triple::arm ||
|
||||
getToolChain().getTriple().getArch() == llvm::Triple::thumb) {
|
||||
if (!Args.hasArg(options::OPT_fbuiltin_strcat))
|
||||
CmdArgs.push_back("-fno-builtin-strcat");
|
||||
if (!Args.hasArg(options::OPT_fbuiltin_strcpy))
|
||||
CmdArgs.push_back("-fno-builtin-strcpy");
|
||||
}
|
||||
|
||||
// gcc has some code here to deal with when no -mmacosx-version-min
|
||||
// and no -miphoneos-version-min is present, but this never happens
|
||||
// due to tool chain specific argument translation.
|
||||
|
@ -991,6 +1009,27 @@ void darwin::CC1::AddCC1OptionsArgs(const ArgList &Args, ArgStringList &CmdArgs,
|
|||
Args.AddLastArg(CmdArgs, options::OPT_p);
|
||||
|
||||
// The driver treats -fsyntax-only specially.
|
||||
if (getToolChain().getTriple().getArch() == llvm::Triple::arm ||
|
||||
getToolChain().getTriple().getArch() == llvm::Triple::thumb) {
|
||||
// Removes -fbuiltin-str{cat,cpy}; these aren't recognized by cc1 but are
|
||||
// used to inhibit the default -fno-builtin-str{cat,cpy}.
|
||||
//
|
||||
// FIXME: Should we grow a better way to deal with "removing" args?
|
||||
//
|
||||
// FIXME: Use iterator.
|
||||
for (ArgList::const_iterator it = Args.begin(),
|
||||
ie = Args.end(); it != ie; ++it) {
|
||||
const Arg *A = *it;
|
||||
if (A->getOption().matches(options::OPT_f_Group) ||
|
||||
A->getOption().matches(options::OPT_fsyntax_only)) {
|
||||
if (!A->getOption().matches(options::OPT_fbuiltin_strcat) &&
|
||||
!A->getOption().matches(options::OPT_fbuiltin_strcpy)) {
|
||||
A->claim();
|
||||
A->render(Args, CmdArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only);
|
||||
|
||||
Args.AddAllArgs(CmdArgs, options::OPT_undef);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s 2> %t &&
|
||||
// RUN: grep -- "-fno-builtin-strcat" %t &&
|
||||
// RUN: grep -- "-fno-builtin-strcpy" %t &&
|
||||
|
||||
// RUN: clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t &&
|
||||
// RUN: not grep -- "-fno-builtin-strcat" %t &&
|
||||
// RUN: not grep -- "-fno-builtin-strcpy" %t &&
|
||||
|
||||
// RUN: clang -ccc-no-clang -ccc-host-triple x86_64-apple-darwin9 -arch arm -### -fsyntax-only %s -fbuiltin-strcat -fbuiltin-strcpy 2> %t &&
|
||||
// RUN: not grep -- "-fno-builtin-strcat" %t &&
|
||||
// RUN: not grep -- "-fno-builtin-strcpy" %t
|
||||
|
Loading…
Reference in New Issue