@@ -1119,6 +1119,8 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1119
1119
const InputInfoList &Inputs) const {
1120
1120
const bool IsIAMCU = getToolChain ().getTriple ().isOSIAMCU ();
1121
1121
const bool IsIntelFPGA = Args.hasArg (options::OPT_fintelfpga);
1122
+ bool SYCLDeviceCompilation = JA.isOffloading (Action::OFK_SYCL) &&
1123
+ JA.isDeviceOffloading (Action::OFK_SYCL);
1122
1124
1123
1125
CheckPreprocessingOptions (D, Args);
1124
1126
@@ -1335,9 +1337,14 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1335
1337
options::OPT_fno_pch_instantiate_templates, true ))
1336
1338
CmdArgs.push_back (Args.MakeArgString (" -fpch-instantiate-templates" ));
1337
1339
}
1340
+
1338
1341
if (YcArg || YuArg) {
1339
1342
StringRef ThroughHeader = YcArg ? YcArg->getValue () : YuArg->getValue ();
1340
- if (!isa<PrecompileJobAction>(JA)) {
1343
+ // If PCH file is available, include it while performing
1344
+ // host compilation (-fsycl-is-host) in SYCL mode (-fsycl).
1345
+ // as well as in non-sycl mode.
1346
+
1347
+ if (!isa<PrecompileJobAction>(JA) && !SYCLDeviceCompilation) {
1341
1348
CmdArgs.push_back (" -include-pch" );
1342
1349
CmdArgs.push_back (Args.MakeArgString (D.GetClPchPath (
1343
1350
C, !ThroughHeader.empty ()
@@ -1356,9 +1363,12 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1356
1363
}
1357
1364
1358
1365
bool RenderedImplicitInclude = false ;
1366
+
1359
1367
for (const Arg *A : Args.filtered (options::OPT_clang_i_Group)) {
1360
- if (A->getOption ().matches (options::OPT_include) &&
1361
- D.getProbePrecompiled ()) {
1368
+ if ((A->getOption ().matches (options::OPT_include) &&
1369
+ D.getProbePrecompiled ()) ||
1370
+ A->getOption ().matches (options::OPT_include_pch)) {
1371
+
1362
1372
// Handling of gcc-style gch precompiled headers.
1363
1373
bool IsFirstImplicitInclude = !RenderedImplicitInclude;
1364
1374
RenderedImplicitInclude = true ;
@@ -1378,8 +1388,11 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1378
1388
FoundPCH = true ;
1379
1389
}
1380
1390
}
1391
+ // If PCH file is available, include it while performing
1392
+ // host compilation (-fsycl-is-host) in SYCL mode (-fsycl).
1393
+ // as well as in non-sycl mode.
1381
1394
1382
- if (FoundPCH) {
1395
+ if (FoundPCH && !SYCLDeviceCompilation ) {
1383
1396
if (IsFirstImplicitInclude) {
1384
1397
A->claim ();
1385
1398
CmdArgs.push_back (" -include-pch" );
@@ -1391,6 +1404,13 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
1391
1404
<< A->getAsString (Args);
1392
1405
}
1393
1406
}
1407
+ // No PCH file, but we still want to include the header file
1408
+ // (-include dummy.h) in device compilation mode.
1409
+ else if (JA.isDeviceOffloading (Action::OFK_SYCL) &&
1410
+ A->getOption ().matches (options::OPT_include_pch)) {
1411
+ continue ;
1412
+ }
1413
+
1394
1414
} else if (A->getOption ().matches (options::OPT_isystem_after)) {
1395
1415
// Handling of paths which must come late. These entries are handled by
1396
1416
// the toolchain itself after the resource dir is inserted in the right
0 commit comments