Error compiling gallium-nine on i686 using musl libc
When compiling Mesa 21.1.6 on i686 using the musl libc following error occurs:
FAILED: src/gallium/frontends/nine/libnine_st.a.p/nine_memory_helper.c.o
...
In file included from ../src/util/u_debug.h:50,
from ../src/util/u_memory.h:37,
from ../src/gallium/frontends/nine/nine_memory_helper.c:97:
../src/gallium/frontends/nine/nine_memory_helper.c: In function 'nine_allocator_create':
../src/gallium/frontends/nine/nine_memory_helper.c:1012:78: error: '__UL_GETOPENMAX' undeclared (first use in this function)
1012 | allocator->num_fd_max = (memfd_virtualsizelimit >= 0) ? MIN2(128, ulimit(__UL_GETOPENMAX)) : 0;
| ^~~~~~~~~~~~~~~
__UL_GETOPENMAX
seems to be glibc specific and not portable. In glibc’s sysdeps/posix/ulimit.c
it is assigned the return value of sysconf(_SC_OPEN_MAX)
. So with the following change
--- a/src/gallium/frontends/nine/nine_memory_helper.c 2021-07-28 23:13:29.332792300 +0200
+++ b/src/gallium/frontends/nine/nine_memory_helper.c 2021-08-03 08:15:30.354344672 +0200
@@ -1009,7 +1009,7 @@
allocator->device = device;
allocator->page_size = sysconf(_SC_PAGESIZE);
assert(allocator->page_size == 4 << 10);
- allocator->num_fd_max = (memfd_virtualsizelimit >= 0) ? MIN2(128, ulimit(__UL_GETOPENMAX)) : 0;
+ allocator->num_fd_max = (memfd_virtualsizelimit >= 0) ? MIN2(128, sysconf(_SC_OPEN_MAX)) : 0;
allocator->min_file_size = DIVUP(100 * (1 << 20), allocator->page_size) * allocator->page_size; /* 100MB files */
allocator->total_allocations = 0;
allocator->total_locked_memory = 0;
compilation succeeds.
Is there a particular reason why ulimit(__UL_GETOPENMAX)
is used? If not, would it be possible to replace the ulimit
call with the sysconf
call; which btw is used two lines above to get the page size.
Thank you!