Skip to content

[Driver][SYCL] Update header inclusion for source + footer #4241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,6 +1418,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
A->render(Args, CmdArgs);
}

Args.AddAllArgs(CmdArgs,
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
options::OPT_F, options::OPT_index_header_map});

// The file being compiled that contains the integration footer is not being
// compiled in the directory of the original source. Add that directory
// as an -internal-isystem option so we can properly find potential headers
Expand All @@ -1426,19 +1430,15 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
SmallString<128> SourcePath(Inputs[0].getBaseInput());
llvm::sys::path::remove_filename(SourcePath);
if (!SourcePath.empty()) {
CmdArgs.push_back("-internal-isystem");
CmdArgs.push_back("-I");
CmdArgs.push_back(Args.MakeArgString(SourcePath));
} else if (llvm::ErrorOr<std::string> CWD =
D.getVFS().getCurrentWorkingDirectory()) {
CmdArgs.push_back("-internal-isystem");
CmdArgs.push_back("-I");
CmdArgs.push_back(Args.MakeArgString(*CWD));
}
}

Args.AddAllArgs(CmdArgs,
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
options::OPT_F, options::OPT_index_header_map});

// Add -Wp, and -Xpreprocessor if using the preprocessor.

// FIXME: There is a very unfortunate problem here, some troubled
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Driver/sycl-int-footer.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// Check compilation tool steps when using the integration footer
// RUN: %clangxx -fsycl -include dummy.h %/s -### 2>&1 \
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S
// RUN: %clangxx -fsycl -I cmdline/dir -include dummy.h %/s -### 2>&1 \
// RUN: | FileCheck -check-prefix FOOTER %s -DSRCDIR=%/S -DCMDDIR=cmdline/dir
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h"
// FOOTER: append-file{{.*}} "[[INPUTFILE:.+\.cpp]]" "--append=[[INTFOOTER]]" "--orig-filename=[[INPUTFILE]]" "--output=[[APPENDEDSRC:.+\.cpp]]"
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-internal-isystem" "[[SRCDIR]]"
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "cmdline/dir" "-I" "[[SRCDIR]]"
// FOOTER-NOT: "-include" "[[INTHEADER]]"

/// Preprocessed file creation with integration footer
Expand Down