Skip to content

Commit e5e6a7f

Browse files
authored
[Driver][SYCL] Update header inclusion for source + footer (#4241)
Instead of using -internal-isystem for the source location header inclusion, use -I as a user header, but be sure it is placed after user defined -I locations.
1 parent ab5e7b0 commit e5e6a7f

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14181418
A->render(Args, CmdArgs);
14191419
}
14201420

1421+
Args.AddAllArgs(CmdArgs,
1422+
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1423+
options::OPT_F, options::OPT_index_header_map});
1424+
14211425
// The file being compiled that contains the integration footer is not being
14221426
// compiled in the directory of the original source. Add that directory
14231427
// as an -internal-isystem option so we can properly find potential headers
@@ -1426,19 +1430,15 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14261430
SmallString<128> SourcePath(Inputs[0].getBaseInput());
14271431
llvm::sys::path::remove_filename(SourcePath);
14281432
if (!SourcePath.empty()) {
1429-
CmdArgs.push_back("-internal-isystem");
1433+
CmdArgs.push_back("-I");
14301434
CmdArgs.push_back(Args.MakeArgString(SourcePath));
14311435
} else if (llvm::ErrorOr<std::string> CWD =
14321436
D.getVFS().getCurrentWorkingDirectory()) {
1433-
CmdArgs.push_back("-internal-isystem");
1437+
CmdArgs.push_back("-I");
14341438
CmdArgs.push_back(Args.MakeArgString(*CWD));
14351439
}
14361440
}
14371441

1438-
Args.AddAllArgs(CmdArgs,
1439-
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1440-
options::OPT_F, options::OPT_index_header_map});
1441-
14421442
// Add -Wp, and -Xpreprocessor if using the preprocessor.
14431443

14441444
// FIXME: There is a very unfortunate problem here, some troubled

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/// Check compilation tool steps when using the integration footer
2-
// RUN: %clangxx -fsycl -include dummy.h %/s -### 2>&1 \
3-
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S
2+
// RUN: %clangxx -fsycl -I cmdline/dir -include dummy.h %/s -### 2>&1 \
3+
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir
44
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h"
55
// FOOTER: append-file{{.*}} "[[INPUTFILE:.+\.cpp]]" "--append=[[INTFOOTER]]" "--orig-filename=[[INPUTFILE]]" "--output=[[APPENDEDSRC:.+\.cpp]]"
6-
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-internal-isystem" "[[SRCDIR]]"
6+
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" "-I" "[[SRCDIR]]"
77
// FOOTER-NOT: "-include" "[[INTHEADER]]"
88

99
/// Preprocessed file creation with integration footer

0 commit comments

Comments
 (0)