[patch, darwin-legacy] suppressing OS version asm directive

David Fang fang at csl.cornell.edu
Thu Mar 27 16:56:27 PDT 2014


Hi Jim,
 	A few weeks ago, you alerted us darwin-legacy users that r204190 
and r204191 added a new asm directive that would break compatibility with 
older cctools.  My regression testing found that 
test/CodeGen/PowerPC/hello-reloc.ll had failed due to different 
macho-dump, for instance. I took a stab at the attached patch to suppress 
this new directive (guessing that OS X 10.9 is the cut-off).  The patch 
restores my regression tests to their previous state.  Does this seem like 
an adequate workaround for legacy support?

David

-- 
David Fang
http://www.csl.cornell.edu/~fang/
-------------- next part --------------
commit 191f81b17dcdb33f29e61f2a67fb85706bc020db
Author: David Fang <fang at csl.cornell.edu>
Date:   Wed Mar 26 22:51:36 2014 -0700

    only emit target version asm directive for sufficiently new darwin

diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 086b081..86a1b8b 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <tuple>		// for std::tie
 #define DEBUG_TYPE "asm-printer"
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "DwarfDebug.h"
@@ -188,10 +189,12 @@ bool AsmPrinter::doInitialization(Module &M) {
   // anyway.
   Triple TT(getTargetTriple());
   if (TT.isOSDarwin()) {
+    static const unsigned MinMajor = 10, MinMinor = 9, MinUpdate = 0;
     unsigned Major, Minor, Update;
     TT.getOSVersion(Major, Minor, Update);
     // If there is a version specified, Major will be non-zero.
-    if (Major)
+    // Suppress this target directive for older toolchains (pre-darwin13).
+    if (Major && (std::tie(Major, Minor, Update) >= std::tie(MinMajor, MinMinor, MinUpdate)))
       OutStreamer.EmitVersionMin((TT.isMacOSX() ?
                                   MCVM_OSXVersionMin : MCVM_IOSVersionMin),
                                  Major, Minor, Update);


More information about the llvm-commits mailing list