Skip to content

Conversation

@michaeljclark
Copy link
Contributor

some changes that were required to compile mimalloc on macOS 10.13:

  • fix compiler error due to const argument to mi_atomic_load_relaxed
    • seems the address to atomic_load_relaxed should be const so perhaps this is a bug in the XCode 10.1 <stdatomic.h> header, nevertheless, a change is needed to get mimalloc to compile with this version of the XCode C library headers. an alternative fix may be to make the segment pointer non-const.
    • reference: https://en.cppreference.com/w/c/atomic/atomic_load
  • fix compiler error claimed_address is not present in malloc_zone_t until macOS 10.14
    • searched through the libmalloc versions to verify this field first appears in macOS 10.14.
  • fix compiler error aligned_alloc is not present in C on any version of macOS
    • the function appears in XcodeDefault.xctoolchain/usr/include/c++/v1/stdlib.h but not in any of the SDK /usr/include/stdlib.h headers, so one presumes it is only available in C++ on macOS.
$ clang --version
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

- error: address argument to atomic operation must be a pointer to
  non-const _Atomic type ('const _Atomic(mi_threadid_t) *' invalid)
- aligned_alloc is not present on macos. comment to suppress warning.
- claimed_address is not present until macos_10.14. add appropriate
  preprocessor guard around zone_claimed_address function and assignment.
@ghost
Copy link

ghost commented Jan 18, 2022

CLA assistant check
All CLA requirements met.

@daanx
Copy link
Collaborator

daanx commented Feb 3, 2022

Thanks @michaeljclark ! I missed this earlier and already fixed the const warning issue. Are you sure about aligned_alloc? It seems to work fine on my M1 with Big Sur. Perhaps we should wrap it in an #ifdef __cplusplus ?

Since this leaves just the claimed_address, I will fix this directly in dev if you are ok.

Thanks again!

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

Successfully merging this pull request may close these issues.

2 participants