Skip to content

Commit 8b8bfa9

Browse files
mdtoguchibader
authored andcommitted
[SYCL][Driver] Path problems when forming -fsycl-help tool calls
When performing -fsycl-help, the strings to execute the tool were corrupted. Adjust how the strings are handled. Adjust output behaviors with -### with -fsycl-help to allow for better inspection of the actual call being made. Also fix the option to enable help output for ocloc Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
1 parent a6d7e12 commit 8b8bfa9

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
16851685
llvm::Triple T;
16861686
if (AV == "gen" || AV == "all")
16871687
HelpArgs.push_back(std::make_tuple(makeDeviceTriple("spir64_gen"),
1688-
"ocloc", "-?"));
1688+
"ocloc", "--help"));
16891689
if (AV == "fpga" || AV == "all")
16901690
HelpArgs.push_back(std::make_tuple(makeDeviceTriple("spir64_fpga"),
16911691
"aoc", "-help"));
@@ -1704,16 +1704,19 @@ void Driver::PrintSYCLToolHelp(const Compilation &C) const {
17041704
llvm::outs() << "Emitting help information for " << std::get<1>(HA) << '\n'
17051705
<< "Use triple of '" << std::get<0>(HA).normalize() <<
17061706
"' to enable ahead of time compilation\n";
1707-
// do not run the tools with -###.
1708-
if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH))
1709-
continue;
17101707
std::vector<StringRef> ToolArgs = { std::get<1>(HA), std::get<2>(HA) };
1711-
StringRef ExecPath(C.getDefaultToolChain().GetProgramPath(std::get<1>(HA).data()));
1708+
SmallString<128> ExecPath(
1709+
C.getDefaultToolChain().GetProgramPath(std::get<1>(HA).data()));
17121710
auto ToolBinary = llvm::sys::findProgramByName(ExecPath);
17131711
if (ToolBinary.getError()) {
17141712
C.getDriver().Diag(diag::err_drv_command_failure) << ExecPath;
17151713
continue;
17161714
}
1715+
// do not run the tools with -###.
1716+
if (C.getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
1717+
llvm::errs() << "\"" << ExecPath << "\" \"" << ToolArgs[1] << "\"\n";
1718+
continue;
1719+
}
17171720
// Run the Tool.
17181721
llvm::sys::ExecuteAndWait(ToolBinary.get(), ToolArgs);
17191722
}

clang/test/Driver/sycl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@
2222
// DEFAULT-PHASES-NOT: linker
2323

2424
// -fsycl-help tests
25+
// RUN: mkdir -p %t-sycl-dir
26+
// RUN: touch %t-sycl-dir/aoc
27+
// RUN: chmod +x %t-sycl-dir/aoc
2528
// Test with a bad argument is expected to fail
2629
// RUN: not %clang -fsycl-help=foo %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-BADARG
2730
// RUN: %clang -### -fsycl-help=gen %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-GEN
28-
// RUN: %clang -### -fsycl-help=fpga %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-FPGA
31+
// RUN: env PATH=%t-sycl-dir %clang -### -fsycl-help=fpga %s 2>&1 | FileCheck %s --check-prefixes=SYCL-HELP-FPGA,SYCL-HELP-FPGA-OUT -DDIR=%t-sycl-dir
2932
// RUN: %clang -### -fsycl-help=x86_64 %s 2>&1 | FileCheck %s --check-prefix=SYCL-HELP-CPU
3033
// RUN: %clang -### -fsycl-help %s 2>&1 | FileCheck %s --check-prefixes=SYCL-HELP-GEN,SYCL-HELP-FPGA,SYCL-HELP-CPU
3134
// SYCL-HELP-BADARG: unsupported argument 'foo' to option 'fsycl-help='
3235
// SYCL-HELP-GEN: Emitting help information for ocloc
3336
// SYCL-HELP-GEN: Use triple of 'spir64_gen-unknown-{{.*}}-sycldevice' to enable ahead of time compilation
37+
// SYCL-HELP-FPGA-OUT: "[[DIR]]{{[/\\]+}}aoc" "-help"
3438
// SYCL-HELP-FPGA: Emitting help information for aoc
3539
// SYCL-HELP-FPGA: Use triple of 'spir64_fpga-unknown-{{.*}}-sycldevice' to enable ahead of time compilation
3640
// SYCL-HELP-CPU: Emitting help information for ioc64

0 commit comments

Comments
 (0)