libbsd: Branch 'main' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Feb 12 23:44:37 UTC 2023


 configure.ac            |    6 +++++-
 include/bsd/sys/cdefs.h |    5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

New commits:
commit dec783dce5a7131e232a06e63a544645b5463dd8
Author: Guillem Jover <guillem at hadrons.org>
Date:   Sun Feb 12 23:55:09 2023 +0100

    build: Fix version script linker support detection
    
    When the linker uses --no-undefined-version either specified by the user
    or as the default behavior (such as with newer clang >= 16 releases),
    a missing symbol definition will cause a linker error if that symbol is
    listed in the version script.

diff --git a/configure.ac b/configure.ac
index 875ff04..4faddd0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,7 +39,11 @@ AC_CACHE_CHECK([if ld supports --version-script flag],
   save_LDFLAGS=$LDFLAGS
   LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
   AC_LINK_IFELSE([
-    AC_LANG_PROGRAM([], [])
+    AC_LANG_PROGRAM([[
+extern int symbol(void);
+int symbol(void) { return 0; }
+]], [[
+]])
   ], [
     libbsd_cv_version_script=yes
   ], [
commit fe21244b055dbcf3805d105f48437f36db2f25be
Author: Guillem Jover <guillem at hadrons.org>
Date:   Tue Dec 20 22:47:02 2022 +0100

    include: Use __has_builtin to detect __builtin_offsetof support
    
    The __has_builtin operator is more specific and is supported by GCC
    and Clang, while __is_identifier() is less specific and only supported
    by Clang, so we should prefer the former whenever it is available, and
    only fallback to use the latter when the former is missing and the
    latter.

diff --git a/include/bsd/sys/cdefs.h b/include/bsd/sys/cdefs.h
index ac18296..126f427 100644
--- a/include/bsd/sys/cdefs.h
+++ b/include/bsd/sys/cdefs.h
@@ -37,6 +37,9 @@
 #ifndef __is_identifier
 #define __is_identifier(x) 1
 #endif
+#ifndef __has_builtin
+#define __has_builtin(x) !__is_identifier(x)
+#endif
 
 #ifdef LIBBSD_OVERLAY
 /*
@@ -182,7 +185,7 @@
  * require it.
  */
 #ifndef __offsetof
-# if LIBBSD_GCC_VERSION >= 0x0401 || !__is_identifier(__builtin_offsetof)
+# if LIBBSD_GCC_VERSION >= 0x0401 || __has_builtin(__builtin_offsetof)
 #  define __offsetof(type, field)	__builtin_offsetof(type, field)
 # else
 #  ifndef __cplusplus


More information about the libbsd mailing list