Skip to content

Commit c045995

Browse files
authored
[Driver][SYCL] Use -fsycl-footer-path for the header location (#4288)
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 69e78f8 commit c045995

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
@@ -5351,6 +5351,14 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
53515351
llvm::sys::path::stem(SrcFileName).str() + "-footer", "h");
53525352
StringRef TmpFileFooter =
53535353
C.addTempFile(C.getArgs().MakeArgString(TmpFileNameFooter));
5354+
// Use of -fsycl-footer-path puts the integration footer into that
5355+
// specified location.
5356+
if (Arg *A = C.getArgs().getLastArg(options::OPT_fsycl_footer_path_EQ)) {
5357+
SmallString<128> OutName(A->getValue());
5358+
llvm::sys::path::append(OutName,
5359+
llvm::sys::path::filename(TmpFileNameFooter));
5360+
TmpFileFooter = C.addTempFile(C.getArgs().MakeArgString(OutName));
5361+
}
53545362
addIntegrationFiles(TmpFileHeader, TmpFileFooter, SrcFileName);
53555363
}
53565364
}

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)