Skip to content
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

error: use of undeclared identifier 'MAP_ANONYMOUS' #245

Open
ryandesign opened this issue Jul 29, 2023 · 6 comments
Open

error: use of undeclared identifier 'MAP_ANONYMOUS' #245

ryandesign opened this issue Jul 29, 2023 · 6 comments

Comments

@ryandesign
Copy link

s2 fails to build on OS X 10.10 and earlier:

https://trac.macports.org/ticket/67784

absl/debugging/internal/examine_stack.cc:58:34: error: use of undeclared identifier 'MAP_ANONYMOUS'
                   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
                                 ^
1 error generated.

MAP_ANONYMOUS is equivalent to MAP_ANON which is available on older systems.

There are several places where you already have code to address this:

// MAP_ANONYMOUS
#if defined(__APPLE__)
// For mmap, Linux defines both MAP_ANONYMOUS and MAP_ANON and says MAP_ANON is
// deprecated. In Darwin, MAP_ANON is all there is.
#if !defined MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif // !MAP_ANONYMOUS
#endif // __APPLE__

#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
#define MAP_ANONYMOUS MAP_ANON
#endif

s2/src/s2/base/port.h

Lines 574 to 581 in 4fe0c97

// MAP_ANONYMOUS
#if defined(__APPLE__)
// For mmap, Linux defines both MAP_ANONYMOUS and MAP_ANON and says MAP_ANON is
// deprecated. In Darwin, MAP_ANON is all there is.
#if !defined MAP_ANONYMOUS
#define MAP_ANONYMOUS MAP_ANON
#endif // !MAP_ANONYMOUS
#endif // __APPLE__

Note that the comment is outdated: MAP_ANONYMOUS does exist on Darwin in OS X 10.11 (released 2015) and later.

There are two places where similar code needs to be added, or it needs to be moved into a more central include file:

void* p = ::mmap(nullptr, num_bytes, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

void* altstack = mmap(nullptr, kAlternateStackSize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);

I see no reason to limit the fix to systems where __APPLE__ is defined.

@ryandesign
Copy link
Author

There are two places where similar code needs to be added

For example like this:

https://github.com/macports/macports-ports/blob/6102b5d9c70d7c21c9d20f79ce9ff65fc2b77772/R/R-s2/files/MAP_ANON.patch

@paleolimbot
Copy link
Collaborator

Thank you for reporting! We are about to update abseil and S2 to newer versions. Do you know if abseil-cpp and the latest version of google/s2geometry are able to compile on macports?

@ryandesign
Copy link
Author

I did not see this fix in the upstream abseil repository.

In MacPorts, the abseil port works around the problem by using a compatibility library developed by MacPorts which includes, among other things, the missing MAP_ANONYMOUS definition. It would be better to report the problem to the developers of abseil however so they can fix it.

@ryandesign
Copy link
Author

Build status information for abseil and s2geometry in MacPorts are here:

https://ports.macports.org/port/abseil/details/

https://ports.macports.org/port/s2geometry/details/

@ryandesign
Copy link
Author

It would be better to report the problem to the developers of abseil however so they can fix it.

abseil/abseil-cpp#1500

@ryandesign
Copy link
Author

But abseil also now uses clock_gettime which is only available in macOS 10.12 and later. I reported this to them and they will not fix it; they state abseil requires macOS 10.13 or later. For MacPorts, we have a clock_gettime implementation in our compatibility library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants