WebAssembly / wabt

The WebAssembly Binary Toolkit
Apache License 2.0
6.86k stars 699 forks source link

MAP_ANONYMOUS undefined on OS X 10.10 and earlier (pre-2015) #1620

Closed jakirkham closed 1 year ago

jakirkham commented 3 years ago

Seeing the following error when compiling macOS. It appears the MAP_ANONYMOUS flag may not be defined, but perhaps MAP_ANON would be a good substitute

../wasm2c/wasm-rt-impl.c:133:58: error: use of undeclared identifier 'MAP_ANONYMOUS'
      mmap(NULL, 0x200000000ul, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
                                                         ^
1 error generated.
jakirkham commented 3 years ago

Any thoughts on this issue?

jakirkham commented 3 years ago

Sorry to keep bumping this. We are unable to build on macOS ever since this issue surfaced. Any help here would be appreciated :)

lars-t-hansen commented 3 years ago

FWIW, a workaround used elsewhere: https://searchfox.org/mozilla-central/source/toolkit/crashreporter/google-breakpad/src/common/memory_allocator.h#45

sbc100 commented 3 years ago

Looks like an easy fix. I'm confused why this isn't causing a built failure during CI. I will take a look.

sbc100 commented 3 years ago

Odd .. I can see wasm-rt-impl.c being compiled just fine by the github CI https://github.com/WebAssembly/wabt/runs/3257150141#step:10:18.

keithw commented 2 years ago

Closing as dormant and "works in CI." Please reopen or comment if somebody is still having trouble here.

jakirkham commented 2 years ago

This issue is still present. Please reopen.

Here's a recent build log demonstrating the issue when our downstream patch is removed ( https://github.com/conda-forge/wabt-feedstock/pull/25/commits/65ee0ea7a631051f4e829c9dbb8c5578f5a63a82 ).

All it would take for one to fix it would be to define MAP_ANON with MAP_ANONYMOUS if only the latter is defined.

keithw commented 2 years ago

Ok, reopening and did some Googling.

It looks like MacOS added MAP_ANONYMOUS in 2015 (with the release of El Capitan 10.11). The problem here looks to be that the linked build log is compiling with the SDK for Mac OS 10.9, released in 2013 and no longer supported.

If you'd like to submit a PR to add support for Mac OS <10.11, I'm happy to take a look, but it's going to be hard for us to get test coverage/CI there. Other options probably include (a) compiling on a more recent version of MacOS, (b) keeping a local patch, or (c) disabling the build of wasm-rt-impl. (It's an example runtime meant to show how to embed wasm2c output in a POSIX-like environment; wabt uses it for running the wasm2c tests but that's it. Arguably wabt should only build it when running the wasm2c tests...)

keithw commented 1 year ago

Closing as dormant/unresponded-to. We would still take a PR on this.