-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Support] Prevent loss of file type flags when creating temporary #167939
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
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-llvm-support Author: Tony Tao (tltao) ChangesNon-binary output files from the compiler need the I'm not sure if there's a portable way to test this, but if anyone has an idea I can add it. Full diff: https://github.com/llvm/llvm-project/pull/167939.diff 1 Files Affected:
diff --git a/llvm/lib/Support/VirtualOutputBackends.cpp b/llvm/lib/Support/VirtualOutputBackends.cpp
index de59b8ab63a53..f44cfd419f8c7 100644
--- a/llvm/lib/Support/VirtualOutputBackends.cpp
+++ b/llvm/lib/Support/VirtualOutputBackends.cpp
@@ -269,8 +269,15 @@ Error OnDiskOutputFile::tryToCreateTemporary(std::optional<int> &FD) {
return createDirectoriesOnDemand(OutputPath, Config, [&]() -> Error {
int NewFD;
SmallString<128> UniquePath;
+ sys::fs::OpenFlags OF = sys::fs::OF_None;
+ if (Config.getTextWithCRLF())
+ OF |= sys::fs::OF_TextWithCRLF;
+ else if (Config.getText())
+ OF |= sys::fs::OF_Text;
+ if (Config.getAppend())
+ OF |= sys::fs::OF_Append;
if (std::error_code EC =
- sys::fs::createUniqueFile(ModelPath, NewFD, UniquePath))
+ sys::fs::createUniqueFile(ModelPath, NewFD, UniquePath, OF))
return make_error<TempFileOutputError>(ModelPath, OutputPath, EC);
if (Config.getDiscardOnSignal())
|
abhina-sree
left a comment
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
cachemeifyoucan
left a comment
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 prefer writing a unit test and it doesn't need to be a portable test (it just needs to run on the platforms that hit this error).
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
cachemeifyoucan
left a comment
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.
|
@cachemeifyoucan There was a test failure on Windows in |
Sounds reasonable. Atomic append is not OF_Append since writing to temporary. Add a comment on this will be a plus. |
Non-binary output files from the compiler need the
OF_Textflag set for encoding conversion to be performed correctly on z/OS.I'm not sure if there's a portable way to test this, but if anyone has an idea I can add it.