Skip to content

Commit 2b88867

Browse files
authored
[Driver][SYCL] Move include/sycl header before other system header locations (#1492)
The location in which the include/sycl headers are added are too late in the ordering sequence. This is causing the possibility of the wrong version of the OpenCL headers to be picked up (i.e. from /usr/include) Improve the ordering by putting the dirs much earlier in the command line instead of relying on the ToolChain addition. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 4d34c9b commit 2b88867

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,9 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
12171217
if (JA.isOffloading(Action::OFK_Cuda))
12181218
getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
12191219

1220-
if (Args.hasArg(options::OPT_fsycl_device_only)) {
1220+
if (JA.isOffloading(Action::OFK_SYCL) ||
1221+
Args.hasArg(options::OPT_fsycl_device_only))
12211222
toolchains::SYCLToolChain::AddSYCLIncludeArgs(D, Args, CmdArgs);
1222-
}
12231223

12241224
// If we are offloading to a target via OpenMP we need to include the
12251225
// openmp_wrappers folder which contains alternative system headers.

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,6 @@ void SYCLToolChain::AddSYCLIncludeArgs(const clang::driver::Driver &Driver,
545545

546546
void SYCLToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
547547
ArgStringList &CC1Args) const {
548-
AddSYCLIncludeArgs(getDriver(), DriverArgs, CC1Args);
549548
HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
550549
}
551550

clang/test/Driver/sycl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
// COMBINED: "-triple" "spir64-unknown-{{.*}}-sycldevice"{{.*}} "-fsycl-is-device"{{.*}} "-emit-llvm-bc"
5050
// TEXTUAL: "-triple" "spir64-unknown-{{.*}}-sycldevice{{.*}}" "-fsycl-is-device"{{.*}} "-emit-llvm"
5151

52+
/// Verify that the sycl header directory is before /usr/include
53+
// RUN: %clangxx -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=HEADER_ORDER
54+
// RUN: %clangxx -### -fsycl %s 2>&1 | FileCheck %s --check-prefix=HEADER_ORDER
55+
// HEADER_ORDER-NOT: clang{{.*}} "/usr/include"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}
56+
5257
/// Verify -fsycl-device-only phases
5358
// RUN: %clang -### -ccc-print-phases -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT-PHASES
5459
// DEFAULT-PHASES: 0: input, "{{.*}}", c

0 commit comments

Comments
 (0)