[compiler-rt] r316048 - Use O_BINARY when opening GCDA file on Windows
Marco Castelluccio via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 17 17:22:01 PDT 2017
Author: marco
Date: Tue Oct 17 17:22:01 2017
New Revision: 316048
URL: http://llvm.org/viewvc/llvm-project?rev=316048&view=rev
Log:
Use O_BINARY when opening GCDA file on Windows
Summary:
Fixes https://bugs.llvm.org/show_bug.cgi?id=34922.
Apparently, the mode in **fdopen** gets simply ignored and Windows only cares about the mode of the original **open**.
I have verified this both with the simple case from bug 34922 and with a full Firefox build.
Reviewers: zturner
Reviewed By: zturner
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D38984
Modified:
compiler-rt/trunk/lib/profile/GCDAProfiling.c
Modified: compiler-rt/trunk/lib/profile/GCDAProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/GCDAProfiling.c?rev=316048&r1=316047&r2=316048&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/GCDAProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/GCDAProfiling.c Tue Oct 17 17:22:01 2017
@@ -37,6 +37,9 @@
#ifndef MAP_FILE
#define MAP_FILE 0
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
#endif
#if defined(__FreeBSD__) && defined(__i386__)
@@ -238,17 +241,17 @@ void llvm_gcda_start_file(const char *or
/* Try just opening the file. */
new_file = 0;
- fd = open(filename, O_RDWR);
+ fd = open(filename, O_RDWR | O_BINARY);
if (fd == -1) {
/* Try opening the file, creating it if necessary. */
new_file = 1;
mode = "w+b";
- fd = open(filename, O_RDWR | O_CREAT, 0644);
+ fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);
if (fd == -1) {
/* Try creating the directories first then opening the file. */
__llvm_profile_recursive_mkdir(filename);
- fd = open(filename, O_RDWR | O_CREAT, 0644);
+ fd = open(filename, O_RDWR | O_CREAT | O_BINARY, 0644);
if (fd == -1) {
/* Bah! It's hopeless. */
int errnum = errno;
More information about the llvm-commits
mailing list