Skip to content

Commit 6176b29

Browse files
[SYCL][Driver] '-fsycl-unnamed-lambda' is not supported with '-fsycl-host-compiler' (#17840)
Addresses #15120 This patch emits an error when `-fsycl-unnamed-lambda` is used in conjunction with `-fsycl-host-compiler` Also, use of `-fsycl-host-compiler` implicitly adds `-fno-sycl-unnamed-lambda` to the list of command line arg strings.
1 parent f4a3cb9 commit 6176b29

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -5885,8 +5885,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
58855885
CmdArgs.push_back("-ffine-grained-bitfield-accesses");
58865886
}
58875887

5888-
if (!Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
5889-
options::OPT_fno_sycl_unnamed_lambda, true))
5888+
// '-fsycl-unnamed-lambda' is not supported with '-fsycl-host-compiler'
5889+
if (Args.hasArg(options::OPT_fsycl_host_compiler_EQ)) {
5890+
if (Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
5891+
options::OPT_fno_sycl_unnamed_lambda, false))
5892+
D.Diag(diag::err_drv_cannot_mix_options) << "-fsycl-host-compiler"
5893+
<< "-fsycl-unnamed-lambda";
5894+
else // '-fsycl-host-compiler' implies '-fno-sycl-unnamed-lambda'
5895+
CmdArgs.push_back("-fno-sycl-unnamed-lambda");
5896+
} else if (!Args.hasFlag(options::OPT_fsycl_unnamed_lambda,
5897+
options::OPT_fno_sycl_unnamed_lambda, true))
58905898
CmdArgs.push_back("-fno-sycl-unnamed-lambda");
58915899

58925900
if (!Args.hasFlag(options::OPT_fsycl_esimd_force_stateless_mem,

clang/test/Driver/sycl-host-compiler-old-model.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@
6262
// RUN: | FileCheck -check-prefix=HOST_COMPILER_NOARG %s
6363
// HOST_COMPILER_NOARG: missing argument to '-fsycl-host-compiler='
6464

65+
/// error for -fsycl-host-compiler and -fsycl-unnamed-lambda combination
66+
// RUN: not %clangxx -fsycl --no-offload-new-driver -fsycl-host-compiler=g++ -fsycl-unnamed-lambda -c -### %s 2>&1 \
67+
// RUN: | FileCheck -check-prefix=HOST_COMPILER_AND_UNNAMED_LAMBDA %s
68+
// HOST_COMPILER_AND_UNNAMED_LAMBDA: error: cannot specify '-fsycl-unnamed-lambda' along with '-fsycl-host-compiler'
69+
70+
// -fsycl-host-compiler implies -fno-sycl-unnamed-lambda
71+
// RUN: %clangxx -### -fsycl --no-offload-new-driver -fsycl-host-compiler=g++ -c -### %s 2>&1 \
72+
// RUN: | FileCheck -check-prefix=IMPLY-NO-SYCL-UNNAMED-LAMBDA %s
73+
// IMPLY-NO-SYCL-UNNAMED-LAMBDA: clang{{.*}} "-fno-sycl-unnamed-lambda"
74+
6575
/// Warning should not be emitted when using -fsycl-host-compiler when linking
6676
// RUN: touch %t.o
6777
// RUN: %clangxx -fsycl --no-offload-new-driver -fsycl-host-compiler=g++ %t.o -### 2>&1 \

0 commit comments

Comments
 (0)