Skip to content

Build Failure Due to Undefined Reference to close_range with alsa-lib 1.2.15 #485

@darkshram

Description

@darkshram

Description

I encountered a build failure while compiling alsa-lib 1.2.15 due to an undefined reference to close_range. My environment uses glibc 2.30, which should support this function.

Error Message

ucm/.libs/libucm.a(ucm_exec.o): In function `uc_mgr_exec':
/builddir/build/BUILD/alsa-lib-1.2.15/src/ucm/ucm_exec.c:263: undefined reference to `close_range'
collect2: error: ld returned 1 exit status

Solution

To resolve the issue, I applied the following patch, which effectively reverses the change that introduced close_range:

diff -Naur alsa-lib-1.2.15.orig/src/ucm/ucm_exec.c alsa-lib-1.2.15/src/ucm/ucm_exec.c
--- alsa-lib-1.2.15.orig/src/ucm/ucm_exec.c     2025-12-07 13:41:56.000000000 -0600
+++ alsa-lib-1.2.15/src/ucm/ucm_exec.c  2025-12-08 15:03:30.632324127 -0600
@@ -259,12 +259,8 @@
                close(f);

-#if defined(_GNU_SOURCE)
-               close_range(3, maxfd, 0);
-#else
                for (f = 3; f < maxfd; f++)
                        close(f);
-#endif

                /* install default handlers for the forked process */
                signal(SIGINT, SIG_DFL);

This workaround restored compatibility and allowed the build to complete successfully.

Additional Information

Please consider this issue for further review. If close_range is required, clearer compatibility notes might be beneficial. Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions