[PATCH, RFC] Fix PR16454

Bill Schmidt wschmidt at linux.vnet.ibm.com
Wed Jun 26 13:58:01 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16454 demonstrates that altivec.h
is being included along paths where it doesn't make much sense to do so.
This file is auto-included when compiling with -faltivec.  What I'm
proposing is to avoid copying the -faltivec flag when the action being
taken is to invoke the assembler or the preprocessor.

I've verified that this fixes the test case in question without
introducing any unit-test or test-suite regressions.  I also verified
that preprocessing a file requiring altivec extensions (like "vector
float x;") with the revised Clang and then compiling the resulting
preprocessed file still works correctly.

However, I really don't know anything about how all the driver machinery
works, so I'd appreciate some extra eyes on this before I commit.  I'm
CC'ing a few folks that were suggested.

For what it's worth, the test case in question is fixed by the
isa<PreprocessJobAction> test.  The other test is there just because it
makes sense to me.

I will add the original test from the PR as a unit test if this approach
passes muster.

Thanks,
Bill


Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 184947)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -2844,7 +2844,10 @@ void Clang::ConstructJob(Compilation &C, const Job
   Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info);
   Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
-  Args.AddLastArg(CmdArgs, options::OPT_faltivec);
+  // -faltivec causes inclusion of altivec.h, which makes no sense for
+  // an assembly or preprocess action.
+  if (!isa<AssembleJobAction>(JA) && !isa<PreprocessJobAction>(JA))
+    Args.AddLastArg(CmdArgs, options::OPT_faltivec);
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 





More information about the cfe-commits mailing list