Skip to content

Commit 35d581f

Browse files
committed
[RISCV] Teach Barmetal toolchain about GCC installation(1/3)
This patch introduces the baretmetal toolchain object about GCC Installation. Currently, if `--gcc-installation` ot `--gcc-install-dir` options are passed on commandline, then sysroot will be formed from there if paths will be valid. Otherwise, it will be fallback to as it already existed in the Baremetal toolchaibn object. Additionally, the restriction to always use integrated assembler is removed because with valid gcc installation, gnu assembler can be invoked as well. This patch currently adds and modifies arm related test only. The riscv specific test will be added in the last PR when driver code related to calling of RISCVToolchain object will be removed. Currently in this PR, there is no way to test riscv target. This is the first PR in the series of 3 PRs for merging and extending Baremetal toolchain object. The division of the PRs is as follows: - Teach Baremetal toolchain about GCC installation and make sysroot and assembler related changes. - Changes related to linker job and defaults for CXXStdlib and other runtime libs. - Finally removing the call to RISCVToolchain object. The above division will also ensure that riscv and arm specific tests are not modified in the same PR. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524 Change-Id: Ibaeb569cf7e2cee03c022aa9ecd1abe29d5c30d4
1 parent 2479479 commit 35d581f

File tree

30 files changed

+299
-18
lines changed

30 files changed

+299
-18
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 82 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,76 @@ static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) {
110110
return std::string(SysRootDir);
111111
}
112112

113+
std::string BareMetal::computeSysRoot() const {
114+
if (!SysRoot.empty())
115+
return SysRoot;
116+
117+
std::string SysRoot = getDriver().SysRoot;
118+
if (!SysRoot.empty())
119+
return SysRoot;
120+
121+
// Verify the GCC installation from -gcc-install-dir, --gcc-toolchain, or
122+
// alongside clang. If valid, form the sysroot. Otherwise, check
123+
// lib/clang-runtimes above the driver.
124+
SmallString<128> SysRootDir;
125+
if (GCCInstallation.isValid()) {
126+
StringRef LibDir = GCCInstallation.getParentLibPath();
127+
StringRef TripleStr = GCCInstallation.getTriple().str();
128+
llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
129+
} else {
130+
// Use the triple as provided to the driver. Unlike the parsed triple
131+
// this has not been normalized to always contain every field.
132+
llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
133+
getDriver().getTargetTriple());
134+
}
135+
136+
if (llvm::sys::fs::exists(SysRootDir))
137+
return std::string(SysRootDir);
138+
SysRoot = computeBaseSysRoot(getDriver(), /*IncludeTriple*/ true);
139+
140+
return SysRoot;
141+
}
142+
143+
static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs,
144+
const Multilib &Multilib,
145+
StringRef InstallPath,
146+
ToolChain::path_list &Paths) {
147+
if (const auto &PathsCallback = Multilibs.filePathsCallback())
148+
for (const auto &Path : PathsCallback(Multilib))
149+
addPathIfExists(D, InstallPath + Path, Paths);
150+
}
151+
113152
BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
114153
const ArgList &Args)
115-
: ToolChain(D, Triple, Args),
116-
SysRoot(computeBaseSysRoot(D, /*IncludeTriple=*/true)) {
117-
getProgramPaths().push_back(getDriver().Dir);
118-
119-
findMultilibs(D, Triple, Args);
120-
SmallString<128> SysRoot(computeSysRoot());
121-
if (!SysRoot.empty()) {
122-
for (const Multilib &M : getOrderedMultilibs()) {
123-
SmallString<128> Dir(SysRoot);
124-
llvm::sys::path::append(Dir, M.osSuffix(), "lib");
125-
getFilePaths().push_back(std::string(Dir));
126-
getLibraryPaths().push_back(std::string(Dir));
154+
: Generic_ELF(D, Triple, Args) {
155+
GCCInstallation.init(Triple, Args);
156+
SysRoot = computeSysRoot();
157+
if (GCCInstallation.isValid()) {
158+
Multilibs = GCCInstallation.getMultilibs();
159+
SelectedMultilibs.assign({GCCInstallation.getMultilib()});
160+
path_list &Paths = getFilePaths();
161+
// Add toolchain/multilib specific file paths.
162+
addMultilibsFilePaths(D, Multilibs, SelectedMultilibs.back(),
163+
GCCInstallation.getInstallPath(), Paths);
164+
getFilePaths().push_back(GCCInstallation.getInstallPath().str());
165+
ToolChain::path_list &PPaths = getProgramPaths();
166+
// Multilib cross-compiler GCC installations put ld in a triple-prefixed
167+
// directory off of the parent of the GCC installation.
168+
PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
169+
GCCInstallation.getTriple().str() + "/bin")
170+
.str());
171+
PPaths.push_back((GCCInstallation.getParentLibPath() + "/../bin").str());
172+
getFilePaths().push_back(computeSysRoot() + "/lib");
173+
} else {
174+
getProgramPaths().push_back(getDriver().Dir);
175+
findMultilibs(D, Triple, Args);
176+
if (!SysRoot.empty()) {
177+
for (const Multilib &M : getOrderedMultilibs()) {
178+
SmallString<128> Dir(SysRoot);
179+
llvm::sys::path::append(Dir, M.osSuffix(), "lib");
180+
getFilePaths().push_back(std::string(Dir));
181+
getLibraryPaths().push_back(std::string(Dir));
182+
}
127183
}
128184
}
129185
}
@@ -265,8 +321,6 @@ Tool *BareMetal::buildStaticLibTool() const {
265321
return new tools::baremetal::StaticLibTool(*this);
266322
}
267323

268-
std::string BareMetal::computeSysRoot() const { return SysRoot; }
269-
270324
BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
271325
// Get multilibs in reverse order because they're ordered most-specific last.
272326
if (!SelectedMultilibs.empty())
@@ -311,6 +365,19 @@ void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
311365
CC1Args.push_back("-nostdsysteminc");
312366
}
313367

368+
void BareMetal::addLibStdCxxIncludePaths(
369+
const llvm::opt::ArgList &DriverArgs,
370+
llvm::opt::ArgStringList &CC1Args) const {
371+
if (!GCCInstallation.isValid())
372+
return;
373+
const GCCVersion &Version = GCCInstallation.getVersion();
374+
StringRef TripleStr = GCCInstallation.getTriple().str();
375+
const Multilib &Multilib = GCCInstallation.getMultilib();
376+
addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text,
377+
TripleStr, Multilib.includeSuffix(), DriverArgs,
378+
CC1Args);
379+
}
380+
314381
void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
315382
ArgStringList &CC1Args) const {
316383
if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
@@ -348,7 +415,7 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
348415
break;
349416
}
350417
case ToolChain::CST_Libstdcxx:
351-
// We only support libc++ toolchain installation.
418+
addLibStdCxxIncludePaths(DriverArgs, CC1Args);
352419
break;
353420
}
354421

clang/lib/Driver/ToolChains/BareMetal.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
1010
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_BAREMETAL_H
1111

12+
#include "ToolChains/Gnu.h"
1213
#include "clang/Driver/Tool.h"
1314
#include "clang/Driver/ToolChain.h"
1415

@@ -19,7 +20,7 @@ namespace driver {
1920

2021
namespace toolchains {
2122

22-
class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
23+
class LLVM_LIBRARY_VISIBILITY BareMetal : public Generic_ELF {
2324
public:
2425
BareMetal(const Driver &D, const llvm::Triple &Triple,
2526
const llvm::opt::ArgList &Args);
@@ -35,7 +36,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
3536
Tool *buildStaticLibTool() const override;
3637

3738
public:
38-
bool useIntegratedAs() const override { return true; }
3939
bool isBareMetal() const override { return true; }
4040
bool isCrossCompiling() const override { return true; }
4141
bool HasNativeLLVMSupport() const override { return true; }
@@ -67,6 +67,9 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
6767
void AddClangCXXStdlibIncludeArgs(
6868
const llvm::opt::ArgList &DriverArgs,
6969
llvm::opt::ArgStringList &CC1Args) const override;
70+
void
71+
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
72+
llvm::opt::ArgStringList &CC1Args) const override;
7073
std::string computeSysRoot() const override;
7174
SanitizerMask getSupportedSanitizers() const override;
7275

@@ -79,7 +82,6 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
7982
OrderedMultilibs getOrderedMultilibs() const;
8083

8184
std::string SysRoot;
82-
8385
SmallVector<std::string> MultilibMacroDefines;
8486
};
8587

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/true

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/lib/crt0.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtbegin.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/crtend.o

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/true

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crt0.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtbegin.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf/lib/crtend.o

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/true

clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/lib/crt0.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtbegin.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/crtend.o

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/true

clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/.keep

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crt0.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtbegin.o

Whitespace-only changes.

clang/test/Driver/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi/lib/crtend.o

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// A basic clang -cc1 command-line, and simple environment check.
2+
3+
// The tests here are similar to those in aarch64-toolchain.c, however
4+
// these tests need to create symlinks to test directory trees in order to
5+
// set up the environment and therefore shell support is required.
6+
// REQUIRES: shell
7+
// UNSUPPORTED: system-windows
8+
9+
// If there is no GCC install detected then the driver searches for executables
10+
// and runtime starting from the directory tree above the driver itself.
11+
// The test below checks that the driver correctly finds the linker and
12+
// runtime if and only if they exist.
13+
//
14+
// RUN: rm -rf %t
15+
// RUN: mkdir -p %t/aarch64-nogcc/bin
16+
// RUN: ln -s %clang %t/aarch64-nogcc/bin/clang
17+
// RUN: ln -s %S/Inputs/basic_aarch64_nogcc_tree/aarch64-none-elf %t/aarch64-nogcc/aarch64-none-elf
18+
// RUN: %t/aarch64-nogcc/bin/clang %s -### -no-canonical-prefixes \
19+
// RUN: --gcc-toolchain=%t/aarch64-nogcc/invalid \
20+
// RUN: --target=aarch64-none-elf --rtlib=libgcc -fuse-ld=ld 2>&1 \
21+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s
22+
23+
// RUN: %t/aarch64-nogcc/bin/clang %s -### -no-canonical-prefixes \
24+
// RUN: --sysroot=%t/aarch64-nogcc/bin/../aarch64-none-elf \
25+
// RUN: --target=aarch64-none-elf --rtlib=libgcc -fuse-ld=ld 2>&1 \
26+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s
27+
28+
// C-ARM-BAREMETAL-NOGCC: "-internal-isystem" "{{.*}}/aarch64-nogcc/bin/../aarch64-none-elf/include"

clang/test/Driver/aarch64-toolchain.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// UNSUPPORTED: system-windows
2+
3+
// RUN: %clang -### %s -fuse-ld= \
4+
// RUN: --target=aarch64-none-elf --rtlib=libgcc \
5+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
6+
// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \
7+
// RUN: | FileCheck -check-prefix=C-AARCH64-BAREMETAL %s
8+
9+
// C-AARCH64-BAREMETAL: "-cc1" "-triple" "aarch64-unknown-none-elf"
10+
// C-AARCH64-BAREMETAL: "-isysroot" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
11+
// C-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
12+
13+
// RUN: %clang -### %s -fuse-ld= \
14+
// RUN: --target=aarch64-none-elf --rtlib=libgcc \
15+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
16+
// RUN: --sysroot= 2>&1 \
17+
// RUN: | FileCheck -check-prefix=C-AARCH64-BAREMETAL-NOSYSROOT %s
18+
19+
// C-AARCH64-BAREMETAL-NOSYSROOT: "-cc1" "-triple" "aarch64-unknown-none-elf"
20+
// C-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include"
21+
22+
// RUN: %clangxx -### %s -fuse-ld= \
23+
// RUN: --target=aarch64-none-elf -stdlib=libstdc++ --rtlib=libgcc \
24+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
25+
// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \
26+
// RUN: | FileCheck -check-prefix=CXX-AARCH64-BAREMETAL %s
27+
28+
// CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/aarch64-none-elf"
29+
// CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1/backward"
30+
// CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/8.2.1"
31+
// CXX-AARCH64-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
32+
33+
// RUN: %clangxx -### %s -fuse-ld= \
34+
// RUN: --target=aarch64-none-elf -stdlib=libstdc++ --rtlib=libgcc \
35+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
36+
// RUN: --sysroot= 2>&1 \
37+
// RUN: | FileCheck -check-prefix=CXX-AARCH64-BAREMETAL-NOSYSROOT %s
38+
39+
// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/8.2.1/aarch64-none-elf"
40+
// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/8.2.1/backward"
41+
// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/8.2.1"
42+
// CXX-AARCH64-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include"
43+
44+
// RUN: %clangxx -### %s -fuse-ld= \
45+
// RUN: --target=aarch64-none-elf -stdlib=libc++ --rtlib=libgcc \
46+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
47+
// RUN: --sysroot=%S/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf 2>&1 \
48+
// RUN: | FileCheck -check-prefix=CXX-AARCH64-BAREMETAL-LIBCXX %s
49+
50+
// CXX-AARCH64-BAREMETAL-LIBCXX: "-isysroot" "{{.*}}Inputs/basic_aarch64_gcc_tree/aarch64-none-elf"
51+
// CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include/c++/v1"
52+
// CXX-AARCH64-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/aarch64-none-elf/include"
53+
54+
// RUN: %clangxx -### %s -fuse-ld= \
55+
// RUN: --target=aarch64-none-elf -stdlib=libc++ --rtlib=libgcc \
56+
// RUN: --gcc-toolchain=%S/Inputs/basic_aarch64_gcc_tree \
57+
// RUN: --sysroot= 2>&1 \
58+
// RUN: | FileCheck -check-prefix=CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX %s
59+
60+
// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include/c++/v1"
61+
// CXX-AARCH64-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_aarch64_gcc_tree/lib/gcc/aarch64-none-elf/8.2.1/../../../../aarch64-none-elf/include"

clang/test/Driver/arm-gnutools.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// check that gnu assembler is invoked with arm baremetal as well
2+
3+
// RUN: %clang --target=armv6m-none-eabi --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c \
4+
// RUN: 2>&1 | FileCheck %s
5+
6+
// RUN: %clang --target=armv7-none-eabi --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c \
7+
// RUN: 2>&1 | FileCheck %s
8+
9+
// RUN: %clang --target=aarch64-none-elf --gcc-toolchain=%S/Inputs/basic_riscv32_tree -fno-integrated-as %s -### -c \
10+
// RUN: 2>&1 | FileCheck %s
11+
12+
// CHECK: "{{.*}}as{{(.exe)?}}"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// A basic clang -cc1 command-line, and simple environment check.
2+
3+
// The tests here are similar to those in arm-toolchain.c, however
4+
// these tests need to create symlinks to test directory trees in order to
5+
// set up the environment and therefore shell support is required.
6+
// REQUIRES: shell
7+
// UNSUPPORTED: system-windows
8+
9+
// If there is no GCC install detected then the driver searches for executables
10+
// and runtime starting from the directory tree above the driver itself.
11+
// The test below checks that the driver correctly finds the linker and
12+
// runtime if and only if they exist.
13+
//
14+
// RUN: rm -rf %t
15+
// RUN: mkdir -p %t/arm-nogcc/bin
16+
// RUN: ln -s %clang %t/arm-nogcc/bin/clang
17+
// RUN: ln -s %S/Inputs/basic_arm_nogcc_tree/armv6m-none-eabi %t/arm-nogcc/armv6m-none-eabi
18+
// RUN: %t/arm-nogcc/bin/clang %s -### -no-canonical-prefixes \
19+
// RUN: --gcc-toolchain=%t/arm-nogcc/invalid \
20+
// RUN: --target=armv6m-none-eabi --rtlib=libgcc -fuse-ld=ld 2>&1 \
21+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s
22+
23+
// RUN: %t/arm-nogcc/bin/clang %s -### -no-canonical-prefixes \
24+
// RUN: --sysroot=%t/arm-nogcc/bin/../armv6m-none-eabi \
25+
// RUN: --target=armv6m-none-eabi --rtlib=libgcc -fuse-ld=ld 2>&1 \
26+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOGCC %s
27+
28+
// C-ARM-BAREMETAL-NOGCC: "-internal-isystem" "{{.*}}/arm-nogcc/bin/../armv6m-none-eabi/include"
29+

clang/test/Driver/arm-toolchain.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// UNSUPPORTED: system-windows
2+
3+
// RUN: %clang -### %s -fuse-ld= \
4+
// RUN: --target=armv6m-none-eabi --rtlib=libgcc \
5+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
6+
// RUN: --sysroot=%S/Inputs/basic_arm_gcc_tree/armv6m-none-eabi 2>&1 \
7+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL %s
8+
9+
// C-ARM-BAREMETAL: "-cc1" "-triple" "thumbv6m-unknown-none-eabi"
10+
// C-ARM-BAREMETAL: "-isysroot" "{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi"
11+
// C-ARM-BAREMETAL: "-internal-isystem" "{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include"
12+
13+
// RUN: %clang -### %s -fuse-ld= \
14+
// RUN: --target=armv6m-none-eabi --rtlib=libgcc \
15+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
16+
// RUN: --sysroot= 2>&1 \
17+
// RUN: | FileCheck -check-prefix=C-ARM-BAREMETAL-NOSYSROOT %s
18+
19+
// C-ARM-BAREMETAL-NOSYSROOT: "-cc1" "-triple" "thumbv6m-unknown-none-eabi"
20+
// C-ARM-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include"
21+
22+
// RUN: %clangxx -### %s -fuse-ld= \
23+
// RUN: --target=armv6m-none-eabi -stdlib=libstdc++ --rtlib=libgcc \
24+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
25+
// RUN: --sysroot=%S/Inputs/basic_arm_gcc_tree/armv6m-none-eabi 2>&1 \
26+
// RUN: | FileCheck -check-prefix=CXX-ARM-BAREMETAL %s
27+
28+
// CXX-ARM-BAREMETAL: "-isysroot" "{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi"
29+
// CXX-ARM-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1/armv6m-none-eabi"
30+
// CXX-ARM-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1/backward"
31+
// CXX-ARM-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/8.2.1"
32+
// CXX-ARM-BAREMETAL: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include"
33+
34+
// RUN: %clangxx -### %s -fuse-ld= \
35+
// RUN: --target=armv6m-none-eabi -stdlib=libstdc++ --rtlib=libgcc \
36+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
37+
// RUN: --sysroot= 2>&1 \
38+
// RUN: | FileCheck -check-prefix=CXX-ARM-BAREMETAL-NOSYSROOT %s
39+
40+
// CXX-ARM-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include/c++/8.2.1/armv6m-none-eabi"
41+
// CXX-ARM-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include/c++/8.2.1/backward"
42+
// CXX-ARM-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include/c++/8.2.1"
43+
// CXX-ARM-BAREMETAL-NOSYSROOT: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include"
44+
45+
// RUN: %clangxx -### %s -fuse-ld= \
46+
// RUN: --target=armv6m-none-eabi -stdlib=libc++ --rtlib=libgcc \
47+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
48+
// RUN: --sysroot=%S/Inputs/basic_arm_gcc_tree/armv6m-none-eabi 2>&1 \
49+
// RUN: | FileCheck -check-prefix=CXX-ARM-BAREMETAL-LIBCXX %s
50+
51+
// CXX-ARM-BAREMETAL-LIBCXX: "-isysroot" "{{.*}}Inputs/basic_arm_gcc_tree/armv6m-none-eabi"
52+
// CXX-ARM-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include/c++/v1"
53+
// CXX-ARM-BAREMETAL-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/armv6m-none-eabi/include"
54+
55+
// RUN: %clangxx -### %s -fuse-ld= \
56+
// RUN: --target=armv6m-none-eabi -stdlib=libc++ --rtlib=libgcc \
57+
// RUN: --gcc-toolchain=%S/Inputs/basic_arm_gcc_tree \
58+
// RUN: --sysroot= 2>&1 \
59+
// RUN: | FileCheck -check-prefix=CXX-ARM-BAREMETAL-NOSYSROOT-LIBCXX %s
60+
61+
// CXX-ARM-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include/c++/v1"
62+
// CXX-ARM-BAREMETAL-NOSYSROOT-LIBCXX: "-internal-isystem" "{{.*}}/Inputs/basic_arm_gcc_tree/lib/gcc/armv6m-none-eabi/8.2.1/../../../../armv6m-none-eabi/include

0 commit comments

Comments
 (0)