CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
121 lines
4.5 KiB
C++
121 lines
4.5 KiB
C++
//===--- UEFI.cpp - UEFI ToolChain Implementations -----------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "UEFI.h"
|
|
#include "clang/Config/config.h"
|
|
#include "clang/Driver/CommonArgs.h"
|
|
#include "clang/Driver/Compilation.h"
|
|
#include "clang/Driver/Driver.h"
|
|
#include "clang/Driver/SanitizerArgs.h"
|
|
#include "clang/Options/Options.h"
|
|
#include "llvm/Option/Arg.h"
|
|
#include "llvm/Option/ArgList.h"
|
|
#include "llvm/Support/VirtualFileSystem.h"
|
|
#include "llvm/TargetParser/Host.h"
|
|
|
|
using namespace clang::driver;
|
|
using namespace clang::driver::toolchains;
|
|
using namespace clang;
|
|
using namespace llvm::opt;
|
|
|
|
UEFI::UEFI(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
|
: ToolChain(D, Triple, Args) {
|
|
getProgramPaths().push_back(getDriver().Dir);
|
|
}
|
|
|
|
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,
|
|
const ArgList &Args,
|
|
const char *LinkingOutput) const {
|
|
ArgStringList CmdArgs;
|
|
auto &TC = static_cast<const toolchains::UEFI &>(getToolChain());
|
|
|
|
assert((Output.isFilename() || Output.isNothing()) && "invalid output");
|
|
if (Output.isFilename())
|
|
CmdArgs.push_back(
|
|
Args.MakeArgString(std::string("/out:") + Output.getFilename()));
|
|
|
|
CmdArgs.push_back("/nologo");
|
|
|
|
// Default entry function name according to the TianoCore reference
|
|
// implementation is EfiMain. -Wl,/subsystem:... or -Wl,/entry:... can
|
|
// override these since they will be added later in AddLinkerInputs.
|
|
CmdArgs.push_back("/subsystem:efi_application");
|
|
CmdArgs.push_back("/entry:EfiMain");
|
|
|
|
// "Terminal Service Aware" flag is not needed for UEFI applications.
|
|
CmdArgs.push_back("/tsaware:no");
|
|
|
|
if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
|
|
CmdArgs.push_back("/debug");
|
|
|
|
// Pass on /Brepro if it was passed to the compiler.
|
|
// Note that /Brepro maps to -mno-incremental-linker-compatible.
|
|
if (!Args.hasFlag(options::OPT_mincremental_linker_compatible,
|
|
options::OPT_mno_incremental_linker_compatible,
|
|
/*Default=*/true))
|
|
CmdArgs.push_back("/Brepro");
|
|
|
|
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
|
|
|
|
AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
|
|
|
|
// Sample these options first so they are claimed even under -nostdlib et al.
|
|
bool NoLibc = Args.hasArg(options::OPT_nolibc);
|
|
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
|
|
options::OPT_r)) {
|
|
addSanitizerRuntimes(TC, Args, CmdArgs);
|
|
|
|
addXRayRuntime(TC, Args, CmdArgs);
|
|
|
|
TC.addProfileRTLibs(Args, CmdArgs);
|
|
|
|
// TODO: When compiler-rt/lib/builtins is ready, enable this call:
|
|
// AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
|
|
|
|
if (!NoLibc) {
|
|
// TODO: When there is a libc ready, add it here.
|
|
}
|
|
}
|
|
|
|
// This should ideally be handled by ToolChain::GetLinkerPath but we need
|
|
// to special case some linker paths. In the case of lld, we need to
|
|
// translate 'lld' into 'lld-link'.
|
|
StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ,
|
|
TC.getDriver().getPreferredLinker());
|
|
if (Linker.empty() || Linker == "lld")
|
|
Linker = "lld-link";
|
|
|
|
auto LinkerPath = TC.GetProgramPath(Linker.str().c_str());
|
|
auto LinkCmd = std::make_unique<Command>(
|
|
JA, *this, ResponseFileSupport::AtFileUTF16(),
|
|
Args.MakeArgString(LinkerPath), CmdArgs, Inputs, Output);
|
|
C.addCommand(std::move(LinkCmd));
|
|
}
|