-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ROOT does not compile on musl libc #9253
Description
I'm trying to compile ROOT v6.24/06 on Void Linux with musl libc, however the build fails with the following error message:
/builddir/root-6.24.06/core/clib/src/mmapsup.c:47:15: error: conflicting types for 'getpagesize'
47 | extern size_t getpagesize PARAMS ((void));
| ^~~~~~~~~~~
In file included from /builddir/root-6.24.06/core/clib/res/mmprivate.h:56,
from /builddir/root-6.24.06/core/clib/src/mmapsup.c:26:
/usr/include/unistd.h:163:5: note: previous declaration of 'getpagesize' was here
163 | int getpagesize(void);
| ^~~~~~~~~~~The relevant part of mmapsup.c is:
#if defined(R__LINUX) && !defined(R__GLIBC) && !defined(__CYGWIN__) \
|| (defined(__CYGWIN__) && (CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR < 213))
extern size_t getpagesize PARAMS ((void));
#else
extern int getpagesize PARAMS ((void));
#endifMy understanding is that as musl doesn't define R__GLIBC, the condition resolves in favor of declaring getpagesize return value as size_t. However, this conflicts with the declaration present in unistd.h (which is included several lines above this), which declares it as int (in accordance with the POSIX standard).
The same code snippet also causes error during core/clib/src/mvalloc.c compilation.
It's not entirely clear to me why should getpagesize be declared in the first place, as it is declared in the included unistd.h file - my guess is for some kind of compatibility, although POSIX dropped it twenty years ago and Cygwin seems to have implemented it at least four years ago, likely more, I am not sure how this works on Windows - let alone as size_t. Thus my suggestion is to remove the above code block from both of the mentioned files entirely, which seems to fix the problem for me (at least until the compilation fails on another problem, which I haven't analyzed yet; and I'm still able to compile for glibc too) and my question is: would it break anything crucial (as I mentioned, getpagesize has been deprecated for more than twenty years now (at least on UNIX-like systems), so keeping support for some potentially obscure platforms which still expect it with size_t return value may not be of high importance (but again, I do not know what the situation is on Windows))? And if so, what is the right way to solve this?
Here's a link to a ROOT forum thread which describes the same problem (but does not provide any more information than is stated above).