-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[compiler-rt][profile] Use flock
shim on Windows even if detection fails
#112695
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
[compiler-rt][profile] Use flock
shim on Windows even if detection fails
#112695
Conversation
…fails This is a follow-up fix for d4efc3e, which introduced CMake-time feature test for `flock`. The feature test always fails on Windows, but we still need to use the `flock` shim provided by WindowsMMap.h regardless of the feature test result.
@glandium Would you mind testing this patch with your PGO setup again? 🙏 |
I think this change looks reasonable - the referenced commit d4efc3e is so large that it's hard to pick out all the various details that happen in there though. But it looks correct to me. |
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 we land this to unbreak coverage builds?
I can confirm it works. |
@llvm/pr-subscribers-pgo Author: Yuta Saito (kateinoigakukun) ChangesThis is a follow-up fix for d4efc3e, which introduced CMake-time feature test for Full diff: https://github.com/llvm/llvm-project/pull/112695.diff 1 Files Affected:
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c b/compiler-rt/lib/profile/InstrProfilingUtil.c
index 95ec4080ba2504..c637b9d0b893cd 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -152,7 +152,8 @@ COMPILER_RT_VISIBILITY int lprofLockFd(int fd) {
}
}
return 0;
-#elif defined(COMPILER_RT_HAS_FLOCK)
+#elif defined(COMPILER_RT_HAS_FLOCK) || defined(_WIN32)
+ // Windows doesn't have flock but WindowsMMap.h provides a shim
flock(fd, LOCK_EX);
return 0;
#else
@@ -179,7 +180,8 @@ COMPILER_RT_VISIBILITY int lprofUnlockFd(int fd) {
}
}
return 0;
-#elif defined(COMPILER_RT_HAS_FLOCK)
+#elif defined(COMPILER_RT_HAS_FLOCK) || defined(_WIN32)
+ // Windows doesn't have flock but WindowsMMap.h provides a shim
flock(fd, LOCK_UN);
return 0;
#else
|
@glandium Thank you for checking 🙏 |
This is a follow-up fix for d4efc3e, which introduced CMake-time feature test for
flock
. The feature test always fails on Windows, but we still need to use theflock
shim provided by WindowsMMap.h regardless of the feature test result.