Use ErrorOS for log messages as well as error

log are also diagnostics so it seems like they should to
the same place as errors and debug messages.

Without this change when I enable --verbose those messages
go to stdout, but when I enable "-mllvm -debug" those messages
go to stderr (because dbgs() goes to stderr by default).

So I end up having to do this a lot:
 lld <args> > output_message 2>&1

Differential Revision: https://reviews.llvm.org/D41033

llvm-svn: 320427
This commit is contained in:
Sam Clegg 2017-12-11 21:57:31 +00:00
parent 3f1fb88afb
commit 77c1def71a
20 changed files with 25 additions and 26 deletions

View File

@ -73,8 +73,7 @@ void ErrorHandler::print(StringRef S, raw_ostream::Colors C) {
void ErrorHandler::log(const Twine &Msg) {
if (Verbose) {
std::lock_guard<std::mutex> Lock(Mu);
outs() << LogName << ": " << Msg << "\n";
outs().flush();
*ErrorOS << LogName << ": " << Msg << "\n";
}
}

View File

@ -5,14 +5,14 @@
# RUN: env LIB=%t/a lld-link /out:%t.exe /entry:main /verbose \
# RUN: std64.lib /subsystem:console %p/Inputs/hello64.obj \
# RUN: /libpath:%t/b /libpath:%t/c > %t.log
# RUN: /libpath:%t/b /libpath:%t/c 2> %t.log
# RUN: FileCheck -check-prefix=CHECK1 %s < %t.log
CHECK1: b{{[/\\]}}std64.lib
# RUN: lld-link /out:%t.exe /entry:main /verbose \
# RUN: std64.lib /subsystem:console %p/Inputs/hello64.obj \
# RUN: /libpath:%t/a /libpath:%t/b /libpath:%t/c > %t.log
# RUN: /libpath:%t/a /libpath:%t/b /libpath:%t/c 2> %t.log
# RUN: FileCheck -check-prefix=CHECK2 %s < %t.log
CHECK2: a{{[/\\]}}std64.lib

View File

@ -9,14 +9,14 @@
; RUN: mkdir -p %t.dir
; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s
; RUN: lld-link %t-main1.a %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
; RUN: /entry:main /verbose > %t.log || true
; RUN: /entry:main /verbose 2> %t.log || true
; RUN: FileCheck -check-prefix=BC %s < %t.log
; BC-NOT: Creating a temporary archive for
; RUN: rm -f %t-main2.a
; RUN: llvm-ar cru %t-main2.a %t.dir/bitcode.obj
; RUN: lld-link %t.obj %t-main2.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
; RUN: /entry:main /verbose > %t.log || true
; RUN: /entry:main /verbose 2> %t.log || true
; RUN: FileCheck -check-prefix=OBJ %s < %t.log
; OBJ-NOT: Creating a temporary archive
@ -25,7 +25,7 @@
; RUN: rm -f %t-main3.a
; RUN: llvm-ar cruT %t-main3.a %t.dir/bitcode.obj
; RUN: lld-link %t.obj %t-main3.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
; RUN: /entry:main /verbose > %t.log || true
; RUN: /entry:main /verbose 2> %t.log || true
; RUN: FileCheck -check-prefix=THIN %s < %t.log
; THIN: Creating a temporary archive

View File

@ -5,7 +5,7 @@
; RUN: llc -filetype=obj %S/Inputs/msvclto-order-b.ll -o %T/msvclto-order-b.obj
; RUN: llvm-ar crs %T/msvclto-order-b.lib %T/msvclto-order-b.obj
; RUN: lld-link /verbose /msvclto /out:%t.exe /entry:main %t.obj \
; RUN: %T/msvclto-order-a.lib %T/msvclto-order-b.lib > %t.log || true
; RUN: %T/msvclto-order-a.lib %T/msvclto-order-b.lib 2> %t.log || true
; RUN: FileCheck %s < %t.log
; CHECK: : link.exe

View File

@ -3,7 +3,7 @@
; RUN: mkdir -p %t.dir
; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s
; RUN: lld-link %t.obj %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \
; RUN: /entry:main /verbose > %t.log || true
; RUN: /entry:main /verbose 2> %t.log || true
; RUN: FileCheck %s < %t.log
; CHECK: /opt:icf /entry:main

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute.s -o %t2
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -2,7 +2,7 @@
# This test is to make sure that we can handle implicit addends properly.
# RUN: llvm-mc -filetype=obj -triple=i386-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge-sec.s -o %t2
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -2,13 +2,13 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge.s -o %t1
# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose 2>&1 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge2.s -o %t2
# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose | FileCheck --check-prefix=NOMERGE %s
# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge3.s -o %t3
# RUN: ld.lld %t %t3 -o %t3.out --icf=all --verbose | FileCheck --check-prefix=NOMERGE %s
# RUN: ld.lld %t %t3 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -8,7 +8,7 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
// RUN: %p/Inputs/icf-non-mergeable.s -o %t2
// RUN: ld.lld %t1 %t2 -o %t3 --icf=all --verbose | FileCheck %s
// RUN: ld.lld %t1 %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s
// CHECK-NOT: selected .text.f1
// CHECK-NOT: removed .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --icf=none --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --icf=none --verbose 2>&1 | FileCheck %s
# CHECK-NOT: selected .text.f1

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2
# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose 2>&1 | FileCheck %s
# CHECK: selected .text.f1
# CHECK: removed .text.f2

View File

@ -2,7 +2,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2
# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose 2>&1 | FileCheck %s
# CHECK-NOT: Selected .text.f1
# CHECK-NOT: Selected .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK-NOT: Selected .text.f1
# CHECK-NOT: Selected .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK-NOT: Selected .text.f1
# CHECK-NOT: Selected .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# CHECK-NOT: Selected .text.f1
# CHECK-NOT: Selected .text.f2

View File

@ -1,7 +1,7 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# RUN: llvm-objdump -t %t2 | FileCheck -check-prefix=ALIGN %s
# CHECK: selected .text.f1

View File

@ -2,7 +2,7 @@
### Make sure that we do not merge data.
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s
# RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=SEC %s
# SEC: .rodata PROGBITS 0000000000200120 000120 000002 00 A 0 0 1