pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/56186: libarchive: fix dirfd() check



>Number:         56186
>Category:       pkg
>Synopsis:       libarchive: fix dirfd() check
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue May 18 12:40:00 +0000 2021
>Originator:     Lehel Bernadt
>Release:        2021Q1
>Organization:
One Identity
>Environment:
AIX 6.1
>Description:
I was trying to build software on AIX 6.1 that pulled in archivers/libarchive, for which the linking failed with undefined symbol .dirfd. It turns out AIX 6.1 is missing some of the POSIX.2008 functionality, including the dirfd() call. This would be handled by libarchive, but the feature is misdetected by the configure script:
========================
configure:18166: gcc -c -maix64 -pthread -Wall -Wformat -Wformat-security -I/usr/pkgsrc/archivers/bsdtar/work/bzip2 -I/usr/pkgsrc/archivers/bsdtar/work/zlib conftest.c >&5
conftest.c: In function 'main':
conftest.c:174:8: warning: implicit declaration of function 'dirfd' [-Wimplicit-function-declaration]
 return(dirfd(dir));
        ^~~~~
configure:18166: $? = 0
========================

This is because configure.ac calls AC_COMPILE_IFELSE, which attempts only a compilation where the lack of declaration results in just a warning.
If I replace this with AC_LINK_IFELSE which does the linking phase as well, the detection becomes correct:
========================
configure:19228: gcc -o conftest -maix64 -pthread -Wall -Wformat -Wformat-security -I/usr/pkgsrc/archivers/bsdtar/work/bzip2 -I/usr/pkgsrc/archivers/bsdtar/work/zlib -maix64
-pthread -Wl,-bsvr4 -Wl,-bnoexpfull -L/usr/pkgsrc/archivers/bsdtar/work/bzip2 -L/usr/pkgsrc/archivers/bsdtar/work/zlib -Wl,-R/usr/pkg/lib conftest.c -lbz2 -lz  >&5
conftest.c: In function 'main':
conftest.c:186:8: warning: implicit declaration of function 'dirfd' [-Wimplicit-function-declaration]
 return(dirfd(dir));
        ^~~~~
ld: 0711-317 ERROR: Undefined symbol: .dirfd
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
configure:19228: $? = 1
========================

In CMakeLists.txt this seems to be handled correctly, as it calls CHECK_C_SOURCE_COMPILES which according to the cmake documentation compiles & links the test program.
>How-To-Repeat:

>Fix:
The patch:
=========================
diff --git a/archivers/libarchive/files/configure.ac b/archivers/libarchive/files/configure.ac
index e73985846c7..2e6d65a0ce7 100644
--- a/archivers/libarchive/files/configure.ac
+++ b/archivers/libarchive/files/configure.ac
@@ -670,7 +670,7 @@ AC_COMPILE_IFELSE(
  [AC_DEFINE(HAVE_READDIR_R,1,[Define to 1 if you have a POSIX compatible readdir_r])]
 )
 # dirfd can be either a function or a macro.
-AC_COMPILE_IFELSE(
+AC_LINK_IFELSE(
  [AC_LANG_PROGRAM([[#include <dirent.h>
                     DIR *dir;]],
                   [[return(dirfd(dir));]])],
=========================
I also needed to run autoconf to regenerate the configure script.


Home | Main Index | Thread Index | Old Index