Skip to content

Commit 03b91a8

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 ce831a2 commit 03b91a8

File tree

30 files changed

+326
-20
lines changed

30 files changed

+326
-20
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

+103-18
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ static bool findRISCVMultilibs(const Driver &D,
9797
return false;
9898
}
9999

100-
static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) {
100+
static std::string computeInstalledToolchainSysRoot(const Driver &D,
101+
bool IncludeTriple) {
101102
if (!D.SysRoot.empty())
102103
return D.SysRoot;
103104

@@ -110,20 +111,93 @@ static std::string computeBaseSysRoot(const Driver &D, bool IncludeTriple) {
110111
return std::string(SysRootDir);
111112
}
112113

114+
// GCC sysroot here means form sysroot from either --gcc-install-dir, or from
115+
// --gcc-toolchain or if the toolchain is installed alongside clang in
116+
// bin/../<TargetTriple> directory if it is not explicitly specified on the
117+
// command line through `--sysroot` option. libc here will be newlib.
118+
std::string BareMetal::computeGCCSysRoot() const {
119+
if (!getDriver().SysRoot.empty())
120+
return getDriver().SysRoot;
121+
122+
SmallString<128> SysRootDir;
123+
if (GCCInstallation.isValid()) {
124+
StringRef LibDir = GCCInstallation.getParentLibPath();
125+
StringRef TripleStr = GCCInstallation.getTriple().str();
126+
llvm::sys::path::append(SysRootDir, LibDir, "..", TripleStr);
127+
} else {
128+
// Use the triple as provided to the driver. Unlike the parsed triple
129+
// this has not been normalized to always contain every field.
130+
llvm::sys::path::append(SysRootDir, getDriver().Dir, "..",
131+
getDriver().getTargetTriple());
132+
}
133+
134+
if (!llvm::sys::fs::exists(SysRootDir))
135+
return std::string();
136+
137+
return std::string(SysRootDir);
138+
}
139+
140+
std::string BareMetal::computeSysRoot() const {
141+
if (!SysRoot.empty())
142+
return SysRoot;
143+
144+
std::string SysRoot = getDriver().SysRoot;
145+
if (!SysRoot.empty() && llvm::sys::fs::exists(SysRoot))
146+
return SysRoot;
147+
148+
// Verify the GCC installation from -gcc-install-dir, --gcc-toolchain, or
149+
// alongside clang. If valid, form the sysroot. Otherwise, check
150+
// lib/clang-runtimes above the driver.
151+
SysRoot = computeGCCSysRoot();
152+
if (!SysRoot.empty())
153+
return SysRoot;
154+
155+
SysRoot =
156+
computeInstalledToolchainSysRoot(getDriver(), /*IncludeTriple*/ true);
157+
158+
return SysRoot;
159+
}
160+
161+
static void addMultilibsFilePaths(const Driver &D, const MultilibSet &Multilibs,
162+
const Multilib &Multilib,
163+
StringRef InstallPath,
164+
ToolChain::path_list &Paths) {
165+
if (const auto &PathsCallback = Multilibs.filePathsCallback())
166+
for (const auto &Path : PathsCallback(Multilib))
167+
addPathIfExists(D, InstallPath + Path, Paths);
168+
}
169+
113170
BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
114171
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));
172+
: Generic_ELF(D, Triple, Args) {
173+
GCCInstallation.init(Triple, Args);
174+
SysRoot = computeSysRoot();
175+
if (GCCInstallation.isValid()) {
176+
Multilibs = GCCInstallation.getMultilibs();
177+
SelectedMultilibs.assign({GCCInstallation.getMultilib()});
178+
path_list &Paths = getFilePaths();
179+
// Add toolchain/multilib specific file paths.
180+
addMultilibsFilePaths(D, Multilibs, SelectedMultilibs.back(),
181+
GCCInstallation.getInstallPath(), Paths);
182+
getFilePaths().push_back(GCCInstallation.getInstallPath().str());
183+
ToolChain::path_list &PPaths = getProgramPaths();
184+
// Multilib cross-compiler GCC installations put ld in a triple-prefixed
185+
// directory off of the parent of the GCC installation.
186+
PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
187+
GCCInstallation.getTriple().str() + "/bin")
188+
.str());
189+
PPaths.push_back((GCCInstallation.getParentLibPath() + "/../bin").str());
190+
getFilePaths().push_back(computeSysRoot() + "/lib");
191+
} else {
192+
getProgramPaths().push_back(getDriver().Dir);
193+
findMultilibs(D, Triple, Args);
194+
if (!SysRoot.empty()) {
195+
for (const Multilib &M : getOrderedMultilibs()) {
196+
SmallString<128> Dir(SysRoot);
197+
llvm::sys::path::append(Dir, M.osSuffix(), "lib");
198+
getFilePaths().push_back(std::string(Dir));
199+
getLibraryPaths().push_back(std::string(Dir));
200+
}
127201
}
128202
}
129203
}
@@ -215,7 +289,7 @@ getMultilibConfigPath(const Driver &D, const llvm::Triple &Triple,
215289
return {};
216290
}
217291
} else {
218-
MultilibPath = computeBaseSysRoot(D, /*IncludeTriple=*/false);
292+
MultilibPath = computeInstalledToolchainSysRoot(D, /*IncludeTriple=*/false);
219293
llvm::sys::path::append(MultilibPath, MultilibFilename);
220294
}
221295
return MultilibPath;
@@ -233,7 +307,7 @@ void BareMetal::findMultilibs(const Driver &D, const llvm::Triple &Triple,
233307
if (D.getVFS().exists(*MultilibPath)) {
234308
// If multilib.yaml is found, update sysroot so it doesn't use a target
235309
// specific suffix
236-
SysRoot = computeBaseSysRoot(D, /*IncludeTriple=*/false);
310+
SysRoot = computeInstalledToolchainSysRoot(D, /*IncludeTriple=*/false);
237311
findMultilibsFromYAML(*this, D, *MultilibPath, Args, Result);
238312
SelectedMultilibs = Result.SelectedMultilibs;
239313
Multilibs = Result.Multilibs;
@@ -258,8 +332,6 @@ Tool *BareMetal::buildStaticLibTool() const {
258332
return new tools::baremetal::StaticLibTool(*this);
259333
}
260334

261-
std::string BareMetal::computeSysRoot() const { return SysRoot; }
262-
263335
BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
264336
// Get multilibs in reverse order because they're ordered most-specific last.
265337
if (!SelectedMultilibs.empty())
@@ -304,6 +376,19 @@ void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
304376
CC1Args.push_back("-nostdsysteminc");
305377
}
306378

379+
void BareMetal::addLibStdCxxIncludePaths(
380+
const llvm::opt::ArgList &DriverArgs,
381+
llvm::opt::ArgStringList &CC1Args) const {
382+
if (!GCCInstallation.isValid())
383+
return;
384+
const GCCVersion &Version = GCCInstallation.getVersion();
385+
StringRef TripleStr = GCCInstallation.getTriple().str();
386+
const Multilib &Multilib = GCCInstallation.getMultilib();
387+
addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text,
388+
TripleStr, Multilib.includeSuffix(), DriverArgs,
389+
CC1Args);
390+
}
391+
307392
void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
308393
ArgStringList &CC1Args) const {
309394
if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
@@ -341,7 +426,7 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
341426
break;
342427
}
343428
case ToolChain::CST_Libstdcxx:
344-
// We only support libc++ toolchain installation.
429+
addLibStdCxxIncludePaths(DriverArgs, CC1Args);
345430
break;
346431
}
347432

clang/lib/Driver/ToolChains/BareMetal.h

+11-2
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; }
@@ -55,6 +55,11 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
5555
return ToolChain::CST_Libcxx;
5656
}
5757

58+
UnwindTableLevel
59+
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
60+
return UnwindTableLevel::None;
61+
}
62+
5863
const char *getDefaultLinker() const override { return "ld.lld"; }
5964

6065
void
@@ -67,6 +72,9 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
6772
void AddClangCXXStdlibIncludeArgs(
6873
const llvm::opt::ArgList &DriverArgs,
6974
llvm::opt::ArgStringList &CC1Args) const override;
75+
void
76+
addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
77+
llvm::opt::ArgStringList &CC1Args) const override;
7078
std::string computeSysRoot() const override;
7179
SanitizerMask getSupportedSanitizers() const override;
7280

@@ -76,6 +84,7 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
7684
OrderedMultilibs getOrderedMultilibs() const;
7785

7886
std::string SysRoot;
87+
std::string computeGCCSysRoot() const;
7988
};
8089

8190
} // namespace toolchains
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.
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.
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.
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.
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

+61
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

+12
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)?}}"
+29
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+

0 commit comments

Comments
 (0)