Skip to content

Commit c23fe4b

Browse files
authored
[Driver][SYCL] Put implied src header search before user settings (#4435)
When compiling the src+footer file, perform the header search in the src directory before any user specified directories.
1 parent 00d80bd commit c23fe4b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -1432,14 +1432,11 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14321432
A->render(Args, CmdArgs);
14331433
}
14341434

1435-
Args.AddAllArgs(CmdArgs,
1436-
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1437-
options::OPT_F, options::OPT_index_header_map});
1438-
14391435
// The file being compiled that contains the integration footer is not being
14401436
// compiled in the directory of the original source. Add that directory
1441-
// as an -internal-isystem option so we can properly find potential headers
1442-
// there.
1437+
// as an -I option so we can properly find potential headers there. The
1438+
// original source search directory should also be placed before any user
1439+
// search directories.
14431440
if (ContainsAppendFooterAction(&JA)) {
14441441
SmallString<128> SourcePath(Inputs[0].getBaseInput());
14451442
llvm::sys::path::remove_filename(SourcePath);
@@ -1453,6 +1450,10 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14531450
}
14541451
}
14551452

1453+
Args.AddAllArgs(CmdArgs,
1454+
{options::OPT_D, options::OPT_U, options::OPT_I_Group,
1455+
options::OPT_F, options::OPT_index_header_map});
1456+
14561457
// Add -Wp, and -Xpreprocessor if using the preprocessor.
14571458

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// 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"{{.*}} "-I" "cmdline/dir" "-I" "[[SRCDIR]]"
6+
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-include" "dummy.h"{{.*}} "-I" "[[SRCDIR]]" "-I" "cmdline/dir"
77
// FOOTER-NOT: "-include" "[[INTHEADER]]"
88

99
/// Preprocessed file creation with integration footer

0 commit comments

Comments
 (0)