pkgsrc-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
(patch) Re: pkgtools/libnbcompat on Linux older than 2008
On Tue, Aug 11, 2015 at 07:46:05PM -0400, Greg Troxel wrote:
>
> It would seem the right fix is to figure out how to make the detection
> of isblank work correctly. (I would expect adding those flags to cause
> problems on some other systems.)
Quick fix: add "#define _GNU_SOURCE" to the autoconf isblank() detection
as in the asprintf() autoconf detection. (see attached patch).
Longer discussion follows:
The autoconf detection for isblank() as is without my patch actually is
working properly.
But: libnbcompat and some libnbcompat consumers disagree on the use of
"#define _GNU_SOURCE".
net/libfetch: #define _GNU_SOURCE in ftp.c and http.c
(does not use autoconf)
pkgtools/pkgin: AC_GNU_SOURCE in configure.ac
devel/bmake: AC_USE_SYSTEM_EXTENSIONS in configure.in
libnbcompat on the other hand does not define _GNU_SOURCE globally.
Maybe it should (or alternatively use AC_USE_SYSTEM_EXTENSIONS).
For isblank, glibc requires __USE_ISOC99 to be defined, otherwise
isblank is neither declared nor defined (but still an isblank() function
is provided in libc.so).
Newer glibc sets __USE_ISOC99 automatically (auto-detect _DEFAULT_SOURCE
=> _POSIX_C_SOURCE=200809L => __USE_ISOC99=1).
Old glibc systems lack this feature, they require _ISOC99_SOURCE or
_GNU_SOURCE to be set from outside. Lacking that, libnbcompat can not
find an isblank() declaration and therefore adds its own function
declaration for its own isblank() code. For the libnbcompat consumer
using _GNU_SOURCE explicitly, this declaration becomes badly mangled
through the isblank macro definition from ctype.h.
AFAICT, among the packages using libnbcompat, only archivers/pax
actually uses isblank(), and pax does not set _GNU_SOURCE. It works fine
on new and old glibc, no matter if libnbcompat uses _GNU_SOURCE for the
detection as in my patch or not. Either it gets the macro definition
from ctype.h, or it implicitly uses the isblank() function from libc.so,
which exists, even though it happens to have no function declaration.
It might be a bug that libnbcompat does not use _GNU_SOURCE. Or it might
be bug that libnbcompat consumers do use _GNU_SOURCE. There are some
consumers which do not use it and might be impaired by it on some other
platform, as comments in net/libfetch say "it can create surprises else
where". On the other hand, pkgtools/pkgin sets it unconditionally, and
apparently runs successfully on quite a few platforms.
Ideally, libnbcompat would use _GNU_SOURCE globally on platforms where
this is appropriate (#if defined(__linux__) ...). And save this finding
in nbcompat.h and an includeable autoconf snippet, thus pushing it to
all of its consumers.
Regards
Matthias Ferdinand
--- configure.ac.orig 2015-08-21 00:13:29.000000000 +0200
+++ configure.ac 2015-08-25 18:43:18.109688812 +0200
@@ -302,7 +302,9 @@
;;
esac
-AC_CHECK_DECLS([isblank(int)], [], [AC_LIBOBJ(isblank)], [#include <ctype.h>])
+AC_CHECK_DECLS([isblank(int)], [], [AC_LIBOBJ(isblank)],
+ [#define _GNU_SOURCE
+ #include <ctype.h>])
AC_REPLACE_FUNCS([err fgetln fnmatch fparseln getdelim getenv \
getline lchflags lchmod lchown lutimes mkdtemp mkstemp setenv \
--- configure.orig 2015-08-21 00:13:29.000000000 +0200
+++ configure 2015-08-25 18:26:09.196702182 +0200
@@ -5929,7 +5929,8 @@
esac
as_ac_Symbol=`$as_echo "ac_cv_have_decl_isblank(int)" | $as_tr_sh`
-ac_fn_c_check_decl "$LINENO" "isblank(int)" "$as_ac_Symbol" "#include <ctype.h>
+ac_fn_c_check_decl "$LINENO" "isblank(int)" "$as_ac_Symbol" "#define _GNU_SOURCE
+ #include <ctype.h>
"
if eval test \"x\$"$as_ac_Symbol"\" = x"yes"; then :
ac_have_decl=1
Home |
Main Index |
Thread Index |
Old Index