[all-commits] [llvm/llvm-project] b11386: Make it possible to redirect not only errs() but a...

Rui Ueyama via All-commits all-commits at lists.llvm.org
Sun Nov 17 18:20:35 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: b11386f9be9b2dc7276a758d64f66833da10bdea
      https://github.com/llvm/llvm-project/commit/b11386f9be9b2dc7276a758d64f66833da10bdea
  Author: Rui Ueyama <ruiu at google.com>
  Date:   2019-11-18 (Mon, 18 Nov 2019)

  Changed paths:
    M lld/COFF/Driver.cpp
    M lld/COFF/DriverUtils.cpp
    M lld/COFF/Writer.cpp
    M lld/Common/ErrorHandler.cpp
    M lld/ELF/Driver.cpp
    M lld/ELF/DriverUtils.cpp
    M lld/ELF/MapFile.cpp
    M lld/MinGW/Driver.cpp
    M lld/include/lld/Common/Driver.h
    M lld/include/lld/Common/ErrorHandler.h
    M lld/include/lld/Common/LLVM.h
    M lld/lib/Core/Resolver.cpp
    M lld/lib/Core/SymbolTable.cpp
    M lld/lib/Driver/DarwinLdDriver.cpp
    M lld/lib/ReaderWriter/FileArchive.cpp
    M lld/lib/ReaderWriter/MachO/LayoutPass.cpp
    M lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    M lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
    M lld/tools/lld/lld.cpp
    M lld/unittests/MachOTests/MachONormalizedFileBinaryWriterTests.cpp
    M lld/wasm/Driver.cpp

  Log Message:
  -----------
  Make it possible to redirect not only errs() but also outs()

This change is for those who use lld as a library. Context:
https://reviews.llvm.org/D70287

This patch adds a new parmeter to lld::*::link() so that we can pass
an raw_ostream object representing stdout. Previously, lld::*::link()
took only an stderr object.

Justification for making stdoutOS and stderrOS mandatory: I wanted to
make link() functions to take stdout and stderr in that order.
However, if we change the function signature from

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stderrOS = llvm::errs());

to

  bool link(ArrayRef<const char *> args, bool canExitEarly,
            raw_ostream &stdoutOS = llvm::outs(),
            raw_ostream &stderrOS = llvm::errs());

, then the meaning of existing code that passes stderrOS silently
changes (stderrOS would be interpreted as stdoutOS). So, I chose to
make existing code not to compile, so that developers can fix their
code.

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




More information about the All-commits mailing list