Skip to content

Commit df59242

Browse files
committed
[Driver][SYCL] Use -fsycl-footer-path for the header location
When the user specifies -fsycl-footer-path, not only use the location for the source + footer file, but also generate the integration footer there.
1 parent d8237a6 commit df59242

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5366,6 +5366,14 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
53665366
llvm::sys::path::stem(SrcFileName).str() + "-footer", "h");
53675367
StringRef TmpFileFooter =
53685368
C.addTempFile(C.getArgs().MakeArgString(TmpFileNameFooter));
5369+
// Use of -fsycl-footer-path puts the integration footer into that
5370+
// specified location.
5371+
if (Arg *A = C.getArgs().getLastArg(options::OPT_fsycl_footer_path_EQ)) {
5372+
SmallString<128> OutName(A->getValue());
5373+
llvm::sys::path::append(OutName,
5374+
llvm::sys::path::filename(TmpFileNameFooter));
5375+
TmpFileFooter = C.addTempFile(C.getArgs().MakeArgString(OutName));
5376+
}
53695377
addIntegrationFiles(TmpFileHeader, TmpFileFooter, SrcFileName);
53705378
}
53715379
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@
6464
/// Test for -fsycl-footer-path=<dir>
6565
// RUN: %clangxx -fsycl -fsycl-footer-path=dummy_dir %s -### 2>&1 \
6666
// RUN: | FileCheck -check-prefix FOOTER_PATH %s
67-
// FOOTER_PATH: append-file{{.*}} "--output=dummy_dir{{(/|\\\\)}}[[APPENDEDSRC:.+\.cpp]]"
67+
// FOOTER_PATH: append-file{{.*}} "--append=dummy_dir{{(/|\\\\)}}{{.*}}-footer-{{.*}}.h"
68+
// FOOTER_PATH-SAME: "--output=dummy_dir{{(/|\\\\)}}[[APPENDEDSRC:.+\.cpp]]"
6869
// FOOTER_PATH: clang{{.*}} "-x" "c++" "dummy_dir{{(/|\\\\)}}[[APPENDEDSRC]]"

0 commit comments

Comments
 (0)