Skip to content

Commit

Permalink
[clang][driver] Cleanup UEFI toolchain driver
Browse files Browse the repository at this point in the history
UEFI toolchain predefines clean up. Introducing new __PECOFF__ predefine
for targets that produce PE COFF binaries. Updating UEFI header includes
to not include system include directories.
  • Loading branch information
Prabhuk committed Oct 8, 2024
1 parent d1335fb commit c241379
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/OSTargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
void addWindowsDefines(const llvm::Triple &Triple, const LangOptions &Opts,
MacroBuilder &Builder) {
Builder.defineMacro("_WIN32");
Builder.defineMacro("__PECOFF__");
if (Triple.isArch64Bit())
Builder.defineMacro("_WIN64");
if (Triple.isWindowsGNUEnvironment())
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Basic/Targets/OSTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,9 @@ template <typename Target>
class LLVM_LIBRARY_VISIBILITY UEFITargetInfo : public OSTargetInfo<Target> {
protected:
void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
MacroBuilder &Builder) const override {}
MacroBuilder &Builder) const override {
Builder.defineMacro("__PECOFF__");
}

public:
UEFITargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Expand Down
5 changes: 0 additions & 5 deletions clang/lib/Basic/Targets/X86.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,11 +826,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
8 changes: 8 additions & 0 deletions clang/lib/Driver/ToolChains/UEFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)

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

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


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

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

};

} // namespace toolchains
Expand Down

0 comments on commit c241379

Please sign in to comment.