Skip to content

Re-implement -reuse-exe for FPGA #647

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 1 commit into from
Sep 18, 2019
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
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,4 @@ def warn_drv_libstdcxx_not_found : Warning<
InGroup<DiagGroup<"stdlibcxx-not-found">>;

def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;

def warn_drv_reuse_exe_file_not_found : Warning<
"-reuse-exe file '%0' not found; ignored">, InGroup<IntelFPGA>;
}
22 changes: 1 addition & 21 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,28 +346,8 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
TranslateSYCLTargetArgs(C, Args, getToolChain(), CmdArgs);
// Look for -reuse-exe=XX option
if (Arg *A = Args.getLastArg(options::OPT_reuse_exe_EQ)) {
StringRef reuse_exe = A->getValue();
Args.ClaimAllArgs(options::OPT_reuse_exe_EQ);
if (llvm::sys::fs::exists(reuse_exe)) {
SmallString<128> ExecPath(getToolChain().GetProgramPath("aocl"));
const char *Exec = C.getArgs().MakeArgString(ExecPath);
ArgStringList ExtractArgs{"do", "aocl-extract-aocx", "-i"};
ExtractArgs.push_back(C.getArgs().MakeArgString(reuse_exe));
std::string TmpName = C.getDriver().GetTemporaryPath("reused-exe", "aocx");
auto OutputFileName = C.addTempFile(C.getArgs().MakeArgString(TmpName));
ExtractArgs.push_back("-o");
ExtractArgs.push_back(OutputFileName);
Command run_extract(JA, *this, Exec, ExtractArgs, None);
const Command* failingCommand = nullptr;
auto res = C.ExecuteCommand(run_extract, failingCommand);
if (res == 0) {
// We extracted the aocx file. Pass it to the aoc command.
CmdArgs.push_back(Args.MakeArgString(Twine("-reuse-aocx=") + TmpName));
}
} else {
const Driver &D = getToolChain().getDriver();
D.Diag(clang::diag::warn_drv_reuse_exe_file_not_found) << reuse_exe;
}
CmdArgs.push_back(Args.MakeArgString(A->getAsString(Args)));
}

SmallString<128> ExecPath(getToolChain().GetProgramPath("aoc"));
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Driver/sycl-offload-intelfpga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@
// CHK-FPGA-LINK-SRC: 15: clang-offload-wrapper, {14}, object, (device-sycl)
// CHK-FPGA-LINK-SRC: 16: offload, "host-sycl (x86_64-unknown-linux-gnu)" {9}, "device-sycl (spir64_fpga-unknown-{{linux|windows}}-sycldevice)" {15}, archive

// -fintelfpga -reuse-exe tests
// RUN: %clang++ -### -fsycl -fintelfpga %s -reuse-exe=does_not_exist 2>&1 \
/// -fintelfpga with -reuse-exe=
// RUN: touch %t.cpp
// RUN: %clang++ -### -reuse-exe=testing -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t.cpp 2>&1 \
// RUN: | FileCheck -check-prefixes=CHK-FPGA-REUSE-EXE %s
// CHK-FPGA-REUSE-EXE: warning: -reuse-exe file 'does_not_exist' not found; ignored
//
// CHK-FPGA-REUSE-EXE: aoc{{.*}} "-o" {{.*}} "-sycl" {{.*}} "-reuse-exe=testing"

// TODO: SYCL specific fail - analyze and enable
// XFAIL: windows-msvc