Skip to content

Commit c7579bf

Browse files
committed
[ELF] -o -: suppress output if disableOutput
So that LLD_IN_TEST=2 ld.lld -o - a.o only writes the output once.
1 parent 4f48048 commit c7579bf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lld/ELF/Writer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,11 @@ template <class ELFT> void Writer<ELFT>::run() {
381381
if (errCount(ctx))
382382
return;
383383

384-
if (auto e = buffer->commit())
385-
Err(ctx) << "failed to write output '" << buffer->getPath()
386-
<< "': " << std::move(e);
384+
if (!ctx.e.disableOutput) {
385+
if (auto e = buffer->commit())
386+
Err(ctx) << "failed to write output '" << buffer->getPath()
387+
<< "': " << std::move(e);
388+
}
387389

388390
if (!ctx.arg.cmseOutputLib.empty())
389391
writeARMCmseImportLib<ELFT>(ctx);

lld/test/ELF/stdout.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# REQUIRES: x86
22

33
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
4-
# RUN: ld.lld %t.o -o - > %t1
4+
## Test that we only write to "-" once.
5+
# RUN: LLD_IN_TEST=2 ld.lld %t.o -o - > %t1
56
# RUN: llvm-objdump -d %t1 | FileCheck %s
67

78
# CHECK: nop

0 commit comments

Comments
 (0)