From: Alexey Brodkin Date: Mon, 13 Mar 2017 09:47:45 +0000 (+0300) Subject: libnl: Fix building with uClibc X-Git-Tag: v18.06.0-rc1~3334 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=51d9ac61c711e7e00f8f2eaf5b3503238864508a;p=openwrt%2Fstaging%2Fchunkeey.git libnl: Fix building with uClibc uClibc doesn't implement strerror_l() and thus libnl starting from 3.2.29 couldn't be compiled with it any longer, see https://github.com/thom311/libnl/commit/6c2d111177e91184073c44f83d4a6182aaba06d7 To work-around that problem we'll just do a check on strerror_l() availability during configuration and if it's not there just fall back to locale-less strerror(). Patch for libnl is alreadfy merged upstream, see https://github.com/thom311/libnl/commit/e15966ac7f3b43df2acf869f98089762807d0568 and once the next libnl release happens this one must be removed from Lede/OpenWrt. Signed-off-by: Alexey Brodkin Cc: Felix Fietkau Cc: John Crispin Cc: Daniel Engberg --- diff --git a/package/libs/libnl/patches/0001-lib-Escape-usage-of-strerror_l-if-it-doesn-t-exist-i.patch b/package/libs/libnl/patches/0001-lib-Escape-usage-of-strerror_l-if-it-doesn-t-exist-i.patch new file mode 100644 index 0000000000..a31ef47729 --- /dev/null +++ b/package/libs/libnl/patches/0001-lib-Escape-usage-of-strerror_l-if-it-doesn-t-exist-i.patch @@ -0,0 +1,105 @@ +From 098a4cc35b0da4438b8b67a914edecebef5bb6a9 Mon Sep 17 00:00:00 2001 +From: Alexey Brodkin +Date: Fri, 10 Mar 2017 13:22:14 +0300 +Subject: [PATCH] lib: Escape usage of strerror_l() if it doesn't exist in libc + +uClibc doesn't implement strerror_l() and thus libnl starting from +3.2.29 couldn't be compiled with it any longer. + +To work-around that problem we'll just do a check on strerror_l() +availability during configuration and if it's not there just fall back +to locale-less strerror(). + +Signed-off-by: Alexey Brodkin +Cc: Andre Draszik +Cc: Thomas Haller +--- + +This patch is now accepted upstream and will be a part of the next libnl +release, see +https://github.com/thom311/libnl/commit/e15966ac7f3b43df2acf869f98089762807d0568 + + configure.ac | 2 ++ + lib/utils.c | 8 +++++++- + src/lib/utils.c | 6 ++++++ + 3 files changed, 15 insertions(+), 1 deletion(-) + +diff --git a/configure.ac b/configure.ac +index 68b285e5b15c..2739b997ee3a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -121,6 +121,8 @@ fi + + AC_CONFIG_SUBDIRS([doc]) + ++AC_CHECK_FUNCS([strerror_l]) ++ + AC_CONFIG_FILES([ + Makefile + libnl-3.0.pc +diff --git a/lib/utils.c b/lib/utils.c +index fb350d13fd2f..06273c5b291e 100644 +--- a/lib/utils.c ++++ b/lib/utils.c +@@ -30,7 +30,9 @@ + #include + #include + #include /* exit() */ ++#ifdef HAVE_STRERROR_L + #include ++#endif + + /** + * Global variable indicating the desired level of debugging output. +@@ -123,9 +125,10 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *)) + + const char *nl_strerror_l(int err) + { ++ const char *buf; ++#ifdef HAVE_STRERROR_L + int errno_save = errno; + locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0); +- const char *buf; + + if (loc == (locale_t)0) { + if (errno == ENOENT) +@@ -140,6 +143,9 @@ const char *nl_strerror_l(int err) + } + + errno = errno_save; ++#else ++ buf = strerror(err); ++#endif + return buf; + } + /** @endcond */ +diff --git a/src/lib/utils.c b/src/lib/utils.c +index 5878f279c364..feb1d4ef4056 100644 +--- a/src/lib/utils.c ++++ b/src/lib/utils.c +@@ -81,6 +81,7 @@ void nl_cli_fatal(int err, const char *fmt, ...) + fprintf(stderr, "\n"); + } else { + char *buf; ++#ifdef HAVE_STRERROR_L + locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0); + if (loc == (locale_t)0) { + if (errno == ENOENT) +@@ -91,9 +92,14 @@ void nl_cli_fatal(int err, const char *fmt, ...) + } + if (loc != (locale_t)0) + buf = strerror_l(err, loc); ++#else ++ buf = strerror(err); ++#endif + fprintf(stderr, "%s\n", buf); ++#ifdef HAVE_STRERROR_L + if (loc != (locale_t)0) + freelocale(loc); ++#endif + } + + exit(abs(err)); +-- +2.7.4 +