Skip to content

[SYCL][Driver] Improve fat static library support #1319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ def warn_drv_object_size_disabled_O0 : Warning<
InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror;
def err_invalid_branch_protection: Error <
"invalid branch protection option '%0' in '%1'">;
def warn_drv_deprecated_option : Warning<
"option '%0' is deprecated, use '%1' directly instead">, InGroup<Deprecated>;

def note_drv_command_failed_diag_msg : Note<
"diagnostic msg: %0">;
Expand Down
13 changes: 13 additions & 0 deletions clang/include/clang/Driver/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Action {
SPIRVTranslatorJobClass,
SPIRCheckJobClass,
SYCLPostLinkJobClass,
PartialLinkJobClass,
BackendCompileJobClass,

JobClassFirst = PreprocessJobClass,
Expand Down Expand Up @@ -680,6 +681,18 @@ class SYCLPostLinkJobAction : public JobAction {
}
};

class PartialLinkJobAction : public JobAction {
void anchor() override;

public:
PartialLinkJobAction(Action *Input, types::ID OutputType);
PartialLinkJobAction(ActionList &Input, types::ID OutputType);

static bool classof(const Action *A) {
return A->getKind() == PartialLinkJobClass;
}
};

class BackendCompileJobAction : public JobAction {
void anchor() override;

Expand Down
14 changes: 14 additions & 0 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,15 @@ class Driver {
&CachedResults,
Action::OffloadKind TargetDeviceOffloadKind) const;

/// Static offload library seen.
bool OffloadStaticLibSeen = false;

void setOffloadStaticLibSeen() { OffloadStaticLibSeen = true; }

/// Returns true if an offload static library is found.
bool checkForOffloadStaticLib(Compilation &C,
llvm::opt::DerivedArgList &Args) const;

public:
/// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
/// return the grouped values as integers. Numbers which are not
Expand All @@ -642,6 +651,8 @@ class Driver {
MutableArrayRef<unsigned> Digits);
/// Compute the default -fmodule-cache-path.
static void getDefaultModuleCachePath(SmallVectorImpl<char> &Result);

bool getOffloadStaticLibSeen() const { return OffloadStaticLibSeen; };
};

/// \return True if the last defined optimization level is -Ofast.
Expand All @@ -651,6 +662,9 @@ bool isOptimizationLevelFast(const llvm::opt::ArgList &Args);
/// \return True if the filename has a valid object file extension.
bool isObjectFile(std::string FileName);

/// \return True if the filename has a static archive/lib extension.
bool isStaticArchiveFile(const StringRef &FileName);

/// \return True if the argument combination will end up generating remarks.
bool willEmitRemarks(const llvm::opt::ArgList &Args);

Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class ToolChain {
mutable std::unique_ptr<Tool> SPIRVTranslator;
mutable std::unique_ptr<Tool> SPIRCheck;
mutable std::unique_ptr<Tool> SYCLPostLink;
mutable std::unique_ptr<Tool> PartialLink;
mutable std::unique_ptr<Tool> BackendCompiler;

Tool *getClang() const;
Expand All @@ -158,6 +159,7 @@ class ToolChain {
Tool *getSPIRVTranslator() const;
Tool *getSPIRCheck() const;
Tool *getSYCLPostLink() const;
Tool *getPartialLink() const;
Tool *getBackendCompiler() const;

mutable std::unique_ptr<SanitizerArgs> SanitizerArguments;
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/Driver/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ const char *Action::getClassName(ActionClass AC) {
return "llvm-no-spir-kernel";
case SYCLPostLinkJobClass:
return "sycl-post-link";
case PartialLinkJobClass:
return "partial-link";
case BackendCompileJobClass:
return "backend-compiler";
}
Expand Down Expand Up @@ -454,6 +456,14 @@ void SYCLPostLinkJobAction::anchor() {}
SYCLPostLinkJobAction::SYCLPostLinkJobAction(Action *Input, types::ID Type)
: JobAction(SYCLPostLinkJobClass, Input, Type) {}

void PartialLinkJobAction::anchor() {}

PartialLinkJobAction::PartialLinkJobAction(Action *Input, types::ID Type)
: JobAction(PartialLinkJobClass, Input, Type) {}

PartialLinkJobAction::PartialLinkJobAction(ActionList &Inputs, types::ID Type)
: JobAction(PartialLinkJobClass, Inputs, Type) {}

void BackendCompileJobAction::anchor() {}

BackendCompileJobAction::BackendCompileJobAction(ActionList &Inputs,
Expand Down
Loading