Skip to content

Commit aa49521

Browse files
committed
Revert "[LLD] Allow usage of LLD as a library"
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
1 parent 8193b29 commit aa49521

File tree

24 files changed

+209
-560
lines changed

24 files changed

+209
-560
lines changed

lld/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,6 @@ add_subdirectory(Common)
191191
add_subdirectory(tools/lld)
192192

193193
if (LLVM_INCLUDE_TESTS)
194-
add_custom_target(LLDUnitTests)
195-
llvm_add_unittests(LLD_UNITTESTS_ADDED)
196194
add_subdirectory(test)
197195
endif()
198196

lld/COFF/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace lld::coff {
6464

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

7070
ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);

lld/Common/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ set_source_files_properties("${version_inc}"
2323
add_lld_library(lldCommon
2424
Args.cpp
2525
CommonLinkerContext.cpp
26-
DriverDispatcher.cpp
2726
DWARF.cpp
2827
ErrorHandler.cpp
2928
Filesystem.cpp

lld/Common/DriverDispatcher.cpp

Lines changed: 0 additions & 203 deletions
This file was deleted.

lld/ELF/Driver.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ void Ctx::reset() {
107107
needsTlsLd.store(false, std::memory_order_relaxed);
108108
}
109109

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

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

149148
return errorCount() == 0;
150149
}
151-
} // namespace elf
152-
} // namespace lld
153150

154151
// Parses a linker -m option.
155152
static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef emul) {

lld/MachO/Driver.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,10 +1367,9 @@ static void handleExplicitExports() {
13671367
}
13681368
}
13691369

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

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

19701969
return errorCount() == 0;
19711970
}
1972-
} // namespace macho
1973-
} // namespace lld

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,11 @@ searchLibrary(StringRef name, ArrayRef<StringRef> searchPaths, bool bStatic) {
157157
return "";
158158
}
159159

160-
namespace lld {
161-
namespace coff {
162-
bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
163-
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput);
164-
}
165-
166-
namespace mingw {
167160
// Convert Unix-ish command line arguments to Windows-ish ones and
168161
// then call coff::link.
169-
bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
170-
llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) {
162+
bool mingw::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
163+
llvm::raw_ostream &stderrOS, bool exitEarly,
164+
bool disableOutput) {
171165
auto *ctx = new CommonLinkerContext;
172166
ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput);
173167

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

489483
return coff::link(vec, stdoutOS, stderrOS, exitEarly, disableOutput);
490484
}
491-
} // namespace mingw
492-
} // namespace lld

lld/docs/NewLLD.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ The ELF Linker as a Library
55
---------------------------
66

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

1010
The current policy is that it is your responsibility to give trustworthy object
1111
files. The function is guaranteed to return as long as you do not pass corrupted

lld/docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Features
3636
external linkers. All you have to do is to construct object files
3737
and command line arguments just like you would do to invoke an
3838
external linker and then call the linker's main function,
39-
``lld::lldMain``, from your code.
39+
``lld::elf::link``, from your code.
4040

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

0 commit comments

Comments
 (0)