Skip to content

Commit d1d6c5d

Browse files
authored
[Driver][SYCL] Improve output file handling for -fsycl-device-only (#3066)
When using -fsycl-device-only, specifying -o file would not output to file when used on Windows (clang-cl). Update to allow for the Windows /o to interpret this as expected.
1 parent fd2e921 commit d1d6c5d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6371,6 +6371,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
63716371
if (AtTopLevel && !isa<DsymutilJobAction>(JA) && !isa<VerifyJobAction>(JA)) {
63726372
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
63736373
return C.addResultFile(FinalOutput->getValue(), &JA);
6374+
// Output to destination for -fsycl-device-only and Windows -o
6375+
if (C.getArgs().hasArg(options::OPT_fsycl_device_only))
6376+
if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_o))
6377+
return C.addResultFile(FinalOutput->getValue(), &JA);
63746378
}
63756379

63766380
// For /P, preprocess to file named after BaseInput.

clang/test/Driver/sycl-device.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@
2828
// RUN: | FileCheck -check-prefix=CHECK-SYCL-AUX-TRIPLE %s
2929
// TODO: %clang -### -fsycl -fsycl-device-only -target aarch64-linux-gnu
3030
// CHECK-SYCL-AUX-TRIPLE: clang{{.*}} "-aux-triple" "aarch64-unknown-linux-gnu"
31+
32+
/// Verify output files are properly specified given -o
33+
// RUN: %clang -### -fsycl -fsycl-device-only -o dummy.out %s 2>&1 \
34+
// RUN: | FileCheck -check-prefix=CHECK-OUTPUT-FILE %s
35+
// RUN: %clang_cl -### -fsycl -fsycl-device-only -o dummy.out %s 2>&1 \
36+
// RUN: | FileCheck -check-prefix=CHECK-OUTPUT-FILE %s
37+
// CHECK-OUTPUT-FILE: clang{{.*}} "-o" "dummy.out"

0 commit comments

Comments
 (0)