Skip to content

Commit ce86f67

Browse files
committed
[Xtensa]: Add '-fuse-ld' option support to ESP Xtensa toolchain
1 parent 4a5f26b commit ce86f67

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

clang/lib/Driver/ToolChains/Xtensa.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ void xtensa::Linker::ConstructJob(Compilation &C, const JobAction &JA,
214214
const ArgList &Args,
215215
const char *LinkingOutput) const {
216216
ArgStringList CmdArgs;
217+
SmallString<128> Linker;
217218
bool WantCRTs =
218219
!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles);
219220
const auto &ToolChain =
@@ -222,9 +223,13 @@ void xtensa::Linker::ConstructJob(Compilation &C, const JobAction &JA,
222223
if (ToolChain.GCCToolchainName == "")
223224
llvm_unreachable("Unable to find Xtensa GCC linker");
224225

225-
SmallString<128> Linker(ToolChain.GCCToolchainDir);
226-
llvm::sys::path::append(Linker, "bin",
227-
ToolChain.GCCToolchainName + "-" + getShortName());
226+
if (Args.hasArg(options::OPT_fuse_ld_EQ)) {
227+
Linker.assign(ToolChain.GetLinkerPath());
228+
} else {
229+
Linker.assign(ToolChain.GCCToolchainDir);
230+
llvm::sys::path::append(Linker, "bin",
231+
ToolChain.GCCToolchainName + "-" + getShortName());
232+
}
228233

229234
const char *crtbegin, *crtend;
230235
auto RuntimeLib = ToolChain.GetRuntimeLibType(Args);

clang/test/Driver/xtensa-toolchain.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: | FileCheck -check-prefix=CC1 %s
66
// CC1: clang{{.*}} "-cc1" "-triple" "xtensa"
77

8-
// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
8+
// RUN: %clang %s -### -no-canonical-prefixes \
99
// RUN: -target xtensa --rtlib=platform \
1010
// RUN: --gcc-toolchain=%S/Inputs/multilib_xtensa_tree 2>&1 \
1111
// RUN: | FileCheck -check-prefix=C-XTENSA-BAREMETAL %s
@@ -14,7 +14,7 @@
1414
// C-XTENSA-BAREMETAL: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}8.4.0/no-rtti"
1515
// C-XTENSA-BAREMETAL: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}lib/no-rtti"
1616

17-
// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
17+
// RUN: %clang %s -### -no-canonical-prefixes \
1818
// RUN: -target xtensa --rtlib=platform \
1919
// RUN: --gcc-toolchain=%S/Inputs/multilib_xtensa_tree -frtti 2>&1 \
2020
// RUN: | FileCheck -check-prefix=C-XTENSA-BAREMETAL-RTTI %s
@@ -23,7 +23,7 @@
2323
// C-XTENSA-BAREMETAL-RTTI: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}8.4.0"
2424
// C-XTENSA-BAREMETAL-RTTI: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}lib"
2525

26-
// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
26+
// RUN: %clang %s -### -no-canonical-prefixes \
2727
// RUN: -target xtensa --rtlib=platform \
2828
// RUN: --gcc-toolchain=%S/Inputs/multilib_xtensa_tree -mfix-esp32-psram-cache-issue 2>&1 \
2929
// RUN: | FileCheck -check-prefix=C-XTENSA-BAREMETAL-PSRAM %s
@@ -32,7 +32,7 @@
3232
// C-XTENSA-BAREMETAL-PSRAM: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}gcc{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}8.4.0/esp32-psram/no-rtti"
3333
// C-XTENSA-BAREMETAL-PSRAM: "-L{{.*}}/Inputs/multilib_xtensa_tree/lib/gcc/xtensa-esp32-elf/8.4.0/../../..{{/|\\\\}}..{{/|\\\\}}xtensa-esp32-elf{{/|\\\\}}lib/esp32-psram/no-rtti"
3434

35-
// RUN: %clang %s -### -no-canonical-prefixes -fuse-ld= \
35+
// RUN: %clang %s -### -no-canonical-prefixes \
3636
// RUN: -target xtensa --rtlib=platform \
3737
// RUN: --gcc-toolchain=%S/Inputs/multilib_xtensa_tree -mfix-esp32-psram-cache-issue -frtti 2>&1 \
3838
// RUN: | FileCheck -check-prefix=C-XTENSA-BAREMETAL-PSRAM-RTTI %s

0 commit comments

Comments
 (0)