зеркало из https://github.com/mozilla/gecko-dev.git
61 строка
2.0 KiB
Diff
61 строка
2.0 KiB
Diff
From 98adaa2097783c0fe3a4c948397e3f2182dcc5d2 Mon Sep 17 00:00:00 2001
|
|
From: Marco Castelluccio <mcastelluccio@mozilla.com>
|
|
Date: Wed, 18 Oct 2017 00:22:01 +0000
|
|
Subject: [PATCH] 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
|
|
|
|
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@316048 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
---
|
|
lib/profile/GCDAProfiling.c | 9 ++++++---
|
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/compiler-rt/lib/profile/GCDAProfiling.c b/compiler-rt/lib/profile/GCDAProfiling.c
|
|
index 138af6ec4..8c92546bd 100644
|
|
--- a/compiler-rt/lib/profile/GCDAProfiling.c
|
|
+++ b/compiler-rt/lib/profile/GCDAProfiling.c
|
|
@@ -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 *orig_filename, const char version[4],
|
|
|
|
/* 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;
|