summaryrefslogtreecommitdiffstats
path: root/patches/03_fix-bad-substitution.patch
blob: e69640479762bc0469128e08da293c3186dc5cb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Author: "P. J. McDermott" <pj@pehjota.net>
Forwarded: https://sourceware.org/ml/libc-alpha/2013-09/msg00286.html
Applied-Upstream: 2.19, https://sourceware.org/git/?p=glibc.git;a=commit;h=0a834dd
Last-Update: 2013-09-29
Subject: 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.

diff -Naur src.orig/libc/sysdeps/unix/make-syscalls.sh src/libc/sysdeps/unix/make-syscalls.sh
--- src.orig/libc/sysdeps/unix/make-syscalls.sh	2012-12-02 16:11:45.000000000 -0500
+++ src/libc/sysdeps/unix/make-syscalls.sh	2013-06-25 12:01:55.178740324 -0400
@@ -275,7 +275,7 @@
     # 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\
diff -Naur src.orig/libc/sysdeps/unix/Makefile src/libc/sysdeps/unix/Makefile
--- src.orig/libc/sysdeps/unix/Makefile	2012-11-06 12:31:45.000000000 -0500
+++ src/libc/sysdeps/unix/Makefile	2013-06-25 12:59:59.068197711 -0400
@@ -51,12 +51,14 @@
 	 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);" \
 	     ;; \