Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coff] Don't try to write the obj if the assembler has errors #123007

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

dpaoliello
Copy link
Contributor

The ASAN and MSAN tests have been failing after #122777 because some fields are now set in executePostLayoutBinding which is skipped by the assembler if it had errors but read in writeObject

Since the compilation has failed anyway, skip writeObject if the assembler had errors.

@llvmbot
Copy link
Member

llvmbot commented Jan 15, 2025

@llvm/pr-subscribers-mc

Author: Daniel Paoliello (dpaoliello)

Changes

The ASAN and MSAN tests have been failing after #122777 because some fields are now set in executePostLayoutBinding which is skipped by the assembler if it had errors but read in writeObject

Since the compilation has failed anyway, skip writeObject if the assembler had errors.


Full diff: https://github.com/llvm/llvm-project/pull/123007.diff

1 Files Affected:

  • (modified) llvm/lib/MC/WinCOFFObjectWriter.cpp (+5)
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 39e02d0522bcfb..da0c0661117b28 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1193,6 +1193,11 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
 }
 
 uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm) {
+  // If the assember had an error, then layout will not have completed, so we
+  // cannot write an object file.
+  if (Asm.getContext().hadError())
+    return 0;
+
   uint64_t TotalSize = ObjWriter->writeObject(Asm);
   if (DwoWriter)
     TotalSize += DwoWriter->writeObject(Asm);

@dpaoliello dpaoliello merged commit ac2165f into llvm:main Jan 15, 2025
10 checks passed
@dpaoliello dpaoliello deleted the bail branch January 15, 2025 17:27
paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 16, 2025
…23007)

The ASAN and MSAN tests have been failing after llvm#122777 because some
fields are now set in `executePostLayoutBinding` which is skipped by the
assembler if it had errors but read in `writeObject`

Since the compilation has failed anyway, skip `writeObject` if the
assembler had errors.
DKLoehr pushed a commit to DKLoehr/llvm-project that referenced this pull request Jan 17, 2025
…23007)

The ASAN and MSAN tests have been failing after llvm#122777 because some
fields are now set in `executePostLayoutBinding` which is skipped by the
assembler if it had errors but read in `writeObject`

Since the compilation has failed anyway, skip `writeObject` if the
assembler had errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mc Machine (object) code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants