[lld] c7579bf - [ELF] -o -: suppress output if disableOutput
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 25 15:50:41 PST 2025
Author: Fangrui Song
Date: 2025-01-25T15:50:29-08:00
New Revision: c7579bfba5969377f7fb4239cc05d6cd4a077957
URL: https://github.com/llvm/llvm-project/commit/c7579bfba5969377f7fb4239cc05d6cd4a077957
DIFF: https://github.com/llvm/llvm-project/commit/c7579bfba5969377f7fb4239cc05d6cd4a077957.diff
LOG: [ELF] -o -: suppress output if disableOutput
So that LLD_IN_TEST=2 ld.lld -o - a.o only writes the output once.
Added:
Modified:
lld/ELF/Writer.cpp
lld/test/ELF/stdout.s
Removed:
################################################################################
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index fe4a0a15ae835d..b7c4790655e8a0 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -381,9 +381,11 @@ template <class ELFT> void Writer<ELFT>::run() {
if (errCount(ctx))
return;
- if (auto e = buffer->commit())
- Err(ctx) << "failed to write output '" << buffer->getPath()
- << "': " << std::move(e);
+ if (!ctx.e.disableOutput) {
+ if (auto e = buffer->commit())
+ Err(ctx) << "failed to write output '" << buffer->getPath()
+ << "': " << std::move(e);
+ }
if (!ctx.arg.cmseOutputLib.empty())
writeARMCmseImportLib<ELFT>(ctx);
diff --git a/lld/test/ELF/stdout.s b/lld/test/ELF/stdout.s
index 64cf64a72b4b62..b5ec07cfabfe92 100644
--- a/lld/test/ELF/stdout.s
+++ b/lld/test/ELF/stdout.s
@@ -1,7 +1,8 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
-# RUN: ld.lld %t.o -o - > %t1
+## Test that we only write to "-" once.
+# RUN: LLD_IN_TEST=2 ld.lld %t.o -o - > %t1
# RUN: llvm-objdump -d %t1 | FileCheck %s
# CHECK: nop
More information about the llvm-commits
mailing list