diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index d96294e06d57..87cd29543803 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -520,11 +520,13 @@ bool AsmPrinter::doInitialization(Module &M) {
   // use the directive, where it would need the same conditionalization
   // anyway.
   if (Target.isOSBinFormatMachO() && Target.isOSDarwin()) {
-    Triple TVT(M.getDarwinTargetVariantTriple());
-    OutStreamer->emitVersionForTarget(
+    if (MAI->useIntegratedAssembler()) {
+      Triple TVT(M.getDarwinTargetVariantTriple());
+      OutStreamer->emitVersionForTarget(
         Target, M.getSDKVersion(),
         M.getDarwinTargetVariantTriple().empty() ? nullptr : &TVT,
         M.getDarwinTargetVariantSDKVersion());
+    }
   }
 
   // Allow the target to emit any magic that it wants at the start of the file.
