Skip to content

Commit 1d0db96

Browse files
committed
[Driver] Teach Barmetal toolchain about GCC installation
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. Moreover, support for adding include paths for libstd C++ library is added as well. 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. RFC: https://discourse.llvm.org/t/merging-riscvtoolchain-and-baremetal-toolchains/75524 Change-Id: Ibaeb569cf7e2cee03c022aa9ecd1abe29d5c30d4
1 parent 6263de9 commit 1d0db96

File tree

28 files changed

+324
-32
lines changed

28 files changed

+324
-32
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

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

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

268-
std::string BareMetal::computeSysRoot() const { return SysRoot; }
269-
270329
BareMetal::OrderedMultilibs BareMetal::getOrderedMultilibs() const {
271330
// Get multilibs in reverse order because they're ordered most-specific last.
272331
if (!SelectedMultilibs.empty())
@@ -294,10 +353,10 @@ void BareMetal::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
294353
if (std::optional<std::string> Path = getStdlibIncludePath())
295354
addSystemInclude(DriverArgs, CC1Args, *Path);
296355

297-
const SmallString<128> SysRoot(computeSysRoot());
298-
if (!SysRoot.empty()) {
356+
const SmallString<128> SysRootDir(computeSysRoot());
357+
if (!SysRootDir.empty()) {
299358
for (const Multilib &M : getOrderedMultilibs()) {
300-
SmallString<128> Dir(SysRoot);
359+
SmallString<128> Dir(SysRootDir);
301360
llvm::sys::path::append(Dir, M.includeSuffix());
302361
llvm::sys::path::append(Dir, "include");
303362
addSystemInclude(DriverArgs, CC1Args, Dir.str());
@@ -311,6 +370,19 @@ void BareMetal::addClangTargetOptions(const ArgList &DriverArgs,
311370
CC1Args.push_back("-nostdsysteminc");
312371
}
313372

373+
void BareMetal::addLibStdCxxIncludePaths(
374+
const llvm::opt::ArgList &DriverArgs,
375+
llvm::opt::ArgStringList &CC1Args) const {
376+
if (!GCCInstallation.isValid())
377+
return;
378+
const GCCVersion &Version = GCCInstallation.getVersion();
379+
StringRef TripleStr = GCCInstallation.getTriple().str();
380+
const Multilib &Multilib = GCCInstallation.getMultilib();
381+
addLibStdCXXIncludePaths(computeSysRoot() + "/include/c++/" + Version.Text,
382+
TripleStr, Multilib.includeSuffix(), DriverArgs,
383+
CC1Args);
384+
}
385+
314386
void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
315387
ArgStringList &CC1Args) const {
316388
if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc,
@@ -341,23 +413,23 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
341413
};
342414

343415
switch (GetCXXStdlibType(DriverArgs)) {
344-
case ToolChain::CST_Libcxx: {
345-
SmallString<128> P(D.Dir);
346-
llvm::sys::path::append(P, "..", "include");
347-
AddCXXIncludePath(P);
348-
break;
349-
}
350-
case ToolChain::CST_Libstdcxx:
351-
// We only support libc++ toolchain installation.
352-
break;
416+
case ToolChain::CST_Libcxx: {
417+
SmallString<128> P(D.Dir);
418+
llvm::sys::path::append(P, "..", "include");
419+
AddCXXIncludePath(P);
420+
break;
421+
}
422+
case ToolChain::CST_Libstdcxx:
423+
addLibStdCxxIncludePaths(DriverArgs, CC1Args);
424+
break;
353425
}
354426

355-
std::string SysRoot(computeSysRoot());
356-
if (SysRoot.empty())
427+
std::string SysRootDir(computeSysRoot());
428+
if (SysRootDir.empty())
357429
return;
358430

359431
for (const Multilib &M : getOrderedMultilibs()) {
360-
SmallString<128> Dir(SysRoot);
432+
SmallString<128> Dir(SysRootDir);
361433
llvm::sys::path::append(Dir, M.gccSuffix());
362434
switch (GetCXXStdlibType(DriverArgs)) {
363435
case ToolChain::CST_Libcxx: {

clang/lib/Driver/ToolChains/BareMetal.h

Lines changed: 11 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; }
@@ -48,6 +48,11 @@ class LLVM_LIBRARY_VISIBILITY BareMetal : public ToolChain {
4848

4949
StringRef getOSLibName() const override { return "baremetal"; }
5050

51+
UnwindTableLevel
52+
getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
53+
return UnwindTableLevel::None;
54+
}
55+
5156
RuntimeLibType GetDefaultRuntimeLibType() const override {
5257
return ToolChain::RLT_CompilerRT;
5358
}
@@ -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

@@ -104,7 +112,7 @@ class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool {
104112

105113
class LLVM_LIBRARY_VISIBILITY Linker final : public Tool {
106114
public:
107-
Linker(const ToolChain &TC) : Tool("baremetal::Linker", "ld.lld", TC) {}
115+
Linker(const ToolChain &TC) : Tool("baremetal::Linker", "linker", TC) {}
108116
bool isLinkJob() const override { return true; }
109117
bool hasIntegratedCPP() const override { return false; }
110118
void ConstructJob(Compilation &C, const JobAction &JA,

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.
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/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.

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.
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/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.

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#!/bin/true
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+

0 commit comments

Comments
 (0)