Skip to content

Commit c3356a4

Browse files
serge-sans-paillearunthomas
serge-sans-paille
authored andcommitted
Support -fuse-ld=lld for riscv
Add a configure feature test to filter out tests that explicitly depend on platform linker. Differential Revision: https://reviews.llvm.org/D74704
1 parent 7309dfe commit c3356a4

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
142142
CmdArgs.push_back("elf32lriscv");
143143
}
144144

145-
std::string Linker = getToolChain().GetProgramPath(getShortName());
145+
std::string Linker = getToolChain().GetLinkerPath();
146146

147147
bool WantCRTs =
148148
!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);

clang/test/Driver/riscv32-toolchain.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// A basic clang -cc1 command-line, and simple environment check.
2+
// REQUIRES: platform-linker
23

34
// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 2>&1 | FileCheck -check-prefix=CC1 %s
45
// CC1: clang{{.*}} "-cc1" "-triple" "riscv32"
56

7+
// Test interaction with -fuse-ld=lld, if lld is available.
8+
// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
9+
// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
10+
611
// In the below tests, --rtlib=platform is used so that the driver ignores
712
// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
813

clang/test/Driver/riscv64-toolchain.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// A basic clang -cc1 command-line, and simple environment check.
2+
// REQUIRES: platform-linker
23

34
// RUN: %clang %s -### -no-canonical-prefixes -target riscv64 2>&1 | FileCheck -check-prefix=CC1 %s
45
// CC1: clang{{.*}} "-cc1" "-triple" "riscv64"
56

7+
// Test interaction with -fuse-ld=lld, if lld is available.
8+
// RUN: %clang %s -### -no-canonical-prefixes -target riscv32 -fuse-ld=lld 2>&1 | FileCheck -check-prefix=LLD %s
9+
// LLD: {{(error: invalid linker name in argument '-fuse-ld=lld')|(ld.lld)}}
10+
611
// In the below tests, --rtlib=platform is used so that the driver ignores
712
// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
813

clang/test/lit.site.cfg.py.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,8 @@ except KeyError:
4646
import lit.llvm
4747
lit.llvm.initialize(lit_config, config)
4848

49+
if not "@CLANG_DEFAULT_LINKER@":
50+
config.available_features('platform-linker')
51+
4952
# Let the main config do the real work.
5053
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg.py")

0 commit comments

Comments
 (0)