Skip to content

Commit

Permalink
Revert "[LLD] Allow usage of LLD as a library"
Browse files Browse the repository at this point in the history
This reverts commit 2700da5.

Reverting since this causes some test failures on our builders: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8778372807208184913/overview
  • Loading branch information
PiJoules committed Jun 14, 2023
1 parent 8193b29 commit aa49521
Show file tree
Hide file tree
Showing 24 changed files with 209 additions and 560 deletions.
2 changes: 0 additions & 2 deletions lld/CMakeLists.txt
Expand Up @@ -191,8 +191,6 @@ add_subdirectory(Common)
add_subdirectory(tools/lld)

if (LLVM_INCLUDE_TESTS)
add_custom_target(LLDUnitTests)
llvm_add_unittests(LLD_UNITTESTS_ADDED)
add_subdirectory(test)
endif()

Expand Down
2 changes: 1 addition & 1 deletion lld/COFF/Driver.cpp
Expand Up @@ -64,7 +64,7 @@ namespace lld::coff {

bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
// This driver-specific context will be freed later by unsafeLldMain().
// This driver-specific context will be freed later by lldMain().
auto *ctx = new COFFLinkerContext;

ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
Expand Down
1 change: 0 additions & 1 deletion lld/Common/CMakeLists.txt
Expand Up @@ -23,7 +23,6 @@ set_source_files_properties("${version_inc}"
add_lld_library(lldCommon
Args.cpp
CommonLinkerContext.cpp
DriverDispatcher.cpp
DWARF.cpp
ErrorHandler.cpp
Filesystem.cpp
Expand Down
203 changes: 0 additions & 203 deletions lld/Common/DriverDispatcher.cpp

This file was deleted.

11 changes: 4 additions & 7 deletions lld/ELF/Driver.cpp
Expand Up @@ -107,11 +107,10 @@ void Ctx::reset() {
needsTlsLd.store(false, std::memory_order_relaxed);
}

namespace lld {
namespace elf {
bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
// This driver-specific context will be freed later by unsafeLldMain().
bool elf::link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly,
bool disableOutput) {
// This driver-specific context will be freed later by lldMain().
auto *ctx = new CommonLinkerContext;

ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
Expand Down Expand Up @@ -148,8 +147,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,

return errorCount() == 0;
}
} // namespace elf
} // namespace lld

// Parses a linker -m option.
static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef emul) {
Expand Down
9 changes: 3 additions & 6 deletions lld/MachO/Driver.cpp
Expand Up @@ -1367,10 +1367,9 @@ static void handleExplicitExports() {
}
}

namespace lld {
namespace macho {
bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly,
bool disableOutput) {
// This driver-specific context will be freed later by lldMain().
auto *ctx = new CommonLinkerContext;

Expand Down Expand Up @@ -1969,5 +1968,3 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,

return errorCount() == 0;
}
} // namespace macho
} // namespace lld
14 changes: 3 additions & 11 deletions lld/MinGW/Driver.cpp
Expand Up @@ -157,17 +157,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
return "";
}

namespace lld {
namespace coff {
bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
}

namespace mingw {
// Convert Unix-ish command line arguments to Windows-ish ones and
// then call coff::link.
bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
llvm::raw_ostream &stderrOS, bool exitEarly,
bool disableOutput) {
auto *ctx = new CommonLinkerContext;
ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);

Expand Down Expand Up @@ -488,5 +482,3 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,

return coff::link(vec, stdoutOS, stderrOS, exitEarly, disableOutput);
}
} // namespace mingw
} // namespace lld
2 changes: 1 addition & 1 deletion lld/docs/NewLLD.rst
Expand Up @@ -5,7 +5,7 @@ The ELF Linker as a Library
---------------------------

You can embed LLD to your program by linking against it and calling the linker's
entry point function `lld::lldMain`.
entry point function lld::elf::link.

The current policy is that it is your responsibility to give trustworthy object
files. The function is guaranteed to return as long as you do not pass corrupted
Expand Down
2 changes: 1 addition & 1 deletion lld/docs/index.rst
Expand Up @@ -36,7 +36,7 @@ Features
external linkers. All you have to do is to construct object files
and command line arguments just like you would do to invoke an
external linker and then call the linker's main function,
``lld::lldMain``, from your code.
``lld::elf::link``, from your code.

- It is small. We are using LLVM libObject library to read from object
files, so it is not a completely fair comparison, but as of February
Expand Down

0 comments on commit aa49521

Please sign in to comment.