[MDEV-29308] 10.8.4 fails to build on OpenBSD Created: 2022-08-16 Updated: 2022-08-22 Resolved: 2022-08-22 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Server |
| Affects Version/s: | 10.6.9, 10.7.5, 10.8.4, 10.9.1, 10.10.1 |
| Fix Version/s: | 10.6.10, 10.7.6, 10.8.5, 10.9.3, 10.10.2 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Brad Smith | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Environment: |
OpenBSD |
||
| Issue Links: |
|
||||||||
| Description |
|
|
| Comments |
| Comment by Marko Mäkelä [ 2022-08-16 ] | |||||||||||||||||||
|
aligned_alloc() is defined in the standard ISO/IEC 9899:2011 a.k.a. C11. Because some systems do not support it yet, I implemented a compile-time check HAVE_ALIGNED_ALLOC. We do not have OpenBSD in our CI systems. Can you please check if the following patch would fix this?
| |||||||||||||||||||
| Comment by Brad Smith [ 2022-08-16 ] | |||||||||||||||||||
|
I tried that before filing the bug report and that did not help. From stdlib.h..
If I removed the #if __ISO_C_VISIBLE >= 2011 wrapper it builds. Tracking it down further I see this in sys/cdefs..
It's hitting the second part. It looks like the function would be visible if building C+17 but not C+11. | |||||||||||||||||||
| Comment by Brad Smith [ 2022-08-16 ] | |||||||||||||||||||
|
Looking at FreeBSD, NetBSD and DragonFly they all expose aligned_alloc() for C+11 by checking __cplusplus in addition to __ISO_C_VISIBLE or equivalent. So it looks like this is a header bug. | |||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-08-17 ] | |||||||||||||||||||
|
A possible work-around could be to run the following using a C++ compiler, so that we would fall back to posix_memalign().
I am not that familiar with CMake, and all checks seem to be for a C compiler. Maybe a better work-around would be to declare the function in the header file, something like this:
The 200411 would have to be replaced with the earliest OpenBSD version that introduced aligned_alloc(). Would this work? | |||||||||||||||||||
| Comment by Brad Smith [ 2022-08-19 ] | |||||||||||||||||||
|
I had to change the diff to the following..
OpenBSD is defined in sys/param.h sys/param..
| |||||||||||||||||||
| Comment by Brad Smith [ 2022-08-19 ] | |||||||||||||||||||
|
I also noticed this from the build..
But that code is being built as C99 instead of C11. | |||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-08-22 ] | |||||||||||||||||||
|
Thank you. It did not occur to me that in modern C, the language dialect decides what is available in the library. An old example: snprintf() is a C99 feature, yet it was ‘always’ available even when the compiler defaulted to the C90 dialect. As you suggested, it probably is easiest not to attempt to use aligned_alloc(), but just use posix_memalign() instead. Linux and Microsoft Windows would be unaffected by that change. Upgrading to C11 and C++17 might be an option, but it would not be trivial. |