[MC, COFF] Support link /incremental conditionally
[oota-llvm.git] / lib / MC / WinCOFFObjectWriter.cpp
index ffb636a593284f1403bb5f7f3299f5a7a569e4f9..a3820906b76b1104b10b57f6d3429931f3e0bdbd 100644 (file)
@@ -621,7 +621,8 @@ bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
   // thunk to implement their /INCREMENTAL feature.  Make sure we don't optimize
   // away any relocations to functions.
   uint16_t Type = cast<MCSymbolCOFF>(SymA).getType();
-  if ((Type >> COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION)
+  if (Asm.isIncrementalLinkerCompatible() &&
+      (Type >> COFF::SCT_COMPLEX_TYPE_SHIFT) == COFF::IMAGE_SYM_DTYPE_FUNCTION)
     return false;
   return MCObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
                                                                 InSet, IsPCRel);
@@ -968,13 +969,19 @@ void WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
 
   Header.PointerToSymbolTable = offset;
 
+  // FIXME: Remove the #else branch and make the #if branch unconditional once
+  // LLVM's self host configuration is aware of /Brepro.
 #if (ENABLE_TIMESTAMPS == 1)
   // MS LINK expects to be able to use this timestamp to implement their
   // /INCREMENTAL feature.
-  std::time_t Now = time(nullptr);
-  if (Now < 0 || !isUInt<32>(Now))
-    Now = UINT32_MAX;
-  Header.TimeDateStamp = Now;
+  if (Asm.isIncrementalLinkerCompatible()) {
+    std::time_t Now = time(nullptr);
+    if (Now < 0 || !isUInt<32>(Now))
+      Now = UINT32_MAX;
+    Header.TimeDateStamp = Now;
+  } else {
+    Header.TimeDateStamp = 0;
+  }
 #else
   // We want a deterministic output. It looks like GNU as also writes 0 in here.
   Header.TimeDateStamp = 0;