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: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer #1066

Open
ryandesign opened this issue Nov 20, 2024 · 7 comments

Comments

@ryandesign
Copy link

openal-soft 1.24.0 doesn't build on macOS 10.12:

common/almalloc.h:78:46: error: aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer
   78 |         return static_cast<gsl::owner<T*>>(::operator new[](n*sizeof(T), AlignVal));
      |                                              ^
common/almalloc.h:78:46: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic
common/almalloc.h:81:9: error: aligned deallocation function of type 'void (void *, std::align_val_t) noexcept' is only available on macOS 10.13 or newer
   81 |     { ::operator delete[](gsl::owner<void*>{p}, AlignVal); }
      |         ^
common/almalloc.h:81:9: note: if you supply your own aligned allocation functions, use -faligned-allocation to silence this diagnostic

Full build log: https://build.macports.org/builders/ports-10.12_x86_64-builder/builds/291362/steps/install-port/logs/stdio

It builds on macOS 12 and later.

This is a regression; 1.23.1 didn't have this problem.

@kcat
Copy link
Owner

kcat commented Nov 23, 2024

OpenAL Soft 1.24 relies on C++17. Even if those specific errors were fixed, various other structs rely on the over-alignment allocators being invoked when creating objects that have higher alignment needs. If they silently use the normal allocators without the necessary alignment, it can result in random crashes or other buggy behavior. I don't relish the idea of adding back the custom malloc functions and sprinkling in custom alignment new/delete methods, when it's been part of the standard for over 7 years.

You can try using a newer compiler and static-linking the C++ runtime to avoid relying on the system having a newer libc++, but C++17 is needed for compiling.

@barracuda156
Copy link
Contributor

@kcat This issue is probably unrelated to C++ standard.

@barracuda156
Copy link
Contributor

@ryandesign FWIW, there is no error on 10.6 with gcc. So this looks like Apple libc++ bug.

@kcat
Copy link
Owner

kcat commented Dec 11, 2024

@ryandesign FWIW, there is no error on 10.6 with gcc. So this looks like Apple libc++ bug.

The issue is as the error says:

aligned allocation function of type 'void *(std::size_t, std::align_val_t)' is only available on macOS 10.13 or newer

macOS 10.12 was released on September 20, 2016, while macOS 10.13 was released on September 25, 2017, so it'd make sense that 10.13 may be needed for more complete C++17 support.

@barracuda156
Copy link
Contributor

@kcat The error text is actually misleading, since here C++ runtime matters and not the macOS version. (I assumed initially that the code may use aligned_alloc, which is dependent on macOS version, but it is not the case, as it turned out.)

@kcat
Copy link
Owner

kcat commented Dec 11, 2024

The error text is actually misleading, since here C++ runtime matters and not the macOS version.

Is there a way for users to upgrade the C++ runtime on their system (and developers to upgrade the compiler/system SDK) to a more modern version, without updating macOS to 10.13? I assume 10.12 has a compiler and C++ runtime that doesn't support it, while 10.13 does. If there's no way to upgrade the C++ runtime to a sufficiently compatible version, then the runtime and macOS versions are linked.

@barracuda156
Copy link
Contributor

Is there a way for users to upgrade the C++ runtime on their system to a more modern version, without updating macOS to 10.13?

@kcat Yes, of course, there is nothing preventing someone from using a modern C++ runtime. As I notice above, everything works fine on my 10.6 (from 2008), which uses a modern libstdc++.

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

3 participants