Skip to content

Commit 97c87ce

Browse files
committed
[clang] Add option for -nolibc in Driver/ToolChains/Baremetal.cpp
Some tests in LLVM-libc require this flag, so compiler-rt is still linked in, but not the C library. With this change, it will not be ignored. Minor changes: clang-format
1 parent 31bf934 commit 97c87ce

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,15 +339,15 @@ void BareMetal::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
339339
};
340340

341341
switch (GetCXXStdlibType(DriverArgs)) {
342-
case ToolChain::CST_Libcxx: {
343-
SmallString<128> P(D.Dir);
344-
llvm::sys::path::append(P, "..", "include");
345-
AddCXXIncludePath(P);
346-
break;
347-
}
348-
case ToolChain::CST_Libstdcxx:
349-
// We only support libc++ toolchain installation.
350-
break;
342+
case ToolChain::CST_Libcxx: {
343+
SmallString<128> P(D.Dir);
344+
llvm::sys::path::append(P, "..", "include");
345+
AddCXXIncludePath(P);
346+
break;
347+
}
348+
case ToolChain::CST_Libstdcxx:
349+
// We only support libc++ toolchain installation.
350+
break;
351351
}
352352

353353
std::string SysRoot(computeSysRoot());
@@ -498,7 +498,9 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
498498
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
499499
AddRunTimeLibs(TC, D, CmdArgs, Args);
500500

501-
CmdArgs.push_back("-lc");
501+
if (!Args.hasArg(options::OPT_nolibc)) {
502+
CmdArgs.push_back("-lc");
503+
}
502504
}
503505

504506
if (D.isUsingLTO())

0 commit comments

Comments
 (0)