[llvm] r204191 - MachO: Emit a version-min load command when possible.
Jim Grosbach
grosbach at apple.com
Tue Mar 18 15:09:08 PDT 2014
Author: grosbach
Date: Tue Mar 18 17:09:08 2014
New Revision: 204191
URL: http://llvm.org/viewvc/llvm-project?rev=204191&view=rev
Log:
MachO: Emit a version-min load command when possible.
When deployment target version information is available, emit it to the
target streamer for inclusion in the object file.
rdar://11337778
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=204191&r1=204190&r2=204191&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Mar 18 17:09:08 2014
@@ -178,6 +178,25 @@ bool AsmPrinter::doInitialization(Module
Mang = new Mangler(TM.getDataLayout());
+ // Emit the version-min deplyment target directive if needed.
+ //
+ // FIXME: If we end up with a collection of these sorts of Darwin-specific
+ // or ELF-specific things, it may make sense to have a platform helper class
+ // that will work with the target helper class. For now keep it here, as the
+ // alternative is duplicated code in each of the target asm printers that
+ // use the directive, where it would need the same conditionalization
+ // anyway.
+ Triple TT(getTargetTriple());
+ if (TT.isOSDarwin()) {
+ unsigned Major, Minor, Update;
+ TT.getOSVersion(Major, Minor, Update);
+ // If there is a version specified, Major will be non-zero.
+ if (Major)
+ OutStreamer.EmitVersionMin((TT.isMacOSX() ?
+ MCVM_OSXVersionMin : MCVM_IOSVersionMin),
+ Major, Minor, Update);
+ }
+
// Allow the target to emit any magic that it wants at the start of the file.
EmitStartOfAsmFile(M);
More information about the llvm-commits
mailing list