Skip to content

Commit 1d5b2cb

Browse files
authored
[Driver][SYCL] Allow for -o output with dependency generation (#4406)
Previous fix to for dependency generation with -fsycl caused a problem when emitting an output file and dependency info. This was causing a multiple output error, due to the extra preprocess step which is counted as a compilation step. Allow for this new step to not count as an official output step.
1 parent fd6d948 commit 1d5b2cb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5866,6 +5866,9 @@ void Driver::BuildJobs(Compilation &C) const {
58665866
// we are also generating .o files. So we allow more than one output file in
58675867
// this case as well.
58685868
//
5869+
// Preprocessing job performed for -fsycl enabled compilation specifically
5870+
// for dependency generation (TY_Dependencies)
5871+
//
58695872
if (FinalOutput) {
58705873
unsigned NumOutputs = 0;
58715874
unsigned NumIfsOutputs = 0;
@@ -5876,7 +5879,10 @@ void Driver::BuildJobs(Compilation &C) const {
58765879
A->getKind() == clang::driver::Action::CompileJobClass &&
58775880
0 == NumIfsOutputs++) ||
58785881
(A->getKind() == Action::BindArchClass && A->getInputs().size() &&
5879-
A->getInputs().front()->getKind() == Action::IfsMergeJobClass)))
5882+
A->getInputs().front()->getKind() == Action::IfsMergeJobClass) ||
5883+
(A->getKind() == Action::PreprocessJobClass &&
5884+
A->getType() == types::TY_Dependencies &&
5885+
C.getArgs().hasArg(options::OPT_fsycl))))
58805886
++NumOutputs;
58815887

58825888
if (NumOutputs > 1) {

clang/test/Driver/sycl-int-footer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,8 @@
9494
// DEP_GEN_PHASES: 10: backend, {9}, assembler, (host-sycl)
9595
// DEP_GEN_PHASES: 11: assembler, {10}, object, (host-sycl)
9696
// DEP_GEN_PHASES: 12: clang-offload-bundler, {5, 11}, object, (host-sycl)
97+
98+
/// Allow for -o and preprocessing
99+
// RUN: %clangxx -fsycl -MD -c %s -o dummy -### 2>&1 \
100+
// RUN: | FileCheck -check-prefix DEP_GEN_OUT_ERROR %s
101+
// DEP_GEN_OUT_ERROR-NOT: cannot specify -o when generating multiple output files

0 commit comments

Comments
 (0)