Skip to content

Commit

Permalink
[compiler-rt] Add a prefix on the windows mmap symbols (#78037)
Browse files Browse the repository at this point in the history
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
mstorsjo/llvm-mingw#390.
  • Loading branch information
mstorsjo authored Jan 19, 2024
1 parent 407db48 commit c6a6547
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions compiler-rt/lib/profile/WindowsMMap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions compiler-rt/lib/profile/WindowsMMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit c6a6547

Please sign in to comment.