Skip to content

Commit bf3577e

Browse files
committed
[clang][Driver] Implement addLibCxxIncludePaths and getCompilerRT for the OpenBSD clang driver.
1 parent 2b37174 commit bf3577e

File tree

2 files changed

+44
-25
lines changed

2 files changed

+44
-25
lines changed

clang/lib/Driver/ToolChains/OpenBSD.cpp

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -258,29 +258,6 @@ OpenBSD::OpenBSD(const Driver &D, const llvm::Triple &Triple,
258258
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
259259
}
260260

261-
void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
262-
ArgStringList &CmdArgs) const {
263-
bool Profiling = Args.hasArg(options::OPT_pg);
264-
265-
CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
266-
CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
267-
}
268-
269-
Tool *OpenBSD::buildAssembler() const {
270-
return new tools::openbsd::Assembler(*this);
271-
}
272-
273-
Tool *OpenBSD::buildLinker() const { return new tools::openbsd::Linker(*this); }
274-
275-
void OpenBSD::addClangTargetOptions(const ArgList &DriverArgs,
276-
ArgStringList &CC1Args,
277-
Action::OffloadKind) const {
278-
// Support for .init_array is still new (Aug 2016).
279-
if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
280-
options::OPT_fno_use_init_array, false))
281-
CC1Args.push_back("-fno-use-init-array");
282-
}
283-
284261
void OpenBSD::AddClangSystemIncludeArgs(
285262
const llvm::opt::ArgList &DriverArgs,
286263
llvm::opt::ArgStringList &CC1Args) const {
@@ -314,4 +291,41 @@ void OpenBSD::AddClangSystemIncludeArgs(
314291
addExternCSystemInclude(DriverArgs, CC1Args, D.SysRoot + "/usr/include");
315292
}
316293

294+
void OpenBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
295+
llvm::opt::ArgStringList &CC1Args) const {
296+
addSystemInclude(DriverArgs, CC1Args,
297+
getDriver().SysRoot + "/usr/include/c++/v1");
298+
}
299+
300+
void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args,
301+
ArgStringList &CmdArgs) const {
302+
bool Profiling = Args.hasArg(options::OPT_pg);
303+
304+
CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
305+
CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
306+
}
307+
308+
std::string OpenBSD::getCompilerRT(const ArgList &Args,
309+
StringRef Component,
310+
FileType Type) const {
311+
SmallString<128> Path(getDriver().SysRoot);
312+
llvm::sys::path::append(Path, "/usr/lib/libcompiler_rt.a");
313+
return std::string(Path.str());
314+
}
315+
316+
void OpenBSD::addClangTargetOptions(const ArgList &DriverArgs,
317+
ArgStringList &CC1Args,
318+
Action::OffloadKind) const {
319+
// Support for .init_array is still new (Aug 2016).
320+
if (!DriverArgs.hasFlag(options::OPT_fuse_init_array,
321+
options::OPT_fno_use_init_array, false))
322+
CC1Args.push_back("-fno-use-init-array");
323+
}
324+
325+
Tool *OpenBSD::buildAssembler() const {
326+
return new tools::openbsd::Assembler(*this);
327+
}
328+
329+
Tool *OpenBSD::buildLinker() const { return new tools::openbsd::Linker(*this); }
330+
317331
bool OpenBSD::HasNativeLLVMSupport() const { return true; }

clang/lib/Driver/ToolChains/OpenBSD.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
5454
OpenBSD(const Driver &D, const llvm::Triple &Triple,
5555
const llvm::opt::ArgList &Args);
5656

57+
bool HasNativeLLVMSupport() const override;
58+
5759
bool IsMathErrnoDefault() const override { return false; }
5860
bool IsObjCNonFragileABIDefault() const override { return true; }
5961
bool isPIEDefault() const override { return true; }
@@ -69,11 +71,14 @@ class LLVM_LIBRARY_VISIBILITY OpenBSD : public Generic_ELF {
6971
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
7072
llvm::opt::ArgStringList &CC1Args) const override;
7173

72-
bool HasNativeLLVMSupport() const override;
73-
74+
void addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
75+
llvm::opt::ArgStringList &CC1Args) const override;
7476
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
7577
llvm::opt::ArgStringList &CmdArgs) const override;
7678

79+
std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
80+
FileType Type = ToolChain::FT_Static) const override;
81+
7782
unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {
7883
return 2;
7984
}

0 commit comments

Comments
 (0)