Skip to content

Commit

Permalink
[clang][driver] Cleanup UEFI toolchain driver (llvm#111473)
Browse files Browse the repository at this point in the history
Updating UEFI header includes to not include system include directories,
adding includes from compiler resource directory and minor cleanups.
  • Loading branch information
Prabhuk authored Dec 22, 2024
1 parent 530fe60 commit dce2245
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
5 changes: 0 additions & 5 deletions clang/lib/Basic/Targets/X86.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,11 +832,6 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
"i64:64-i128:128-f80:128-n8:16:32:64-S128");
}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
getOSDefines(Opts, X86TargetInfo::getTriple(), Builder);
}

BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
}
Expand Down
18 changes: 18 additions & 0 deletions clang/lib/Driver/ToolChains/UEFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)

Tool *UEFI::buildLinker() const { return new tools::uefi::Linker(*this); }

void UEFI::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdinc))
return;

if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
SmallString<128> Dir(getDriver().ResourceDir);
llvm::sys::path::append(Dir, "include");
addSystemInclude(DriverArgs, CC1Args, Dir.str());
}

if (DriverArgs.hasArg(options::OPT_nostdlibinc))
return;

if (std::optional<std::string> Path = getStdlibIncludePath())
addSystemInclude(DriverArgs, CC1Args, *Path);
}

void tools::uefi::Linker::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/UEFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class LLVM_LIBRARY_VISIBILITY UEFI : public ToolChain {
return false;
}
bool isPICDefaultForced() const override { return true; }

void
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
};

} // namespace toolchains
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Lex/InitHeaderSearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
case llvm::Triple::PS5:
case llvm::Triple::RTEMS:
case llvm::Triple::Solaris:
case llvm::Triple::UEFI:
case llvm::Triple::WASI:
case llvm::Triple::ZOS:
return false;
Expand Down

0 comments on commit dce2245

Please sign in to comment.