commit:     ca8f5295e68bfa0d1dec448584a0bc887820fe12
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 24 14:19:45 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Dec 24 14:21:16 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ca8f5295

dev-libs/apr: fix autoconf vs new glibc

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/apr/apr-1.7.6-r1.ebuild            | 163 +++++++++++++++++++++++
 dev-libs/apr/files/apr-1.7.6-autoconf.patch | 199 ++++++++++++++++++++++++++++
 2 files changed, 362 insertions(+)

diff --git a/dev-libs/apr/apr-1.7.6-r1.ebuild b/dev-libs/apr/apr-1.7.6-r1.ebuild
new file mode 100644
index 000000000000..a0ccfa3978fa
--- /dev/null
+++ b/dev-libs/apr/apr-1.7.6-r1.ebuild
@@ -0,0 +1,163 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools flag-o-matic toolchain-funcs
+
+DESCRIPTION="Apache Portable Runtime Library"
+HOMEPAGE="https://apr.apache.org/";
+SRC_URI="mirror://apache/apr/${P}.tar.bz2"
+
+LICENSE="Apache-2.0"
+SLOT="1/${PV%.*}"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86 ~x64-macos ~x64-solaris"
+IUSE="doc old-kernel selinux static-libs +urandom valgrind"
+
+# See bug #815265 for libcrypt dependency
+DEPEND="
+       virtual/libcrypt:=
+       elibc_glibc? ( >=sys-apps/util-linux-2.16 )
+"
+RDEPEND="
+       ${DEPEND}
+       selinux? ( sec-policy/selinux-base-policy )
+"
+DEPEND+=" valgrind? ( dev-debug/valgrind )"
+BDEPEND="
+       >=dev-build/libtool-2.4.2
+       doc? ( app-text/doxygen )
+"
+
+DOCS=( CHANGES NOTICE README )
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-1.6.3-skip-known-failing-tests.patch
+       "${FILESDIR}"/${PN}-1.7.2-libtool.patch
+       "${FILESDIR}"/${PN}-1.7.2-fix-pkgconfig-libs.patch
+       "${FILESDIR}"/${PN}-1.7.2-respect-flags.patch
+       "${FILESDIR}"/${PN}-1.7.4-config-cross.patch
+       "${FILESDIR}"/${PN}-1.7.4-config-libdir.patch
+       "${FILESDIR}"/config.layout.patch
+       "${FILESDIR}"/${PN}-1.7.6-autoconf.patch
+)
+
+src_prepare() {
+       default
+
+       mv configure.in configure.ac || die
+       AT_M4DIR="build" eautoreconf
+}
+
+src_configure() {
+       tc-export AS CC CPP
+
+       # the libtool script uses bash code in it and at configure time, tries
+       # to find a bash shell.  if /bin/sh is bash, it uses that.  this can
+       # cause problems for people who switch /bin/sh on the fly to other
+       # shells, so just force libtool to use /bin/bash all the time.
+       export CONFIG_SHELL="${EPREFIX}"/bin/bash
+       export ac_cv_path_SED="sed"
+       export ac_cv_path_EGREP="grep -E"
+       export ac_cv_path_EGREP_TRADITIONAL="grep -E"
+       export ac_cv_path_FGREP="grep -F"
+       export ac_cv_path_GREP="grep"
+       export ac_cv_path_lt_DD="dd"
+
+       local myconf=(
+               --enable-layout=gentoo
+               --enable-nonportable-atomics
+               --enable-posix-shm
+               --enable-threads
+               $(use_enable static-libs static)
+               $(use_with valgrind)
+               --with-installbuilddir="${EPREFIX}"/usr/share/${PN}/build
+       )
+
+       tc-is-static-only && myconf+=( --disable-dso )
+
+       if use old-kernel; then
+               local apr_cv_accept4 apr_cv_dup3 apr_cv_epoll_create1 
apr_cv_sock_cloexec
+               export apr_cv_accept4="no"
+               export apr_cv_dup3="no"
+               export apr_cv_epoll_create1="no"
+               export apr_cv_sock_cloexec="no"
+       fi
+
+       if tc-is-cross-compiler; then
+               # The apache project relies heavily on AC_TRY_RUN and doesn't
+               # have any sane cross-compiling fallback logic.
+               export \
+                       ac_cv_file__dev_zero="yes" \
+                       ac_cv_func_sem_open="yes" \
+                       ac_cv_mmap__dev_zero="yes" \
+                       ac_cv_negative_eai="yes" \
+                       ac_cv_o_nonblock_inherited="no" \
+                       ac_cv_struct_rlimit="yes" \
+                       ap_cv_atomic_builtins="yes" \
+                       apr_cv_accept4="yes" \
+                       apr_cv_dup3="yes" \
+                       apr_cv_epoll="yes" \
+                       apr_cv_epoll_create1="yes" \
+                       apr_cv_gai_addrconfig="yes" \
+                       apr_cv_mutex_recursive="yes" \
+                       apr_cv_mutex_robust_shared="yes" \
+                       apr_cv_process_shared_works="yes" \
+                       apr_cv_pthreads_lib="-pthread" \
+                       apr_cv_sock_cloexec="yes" \
+                       apr_cv_tcp_nodelay_with_cork="yes"
+       fi
+
+       if use urandom; then
+               myconf+=( --with-devrandom=/dev/urandom )
+       else
+               myconf+=( --with-devrandom=/dev/random )
+       fi
+
+       # Avoid libapr containing undefined references (underlinked)
+       # undefined reference to `__sync_val_compare_and_swap_8'
+       # (May be possible to fix via libatomic linkage in future?)
+       # bug #740464
+       append-atomic-flags
+       if use x86 || [[ ${LIBS} == *atomic* ]] ; then
+               myconf+=( --disable-nonportable-atomics )
+       fi
+
+       econf "${myconf[@]}"
+}
+
+src_compile() {
+       if tc-is-cross-compiler; then
+               # This header is the same across targets, so use the build 
compiler.
+               emake tools/gen_test_char
+
+               tc-export_build_env BUILD_CC
+               ${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_CPPFLAGS} ${BUILD_LDFLAGS} \
+                       tools/gen_test_char.c -o tools/gen_test_char || die
+       fi
+
+       emake all $(usev doc dox)
+}
+
+src_test() {
+       # Building tests in parallel is broken
+       emake -j1 check
+}
+
+src_install() {
+       default
+
+       if ! use static-libs; then
+               find "${ED}" -name '*.la' -delete || die
+       fi
+
+       if use doc; then
+               docinto html
+               dodoc -r docs/dox/html/*
+       fi
+
+       # This file is only used on AIX systems, which Gentoo is not,
+       # and causes collisions between the SLOTs, so remove it.
+       # Even in Prefix, we don't need this on AIX.
+       rm "${ED}/usr/$(get_libdir)/apr.exp" || die
+}

diff --git a/dev-libs/apr/files/apr-1.7.6-autoconf.patch 
b/dev-libs/apr/files/apr-1.7.6-autoconf.patch
new file mode 100644
index 000000000000..014839537ca3
--- /dev/null
+++ b/dev-libs/apr/files/apr-1.7.6-autoconf.patch
@@ -0,0 +1,199 @@
+https://src.fedoraproject.org/rpms/apr/blob/rawhide/f/apr-1.7.6-autoconf.patch
+https://github.com/apache/apr/pull/68
+--- apr-1.7.6/build/apr_common.m4.5
++++ apr-1.7.6/build/apr_common.m4
+@@ -467,19 +467,11 @@
+    CFLAGS="$CFLAGS -Werror"
+  fi
+  AC_COMPILE_IFELSE(
+-  [AC_LANG_SOURCE(
+-   [
+-#ifndef PACKAGE_NAME
+-#include "confdefs.h"
+-#endif
+-   ]
+-   [[$1]]
+-   [int main(int argc, const char *const *argv) {]
+-   [[$2]]
+-   [   return 0; }]
+-  )], [CFLAGS=$apr_save_CFLAGS
+-$3],  [CFLAGS=$apr_save_CFLAGS
+-$4])
++  [AC_LANG_PROGRAM([[$1]], [[$2]])],
++  [CFLAGS=$apr_save_CFLAGS
++   $3],
++  [CFLAGS=$apr_save_CFLAGS
++   $4])
+ ])
+ 
+ dnl
+--- apr-1.7.6/build/apr_network.m4.5
++++ apr-1.7.6/build/apr_network.m4
+@@ -259,11 +259,12 @@
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
++#include <stdio.h>
+ ],[
+ int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, 
+                           (char *) 0, 0, (struct hostent **) 0, &tmp);
+ /* use tmp to suppress the warning */
+-tmp=0;
++puts(tmp ? "non-zero" : "zero");
+ ], ac_cv_gethostbyname_r_style=glibc2, ac_cv_gethostbyname_r_style=none))
+ 
+ if test "$ac_cv_gethostbyname_r_style" = "glibc2"; then
+@@ -287,11 +288,12 @@
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
++#include <stdio.h>
+ ],[
+ int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, 
+                           (struct hostent_data *) 0);
+ /* use tmp to suppress the warning */
+-tmp=0;
++puts(tmp ? "non-zero" : "zero");
+ ], ac_cv_gethostbyname_r_arg=hostent_data, ac_cv_gethostbyname_r_arg=char))
+ 
+ if test "$ac_cv_gethostbyname_r_arg" = "hostent_data"; then
+@@ -327,12 +329,13 @@
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
++#include <stdio.h>
+ ],[
+ int tmp = getservbyname_r((const char *) 0, (const char *) 0,
+                           (struct servent *) 0, (char *) 0, 0,
+                           (struct servent **) 0);
+ /* use tmp to suppress the warning */
+-tmp=0;
++puts(tmp ? "non-zero" : "zero");
+ ], ac_cv_getservbyname_r_style=glibc2, ac_cv_getservbyname_r_style=none)
+ 
+ if test "$ac_cv_getservbyname_r_style" = "none"; then
+@@ -354,11 +357,12 @@
+     #ifdef HAVE_STDLIB_H
+     #include <stdlib.h>
+     #endif
++    #include <stdio.h>
+     ],[
+     struct servent *tmp = getservbyname_r((const char *) 0, (const char *) 0,
+                                           (struct servent *) 0, (char *) 0, 
0);
+     /* use tmp to suppress the warning */
+-    tmp=NULL;
++    puts(tmp ? "non-zero" : "zero");
+     ], ac_cv_getservbyname_r_style=solaris, ac_cv_getservbyname_r_style=none)
+ fi
+ 
+@@ -381,11 +385,12 @@
+     #ifdef HAVE_STDLIB_H
+     #include <stdlib.h>
+     #endif
++    #include <stdio.h>
+     ],[
+     int tmp = getservbyname_r((const char *) 0, (const char *) 0,
+                               (struct servent *) 0, (struct servent_data *) 
0);
+     /* use tmp to suppress the warning */
+-    tmp=0;
++    puts(tmp ? "non-zero" : "zero");
+     ], ac_cv_getservbyname_r_style=osf1, ac_cv_getservbyname_r_style=none)
+ fi
+ ])
+--- apr-1.7.6/build/buildcheck.sh.5
++++ apr-1.7.6/build/buildcheck.sh
+@@ -15,11 +15,11 @@
+   echo "buildconf: python version $py_version (ok)"
+ fi
+ 
+-# autoconf 2.59 or newer
++# autoconf 2.61 or newer
+ ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 
's/^[^0-9]*//;s/[a-z]* *$//;q'`
+ if test -z "$ac_version"; then
+   echo "buildconf: autoconf not found."
+-  echo "           You need autoconf version 2.59 or newer installed"
++  echo "           You need autoconf version 2.61 or newer installed"
+   echo "           to build APR from SVN."
+   res=1
+ else
+--- apr-1.7.6/configure.in.5
++++ apr-1.7.6/configure.in
+@@ -145,12 +145,14 @@
+     APR_CROSS_COMPILING=maybe
+   elif test "x$build_alias" != "x$host_alias"; then
+     APR_CROSS_COMPILING=yes
++  else
++    APR_CROSS_COMPILING=no
+   fi
+ else
+     APR_CROSS_COMPILING=no
+ fi
+-
+ AC_SUBST(APR_CROSS_COMPILING)
++AC_MSG_NOTICE([cross-compilation detection: $APR_CROSS_COMPILING])
+ 
+ # Libtool might need this symbol -- it must point to the location of
+ # the generated libtool script (not necessarily the "top" build dir).
+@@ -1876,6 +1878,7 @@
+ AC_CHECK_TYPE(ssize_t, int)
+ AC_C_INLINE
+ AC_C_CONST
++AC_C_VARARRAYS
+ AC_FUNC_SETPGRP
+ 
+ APR_CHECK_SOCKLEN_T
+@@ -1971,6 +1974,8 @@
+     AC_ERROR([could not detect a 64-bit integer type])
+ fi
+ 
++AC_MSG_NOTICE([for apr_(u)int64_t using $int64_strfn and 
${int64_value}/${uint64_value}])
++
+ # If present, allow the C99 macro INT64_C to override our conversion.
+ #
+ # HP-UX's ANSI C compiler provides this without any includes, so we
+@@ -2152,7 +2157,6 @@
+     aprlfs=0     
+ fi
+ 
+-AC_MSG_CHECKING([which type to use for apr_off_t])
+ if test "${ac_cv_sizeof_off_t}${apr_cv_use_lfs64}" = "4yes"; then
+     # LFS is go!
+     off_t_fmt='#define APR_OFF_T_FMT APR_INT64_T_FMT'
+@@ -2203,7 +2207,7 @@
+    off_t_fmt=d
+    off_t_strfn='strtoi'
+ fi
+-AC_MSG_RESULT($off_t_value)
++AC_MSG_NOTICE([for apr_off_t using $off_t_strfn and $off_t_value])
+ 
+ # Regardless of whether _LARGEFILE64_SOURCE is used, on some
+ # platforms _FILE_OFFSET_BITS will affect the size of ino_t and hence
+@@ -2234,7 +2238,7 @@
+     fi
+     ;;
+ esac
+-AC_MSG_NOTICE([using $ino_t_value for ino_t])
++AC_MSG_NOTICE([for apr_ino_t using $ino_t_value])
+ 
+ # Checks for endianness
+ AC_C_BIGENDIAN
+--- apr-1.7.6/poll/unix/poll.c.5
++++ apr-1.7.6/poll/unix/poll.c
+@@ -73,7 +73,7 @@
+                                    apr_interval_time_t timeout)
+ {
+     int i, num_to_poll;
+-#ifdef HAVE_VLA
++#ifdef HAVE_C_VARARRAYS
+     /* XXX: I trust that this is a segv when insufficient stack exists? */
+     struct pollfd pollset[num + 1]; /* +1 since allocating 0 is undefined 
behaviour */
+ #elif defined(HAVE_ALLOCA)
+@@ -130,7 +130,7 @@
+         }
+     }
+     
+-#if !defined(HAVE_VLA) && !defined(HAVE_ALLOCA)
++#if !defined(HAVE_C_VARARRAYS) && !defined(HAVE_ALLOCA)
+     if (num > SMALL_POLLSET_LIMIT) {
+         free(pollset);
+     }

Reply via email to