-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][Driver] Improve -save-temps
for SYCL mode
#4931
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
Conversation
dc12fa6
to
f1d2f4d
Compare
clang/lib/Driver/Driver.cpp
Outdated
llvm::sys::path::remove_filename(OutFileDir); | ||
// `remove_filename` will return an empty string if in CWD, patch it. | ||
if (OutFileDir.empty()) | ||
llvm::sys::path::native(OutFileDir = "./"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is my understanding that we should use the -o
information for the saved temporary files when -save-temps=obj
is used. Otherwise, the CWD
is used.
Also, since OutFileDir
is only used with IsSaveTemps
, we can move this logic there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
I kept the declaration of OutFileDir
above the loop, so it doesn't need to be re-calculated.
bf7a42b
to
698272a
Compare
clang/test/Driver/sycl-offload.c
Outdated
/// ########################################################################### | ||
/// Verify that -save-temps puts header/footer in a correct place | ||
// RUN: %clang -fsycl -fno-sycl-device-lib=all -fsycl-targets=spir64-unknown-unknown -target x86_64-unknown-linux-gnu -save-temps %s -### 2>&1 | FileCheck %s -check-prefixes=CHECK-SAVE-TEMPS-DIR | ||
// CHECK-SAVE-TEMPS-DIR: clang{{.*}} "-fsycl-int-header=./sycl-offload-header-{{[a-z0-9]*}}.h"{{.*}}"-fsycl-int-footer=./sycl-offload-footer-{{[a-z0-9]*}}.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also check behaviors with -save-temps=obj
and -o
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly enough, -save-temps=obj
with -o
containing a relative path breaks the compilation. It fails to correctly construct the output file names for sycl-post-link
job. As that is also present in main branch, I'd like to address it in a separate PR.
ca2f3ca
to
9a19200
Compare
clang/lib/Driver/Driver.cpp
Outdated
// If in `SaveTempsCwd` mode, or `remove_filename` returned an empty | ||
// string use CWD, otherwise append separator. | ||
if (OutFileDir.empty()) | ||
llvm::sys::path::native(OutFileDir = "./"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked through how other temporaries for save-temps are formulated in regards to $CWD, and there is no qualifier like ./
. The output is just the filename. Perhaps we should do the same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right, removed. Looks like the other use of ./
https://github.com/jchlanda/llvm/blob/jakub/save_temps_llvm_foreach/clang/lib/Driver/ToolChains/SYCL.cpp#L138 will have to stay, because of the way llvm-foreach
handles the OutDirectory
option.
7734610
to
e91f9d4
Compare
Is there anything else that should be done for this PR? |
save-temps
improvements-save-temps
for SYCL mode
e91f9d4
to
a9d40c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@jchlanda, please, take a look at test failures on Windows platform. |
Co-authored-by: mdtoguchi <[email protected]>
41ae583
to
1f3e9da
Compare
Make sure that
header
andfooter
files as well as the output ofllvm-foreach
(such asasm
andfatbin
for CUDA) stay in the output directory.As discussed here: #4752
I'm unsure if that is a canonical way of getting the directory, as it relies on the output file's directory (not absolute) or the current dir.