Skip to content

Commit cf1e717

Browse files
authored
[Driver][SYCL] Restrict user -include file in final integration footer step (#4036)
When compiling with the integration footer, the host side of the compile is performed twice. Once for the preprocessing and again with a full file containing the integration footer. For any user -include file.h files, we only want to include that during the preprocessing step and not with the subsequent compile.
1 parent 14cdb5a commit cf1e717

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,11 @@ void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
14161416
<< A->getAsString(Args);
14171417
}
14181418
}
1419+
// Do not render -include when performing the compilation that occurs
1420+
// after the the integration footer has been appended. This has already
1421+
// been preprocessed and should not be included again.
1422+
if (ContainsAppendFooterAction(&JA))
1423+
continue;
14191424
} else if (A->getOption().matches(options::OPT_isystem_after)) {
14201425
// Handling of paths which must come late. These entries are handled by
14211426
// the toolchain itself after the resource dir is inserted in the right

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
/// Check compilation tool steps when using the integration footer
2-
// RUN: %clangxx -fsycl %s -### 2>&1 \
2+
// RUN: %clangxx -fsycl -include dummy.h %s -### 2>&1 \
33
// RUN: | FileCheck -check-prefix FOOTER %s
4-
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"
5-
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-E"{{.*}} "-C"{{.*}} "-o" "[[PREPROC:.+\.ii]]"
4+
// FOOTER: clang{{.*}} "-fsycl-is-device"{{.*}} "-fsycl-int-header=[[INTHEADER:.+\.h]]" "-fsycl-int-footer=[[INTFOOTER:.+\h]]" "-sycl-std={{.*}}"{{.*}} "-include" "dummy.h"
5+
// FOOTER: clang{{.*}} "-include" "[[INTHEADER]]"{{.*}} "-fsycl-is-host"{{.*}} "-E"{{.*}} "-C"{{.*}} "-include" "dummy.h"{{.*}} "-o" "[[PREPROC:.+\.ii]]"
66
// FOOTER: append-file{{.*}} "[[PREPROC]]" "--append=[[INTFOOTER]]" "--output=[[APPENDEDSRC:.+\.cpp]]"
77
// FOOTER: clang{{.*}} "-fsycl-is-host"{{.*}} "[[APPENDEDSRC]]"
88
// FOOTER-NOT: "-include" "[[INTHEADER]]"
99

10+
// RUN: %clangxx -fsycl -include dummy.h %s -### 2>&1 \
11+
// RUN: | FileCheck -check-prefix FOOTER_NO_HEADER %s
12+
// FOOTER_NO_HEADER: append-file{{.*}}
13+
// FOOTER_NO_HEADER-NOT: clang{{.*}} "-include" "dummy.h"
14+
1015
/// Preprocessed file creation with integration footer
1116
// RUN: %clangxx -fsycl -E %s -### 2>&1 \
1217
// RUN: | FileCheck -check-prefix FOOTER_PREPROC_GEN %s

0 commit comments

Comments
 (0)