bug#78376: Llvm & Musl Libc - "function-like macro '__GNUC_PREREQ' is not defined"

Collin Funk <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
Hi,

NR <[email protected]> writes:

> I was aiming to build a llvm/musl-based system, and while something
> like `bash` will build fine, I encountered this error attempting to
> build coreutils:
> ```
> In file included from lib/fts.c:53:
> lib/fts_.h:70:32: error: function-like macro '__GNUC_PREREQ' is not defined
>    70 | #   if defined __cplusplus && (__GNUC_PREREQ (2,8) ||
> __clang_major__ >= 4)
> ```
> Looking in the llvm source, the closest grep result I could find was:
> ```
> llvm_project/llvm/include/llvm/Support/Compiler.h:/// Extend the
> default __GNUC_PREREQ even if glibc's features.h isn't
> ```

Thanks for the report. I could not reproduce this on the Musl system I
have access too, but it is clearly due to a recent commit of mine in
Gnulib.

I don't have commit privileges to Coreutils so you can run 'git am' on
the attached patch. Or wait until a Coreutils maintainer does the same
and pushes the change.

Collin
0001-build-update-gnulib-submodule-to-latest.patch (text/x-patch, 5.3 KB)
From 7bc983dde89f2fa736846087cf796ab32c64b5cb Mon Sep 17 00:00:00 2001
From: Collin Funk <[email protected]>
Date: Sun, 11 May 2025 09:56:37 -0700
Subject: [PATCH] build: update gnulib submodule to latest

* bootstrap: Update using './bootstrap --bootstrap-sync'.
---
 bootstrap | 58 ++++++++++++++++++++++++++++++++++++-------------------
 gnulib    |  2 +-
 2 files changed, 39 insertions(+), 21 deletions(-)

diff --git a/bootstrap b/bootstrap
index a0af39c2e..fef3cbcd3 100755
--- a/bootstrap
+++ b/bootstrap
@@ -37,7 +37,7 @@ medir=`dirname "$me"`
 
 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
 
-scriptlibversion=2024-11-12.21; # UTC
+scriptlibversion=2025-02-16.12; # UTC
 
 # Copyright (C) 2003-2025 Free Software Foundation, Inc.
 #
@@ -152,7 +152,8 @@ po_download_command_format=\
 "wget --mirror --level=1 -nd -nv -A.po -P '%s' \
  https://translationproject.org/latest/%s/"
 
-# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
+# When extracting the package name from an AC_INIT invocation,
+# prefer a non-empty tarname (4th argument of AC_INIT if given), else
 # fall back to the package name (1st argument with munging).
 extract_package_name='
   /^AC_INIT(\[*/{
@@ -164,17 +165,20 @@ extract_package_name='
        q
      }
      s/[],)].*//
-     s/^GNU //
-     y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
-     s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
      p
   }
 '
-package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
+normalize_package_name='
+  s/^GNU //
+  y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+  s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
+'
+package=$(${AUTOCONF:-autoconf} --trace 'AC_INIT:$4' configure.ac 2>/dev/null)
 if test -z "$package"; then
   package=$(sed -n "$extract_package_name" configure.ac) \
       || die 'cannot find package name in configure.ac'
 fi
+package=$(echo "$package" | sed "$normalize_package_name")
 gnulib_name=lib$package
 
 build_aux=build-aux
@@ -576,18 +580,11 @@ prepare_GNULIB_SRCDIR ()
           || cleanup_gnulib
         else
           # GNULIB_REFDIR is not set or not usable. Ignore it.
-          shallow=
+          shallow='--depth 2'
           if test -z "$GNULIB_REVISION"; then
-            if git clone -h 2>&1 | grep -- --depth > /dev/null; then
-              shallow='--depth 2'
-            fi
             git clone $shallow "$gnulib_url" "$gnulib_path" \
               || cleanup_gnulib
           else
-            if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
-              shallow='--depth 2'
-            fi
-            mkdir -p "$gnulib_path"
             # Only want a shallow checkout of $GNULIB_REVISION, but git does not
             # support cloning by commit hash. So attempt a shallow fetch by
             # commit hash to minimize the amount of data downloaded and changes
@@ -596,13 +593,34 @@ prepare_GNULIB_SRCDIR ()
             # shallow fetch cannot be performed because we do not know what the
             # depth of the commit is without fetching all commits. So fall back
             # to fetching all commits.
-            git -C "$gnulib_path" init
+            # $GNULIB_REVISION can be a commit id, a tag name, or a branch name.
+            mkdir -p "$gnulib_path"
+            # Use a -c option to silence an annoying message
+            # "hint: Using 'master' as the name for the initial branch."
+            # (cf. <https://stackoverflow.com/questions/65524512/>).
+            git -C "$gnulib_path" -c init.defaultBranch=master init
             git -C "$gnulib_path" remote add origin "$gnulib_url"
-            git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
-              || git -C "$gnulib_path" fetch origin \
-              || cleanup_gnulib
-            git -C "$gnulib_path" reset --hard FETCH_HEAD
-            git -C "$gnulib_path" checkout "$GNULIB_REVISION" || cleanup_gnulib
+            if git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION"
+            then
+              # "git fetch" of the specific commit succeeded.
+              git -C "$gnulib_path" reset --hard FETCH_HEAD \
+                || cleanup_gnulib
+              # "git fetch" does not fetch tags (at least in git version 2.43).
+              # If $GNULIB_REVISION is a tag (not a commit id or branch name),
+              # add the tag explicitly.
+              revision=`git -C "$gnulib_path" log -1 --pretty=format:%H`
+              branch=`LC_ALL=C git -C "$gnulib_path" remote show origin \
+                      | sed -n -e 's/^    \([^ ]*\) * tracked$/\1/p'`
+              test "$revision" = "$GNULIB_REVISION" \
+                || test "$branch" = "$GNULIB_REVISION" \
+                || git -C "$gnulib_path" tag "$GNULIB_REVISION"
+            else
+              # Fetch the entire repository.
+              git -C "$gnulib_path" fetch origin \
+                || cleanup_gnulib
+              git -C "$gnulib_path" checkout "$GNULIB_REVISION" \
+                || cleanup_gnulib
+            fi
           fi
         fi
         trap - HUP INT PIPE TERM
diff --git a/gnulib b/gnulib
index 955360a66..a92aa1799 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 955360a66c99bdd9ac3688519a8b521b06958fd3
+Subproject commit a92aa179978a136fa9cc9023d02b5529b19a2210
-- 
2.49.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.