This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Print the lld-link command to stderr if running with -verbose
ClosedPublic

Authored by mstorsjo on Jun 18 2021, 5:36 AM.

Details

Summary

When testing with -###, we print the output to stdout, as that's the
main purpose of the link command (as it exits after printing).

When linking with -verbose, we continue and then get log messages
from the actual link. Those log messages are printed to stderr. By
printing the command to the same stream, we make sure they appear
in a sensible chronological order.

Diff Detail

Event Timeline

mstorsjo requested review of this revision.Jun 18 2021, 5:36 AM
mstorsjo created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2021, 5:36 AM
rnk accepted this revision.Jun 18 2021, 9:50 AM

lgtm

This revision is now accepted and ready to land.Jun 18 2021, 9:50 AM
rnk requested changes to this revision.Jun 18 2021, 9:52 AM

Actually, maybe we should aim for consistency with clang and GCC, and they both print this stuff to stderr:

$ clang -c t.cpp -### > /dev/null
clang version 13.0.0 (git@github.com:llvm/llvm-project.git 621d93d263f82059c2826fe919a1a138b65627a3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/google/home/rnk/llvm-project/build/bin
 (in-process)
 "/usr/local/google/home/rnk/llvm-project/build/bin/clang-13" "-cc1" "-triple" "x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "t.cpp" "-mrelocation-model" "static" "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-debugger-tuning=gdb" "-fcoverage-compilation-dir=/usr/local/google/home/rnk/llvm-project/build" "-resource-dir" "/usr/local/google/home/rnk/llvm-project/build/lib/clang/13.0.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward" "-internal-isystem" "/usr/local/google/home/rnk/llvm-project/build/lib/clang/13.0.0/include" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-fdebug-compilation-dir=/usr/local/google/home/rnk/llvm-project/build" "-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fcxx-exceptions" "-fexceptions" "-fcolor-diagnostics" "-faddrsig" "-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o" "t.o" "-x" "c++" "t.cpp"

$ gcc -c t.cpp -### > /dev/null
Using built-in specs.
COLLECT_GCC=gcc
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 10.2.1-6+build2' --with-bugurl=file:///usr/share/doc/gcc-10/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-10 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-10-i0uLfW/gcc-10-10.2.1/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-10-i0uLfW/gcc-10-10.2.1/debian/tmp-gcn/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.1 20210110 (Debian 10.2.1-6+build2) 
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/10/cc1plus -quiet -imultiarch x86_64-linux-gnu -D_GNU_SOURCE t.cpp -quiet -dumpbase t.cpp "-mtune=generic" "-march=x86-64" -auxbase t -fasynchronous-unwind-tables -o /tmp/cciMprQs.s
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64'
 as --64 -o t.o /tmp/cciMprQs.s
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/10/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/10/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-mtune=generic' '-march=x86-64'
This revision now requires changes to proceed.Jun 18 2021, 9:52 AM
mstorsjo updated this revision to Diff 353078.Jun 18 2021, 12:40 PM

Unconditionally printing the command to stderr.

rnk accepted this revision.Jun 22 2021, 3:45 PM

lgtm

This revision is now accepted and ready to land.Jun 22 2021, 3:45 PM
This revision was landed with ongoing or failed builds.Jun 23 2021, 12:22 AM
This revision was automatically updated to reflect the committed changes.