[cfe-commits] r81425 - in /cfe/trunk: include/clang/Driver/Options.def lib/Driver/Tools.cpp test/Driver/arm-darwin-builtin.c
Daniel Dunbar
daniel at zuster.org
Wed Sep 9 20:37:05 PDT 2009
Author: ddunbar
Date: Wed Sep 9 22:37:02 2009
New Revision: 81425
URL: http://llvm.org/viewvc/llvm-project?rev=81425&view=rev
Log:
Implement Darwin/ARM behavior for defaulting to -fno-builtin-str{cat,cpy}.
Added:
cfe/trunk/test/Driver/arm-darwin-builtin.c
Modified:
cfe/trunk/include/clang/Driver/Options.def
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/include/clang/Driver/Options.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.def?rev=81425&r1=81424&r2=81425&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.def (original)
+++ cfe/trunk/include/clang/Driver/Options.def Wed Sep 9 22:37:02 2009
@@ -370,6 +370,8 @@
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("-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)
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=81425&r1=81424&r2=81425&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Sep 9 22:37:02 2009
@@ -662,6 +662,16 @@
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 @@
!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,7 +1009,28 @@
Args.AddLastArg(CmdArgs, options::OPT_p);
// The driver treats -fsyntax-only specially.
- Args.AddAllArgs(CmdArgs, options::OPT_f_Group, options::OPT_fsyntax_only);
+ 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);
if (Args.hasArg(options::OPT_Qn))
Added: cfe/trunk/test/Driver/arm-darwin-builtin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-darwin-builtin.c?rev=81425&view=auto
==============================================================================
--- cfe/trunk/test/Driver/arm-darwin-builtin.c (added)
+++ cfe/trunk/test/Driver/arm-darwin-builtin.c Wed Sep 9 22:37:02 2009
@@ -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
+
More information about the cfe-commits
mailing list