1 | //===- AllDrivers.cpp -------------------------------------------*- C++ -*-===// |
---|---|
2 | // |
3 | // This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // This test shows a typical case where all LLD drivers are linked into the |
9 | // application binary. This is very similar to how lld.exe binary is linked, |
10 | // except that here we cleanup the internal LLD memory context after each call. |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | #include "lld/Common/Driver.h" |
14 | #include "gmock/gmock.h" |
15 | |
16 | LLD_HAS_DRIVER(coff) |
17 | LLD_HAS_DRIVER(elf) |
18 | LLD_HAS_DRIVER(mingw) |
19 | LLD_HAS_DRIVER(macho) |
20 | LLD_HAS_DRIVER(wasm) |
21 | |
22 | static bool lldInvoke(std::vector<const char *> args) { |
23 | args.push_back(x: "--version"); |
24 | lld::Result r = |
25 | lld::lldMain(args, stdoutOS&: llvm::outs(), stderrOS&: llvm::errs(), LLD_ALL_DRIVERS); |
26 | return !r.retCode && r.canRunAgain; |
27 | } |
28 | |
29 | TEST(AsLib, AllDrivers) { |
30 | EXPECT_TRUE(lldInvoke({"ld.lld"})); |
31 | EXPECT_TRUE(lldInvoke({"ld64.lld"})); |
32 | EXPECT_TRUE(lldInvoke({"ld", "-m", "i386pe"})); // MinGW |
33 | EXPECT_TRUE(lldInvoke({"lld-link"})); |
34 | EXPECT_TRUE(lldInvoke({"wasm-ld"})); |
35 | } |
36 |