This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Don't use Bash-specific ${parameter/pattern/string} expansion


sysdeps/unix/make-syscalls.sh and sysdeps/unix/Makefile use GNU Bash's
${parameter/pattern/string} parameter expansion.  Non-Bash shells (e.g.
dash or BusyBox ash when built with CONFIG_ASH_BASH_COMPAT disabled)
don't support this expansion syntax.  So glibc will fail to build when
$(SHELL) expands to a path that isn't provided by Bash.

An example build failure:

    for dir in [...]; do \
      test -f $dir/syscalls.list && \
      { sysdirs='[...]' \
        asm_CPP='gcc -c    -I[...]   -D_LIBC_REENTRANT -include include/libc-symbols.h       -DASSEMBLER  -g -Wa,--noexecstack   -E -x assembler-with-cpp' \
        /bin/sh sysdeps/unix/make-syscalls.sh $dir || exit 1; }; \
      test $dir = sysdeps/unix && break; \
    done > [build-dir]/sysd-syscallsT
    sysdeps/unix/make-syscalls.sh: line 273: syntax error: bad substitution

This patch simply replaces the three instances of the Bash-only syntax
in these files with an echo and sed command substitution.  (Personally,
I'd prefer printf, but surrounding code uses echo and the usage here
appears reasonably safe.)

There's one other instance of this expansion syntax in the glibc tree
(scripts/cross-test-ssh.sh:106), but that file isn't used during the
build.

With this patch, glibc can almost be configured and built using dash,
BusyBox ash, or almost any other Bourne-compatible shell.

2013-09-08  P. J. McDermott  <pj@pehjota.net>

	* sysdeps/unix/Makefile: Don't use Bash-specific
	${parameter/pattern/string} parameter expansion.
	* sysdeps/unix/make-syscalls.sh: Likewise.
---
 sysdeps/unix/Makefile         |    6 ++++--
 sysdeps/unix/make-syscalls.sh |    2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/Makefile b/sysdeps/unix/Makefile
index 375561f..1d4c451 100644
--- a/sysdeps/unix/Makefile
+++ b/sysdeps/unix/Makefile
@@ -51,12 +51,14 @@ $(objpfx)stub-syscalls.c: $(common-objpfx)sysd-syscalls \
 	 for call in $(unix-stub-syscalls); do \
 	   case $$call in \
 	   *@@*) \
-	     ver=$${call##*@}; call=$${call%%@*}; ver=$${ver//./_}; \
+	     ver=$${call##*@}; call=$${call%%@*}; \
+	     ver=`echo $ver | sed 's/\./_/g'`; \
 	     echo "strong_alias (_no_syscall, __$${call}_$${ver})"; \
 	     echo "versioned_symbol (libc, __$${call}_$${ver}, $$call, $$ver);"\
 	     ;; \
 	   *@*) \
-	     ver=$${call##*@}; call=$${call%%@*}; ver=$${ver//./_}; \
+	     ver=$${call##*@}; call=$${call%%@*}; \
+	     ver=`echo $ver | sed 's/\./_/g'`; \
 	     echo "strong_alias (_no_syscall, __$${call}_$${ver})"; \
 	     echo "compat_symbol (libc, __$${call}_$${ver}, $$call, $$ver);" \
 	     ;; \
diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh
index f04f2ab..70dc563 100644
--- a/sysdeps/unix/make-syscalls.sh
+++ b/sysdeps/unix/make-syscalls.sh
@@ -275,7 +275,7 @@ while read file srcfile caller syscall args strong weak; do
     # name in the vDSO and KERNEL_X.Y is its symbol version.
     vdso_symbol="${vdso_syscall%@*}"
     vdso_symver="${vdso_syscall#*@}"
-    vdso_symver="${vdso_symver//./_}"
+    vdso_symver=`echo $vdso_symver | sed 's/\./_/g'`
     echo "\
 \$(foreach p,\$(sysd-rules-targets),\$(objpfx)\$(patsubst %,\$p,$file).os): \\
 		\$(..)sysdeps/unix/make-syscalls.sh\
-- 
Patrick "P. J." McDermott
  http://www.pehjota.net/
Lead Developer, ProteanOS
  http://www.proteanos.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]