[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.
This commit is contained in:
Martin Storsjö 2024-01-19 10:01:29 +02:00 committed by GitHub
parent 407db48eb4
commit c6a6547798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 2 deletions

View File

@ -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;

View File

@ -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);