>From 61d9a64f91aa89652265da97e32edee86d5fba45 Mon Sep 17 00:00:00 2001
Message-ID: <61d9a64f91aa89652265da97e32edee86d5fba45.1782177700.git.gniibe@fsij.org>
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Tue, 23 Jun 2026 10:21:33 +0900
Subject: [PATCH Libgpg-error] build: No use of awk with gen-lock-obj.sh.
To: gnupg-devel@gnupg.org
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.47.3"

This is a multi-part message in MIME format.
--------------2.47.3
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit


* configure.ac: For invocation of gen-lock-obj.sh, use NM instead of
OBJDUMP, use no AWK.
* src/gen-lock-obj.sh: Use NM with option -P and -t d for portable
output in decimal.  No use of AWK, simply use cut.

--

Signed-off-by: Alexis Lothoré <alexis.lothore@bootlin.com>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
---
 configure.ac        | 10 +++++-----
 src/gen-lock-obj.sh | 25 ++++++++++---------------
 2 files changed, 15 insertions(+), 20 deletions(-)


--------------2.47.3
Content-Type: text/x-patch; name="0001-build-No-use-of-awk-with-gen-lock-obj.sh.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-build-No-use-of-awk-with-gen-lock-obj.sh.patch"

diff --git a/configure.ac b/configure.ac
index e3d1a19..e9abe0d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -635,16 +635,16 @@ if test x"$gl_use_threads" = xno; then
 elif test x$cross_compiling = xyes; then
   case $host in
     *-*-gnu* | *-*-linux-gnu* | *-*-linux-musl* | wasm*-*-emscripten)
-    AC_CHECK_TOOL(OBJDUMP, [objdump])
-    if test -n "$OBJDUMP"; then
+    AC_CHECK_TOOL(NM, [nm])
+    if test -n "$NM"; then
       lock_obj_h_generated=yes
       if test ! -d src; then mkdir src; fi
       LOCK_ABI_VERSION=1 host=$host host_alias=$host_alias \
-          CC=$CC OBJDUMP=$OBJDUMP \
+          CC=$CC NM=$NM \
           ac_ext=$ac_ext ac_objext=$ac_objext \
-          AWK=$AWK $srcdir/src/gen-lock-obj.sh \
+          $srcdir/src/gen-lock-obj.sh \
           >src/lock-obj-pub.native.h
-      AC_MSG_NOTICE([generated src/lock-obj-pub.native.h using $host_alias-objdump and $AWK])
+      AC_MSG_NOTICE([generated src/lock-obj-pub.native.h using $NM])
     else
       force_use_syscfg=yes
     fi
diff --git a/src/gen-lock-obj.sh b/src/gen-lock-obj.sh
index a8d9352..dccd02b 100755
--- a/src/gen-lock-obj.sh
+++ b/src/gen-lock-obj.sh
@@ -24,8 +24,7 @@
 # Following variables should be defined to invoke this script
 #
 #   CC
-#   OBJDUMP
-#   AWK
+#   NM
 #   ac_ext
 #   ac_object
 #   host
@@ -34,8 +33,8 @@
 # An example:
 #
 # LOCK_ABI_VERSION=1 host=x86_64-pc-linux-gnu host_alias=x86_64-linux-gnu \
-#     CC=$host_alias-gcc OBJDUMP=$host_alias-objdump ac_ext=c ac_objext=o \
-#     AWK=gawk ./gen-lock-obj.sh
+#     CC=$host_alias-gcc NM=$NM ac_ext=c ac_objext=o \
+#     ./gen-lock-obj.sh
 #
 
 if test -n "`echo -n`"; then
@@ -61,23 +60,19 @@ typedef struct
 #define GPGRT_LOCK_INITIALIZER {-1}
 EOF
 else
-AWK_VERSION_OUTPUT=$($AWK 'BEGIN { print PROCINFO["version"] }')
-if test -n "$AWK_VERSION_OUTPUT"; then
-    # It's GNU awk, which supports PROCINFO.
-    AWK_OPTION=--non-decimal-data
-fi
-
 cat <<'EOF' >conftest.$ac_ext
 #include <pthread.h>
 pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
 EOF
 
+#
+# Note: NM actually comes with the option -B, because of libtool.m4.
+# We override with the -P option (Use POSIX.2 standard format).
+#
 if $CC -c conftest.$ac_ext; then :
-  ac_mtx_size=$($OBJDUMP -t conftest.$ac_objext \
-         | $AWK $AWK_OPTION '
-/mtx$/ { mtx_size = int("0x" $5) }
-END { print mtx_size }')
-else
+  ac_mtx_size=$($NM -P -t d conftest.$ac_objext | cut -d ' ' -f 4)
+fi
+if test -z "$ac_mtx_size"; then
     echo "Can't determine mutex size"
     exit 1
 fi

--------------2.47.3--


