Re: [PATCH libgpg-error] build: fix mutex size computation on systems without gawk
NIIBE Yutaka via Gnupg-devel <[email protected]> Tue, 23 Jun 2026 10:24:06 +0900
| Newsgroups | gmane.comp.encryption.gpg.devel |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hello, Alexis Lothoré wrote: > but when the build host does not have gawk but mawk for example, the > script fails to parse correctly the objdump output, leading to a faulty > header being generated: I see the problem. > Fix size parsing by replacing objdump, which outputs a hexadecimal value > (prefixed with 0x) with nm. Your idea sounds good. I think that we can go further, to remove use of AWK in the script. Testing the change, I noticed that use of NM has two possible issue(s). (1) Considering the future where we use the script for other OS... When objdump is available, it is highly likely it's GNU objdump implementation (otherwise, it has compatible options and compatible output), but it's different in case of NM. Since NM is a standard tool (there are multiple active implementations among different OS), we have to care about portable use of NM. IIUC, -S option is not portable. I think that it is good to use of -P option (which asks the POSIX.2 standard output format), instead. (2) NM is actually affected by libtool (specifically, m4/libtool.m4). It is currently no problem for the script, but we should remember. Attached is revised version. If no problem, I will push this change. -- --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-build-No-use-of-awk-with-gen-lock-obj.sh.patch Content-Transfer-Encoding: 8bit >From 61d9a64f91aa89652265da97e32edee86d5fba45 Mon Sep 17 00:00:00 2001 Message-ID: <61d9a64f91aa89652265da97e32edee86d5fba45.1782177700.git.gniibe@fsij.org> From: NIIBE Yutaka <[email protected]> Date: Tue, 23 Jun 2026 10:21:33 +0900 Subject: [PATCH Libgpg-error] build: No use of awk with gen-lock-obj.sh. To: [email protected] 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é <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]> --- 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-- --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Gnupg-devel mailing list [email protected] https://lists.gnupg.org/mailman/listinfo/gnupg-devel --=-=-=--