[compiler-rt] c6a6547 - [compiler-rt] Add a prefix on the windows mmap symbols (#78037)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 19 00:01:33 PST 2024
Author: Martin Storsjö
Date: 2024-01-19T10:01:29+02:00
New Revision: c6a6547798ca641b985456997cdf986bb99b0707
URL: https://github.com/llvm/llvm-project/commit/c6a6547798ca641b985456997cdf986bb99b0707
DIFF: https://github.com/llvm/llvm-project/commit/c6a6547798ca641b985456997cdf986bb99b0707.diff
LOG: [compiler-rt] Add a prefix on the windows mmap symbols (#78037)
For Windows, the compiler-rt profile library contains a polyfill
reimplementation of the mmap family of functions.
Previously, the runtime library exposed those symbols like, "mmap", in
the user symbol namespace. This could cause misdetections by configure
scripts that check for the "mmap" function just by linking, without
including headers.
Add a prefix on the symbols, and make an undeclared function static.
This fixes such an issue reported at
https://github.com/mstorsjo/llvm-mingw/issues/390.
Added:
Modified:
compiler-rt/lib/profile/WindowsMMap.c
compiler-rt/lib/profile/WindowsMMap.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/WindowsMMap.c b/compiler-rt/lib/profile/WindowsMMap.c
index 07c0a689feaeae0..9d7da835b1ed381 100644
--- a/compiler-rt/lib/profile/WindowsMMap.c
+++ b/compiler-rt/lib/profile/WindowsMMap.c
@@ -124,8 +124,7 @@ int madvise(void *addr, size_t length, int advice)
return 0;
}
-COMPILER_RT_VISIBILITY
-int lock(HANDLE handle, DWORD lockType, BOOL blocking) {
+static int lock(HANDLE handle, DWORD lockType, BOOL blocking) {
DWORD flags = lockType;
if (!blocking)
flags |= LOCKFILE_FAIL_IMMEDIATELY;
diff --git a/compiler-rt/lib/profile/WindowsMMap.h b/compiler-rt/lib/profile/WindowsMMap.h
index 68b8de2398d6068..1df1a0be0b02bd8 100644
--- a/compiler-rt/lib/profile/WindowsMMap.h
+++ b/compiler-rt/lib/profile/WindowsMMap.h
@@ -60,6 +60,12 @@
# define DWORD_LO(x) (x)
#endif
+#define mmap __llvm_profile_mmap
+#define munmap __llvm_profile_munmap
+#define msync __llvm_profile_msync
+#define madvise __llvm_profile_madvise
+#define flock __llvm_profile_flock
+
void *mmap(void *start, size_t length, int prot, int flags, int fd,
off_t offset);
More information about the llvm-commits
mailing list