Skip to content

Commit ea21fdc

Browse files
authored
[Driver][SYCL][FPGA] Adjust the output location for the project report (#1278)
When no output specifier is given on the command line, create the output project report location in the $CWD as opposed to matching the source location if it was specified with a directory. Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
1 parent 93001bb commit ea21fdc

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,22 @@ void SYCL::fpga::BackendCompiler::ConstructJob(Compilation &C,
272272
} else {
273273
// Output directory is based off of the first object name
274274
for (Arg * Cur : Args) {
275-
SmallString<128> AN = Cur->getSpelling();
276-
StringRef Ext(llvm::sys::path::extension(AN));
277-
if (!Ext.empty()) {
278-
types::ID Ty = getToolChain().LookupTypeForExtension(Ext.drop_front());
279-
if (Ty == types::TY_INVALID)
280-
continue;
281-
if (types::isSrcFile(Ty) || Ty == types::TY_Object) {
282-
llvm::sys::path::replace_extension(AN, "prj");
283-
ReportOptArg += Args.MakeArgString(AN);
284-
break;
285-
}
275+
if (Cur->getOption().getKind() != Option::InputClass)
276+
continue;
277+
SmallString<128> ArgName = Cur->getSpelling();
278+
StringRef Ext(llvm::sys::path::extension(ArgName));
279+
if (Ext.empty())
280+
continue;
281+
types::ID Ty = getToolChain().LookupTypeForExtension(Ext.drop_front());
282+
if (Ty == types::TY_INVALID)
283+
continue;
284+
if (types::isSrcFile(Ty) || Ty == types::TY_Object) {
285+
// Project report should be saved into CWD, so strip off any
286+
// directory information if provided with the input file.
287+
ArgName = llvm::sys::path::filename(ArgName);
288+
llvm::sys::path::replace_extension(ArgName, "prj");
289+
ReportOptArg += Args.MakeArgString(ArgName);
290+
break;
286291
}
287292
}
288293
}

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,16 @@
232232
// RUN: | FileCheck -DOUTDIR=%t_dir -check-prefix=CHK-FPGA-REPORT-OPT %s
233233
// CHK-FPGA-REPORT-OPT: aoc{{.*}} "-sycl" {{.*}} "-output-report-folder=[[OUTDIR]]{{/|\\\\}}file.prj"
234234

235+
/// -fintelfpga output report file from dir/source
236+
// RUN: mkdir -p %t_dir
237+
// RUN: touch %t_dir/dummy.cpp
238+
// RUN: %clangxx -### -fsycl -fintelfpga %t_dir/dummy.cpp 2>&1 \
239+
// RUN: | FileCheck -DOUTDIR=%t_dir -check-prefix=CHK-FPGA-REPORT-OPT2 %s
240+
// RUN: %clang_cl -### -fsycl -fintelfpga %t_dir/dummy.cpp 2>&1 \
241+
// RUN: | FileCheck -DOUTDIR=%t_dir -check-prefix=CHK-FPGA-REPORT-OPT2 %s
242+
// CHK-FPGA-REPORT-OPT2: aoc{{.*}} "-sycl" {{.*}} "-output-report-folder=dummy.prj"
243+
// CHK-FPGA-REPORT-OPT2-NOT: aoc{{.*}} "-sycl" {{.*}} "-output-report-folder=[[OUTDIR]]{{.*}}"
244+
235245
/// -fintelfpga static lib (aoco)
236246
// RUN: echo "Dummy AOCO image" > %t.aoco
237247
// RUN: echo "void foo() {}" > %t.c

0 commit comments

Comments
 (0)