Bug 202511 - sys-libs/glibc-2.7-r1 fails to build with bsd awk
Bug#: 202511 Product:  Gentoo Linux Version: unspecified Platform: All
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: toolchain@gentoo.org Reported By: aballier@gentoo.org
Component: Applications
URL:  http://sourceware.org/ml/libc-alpha/2007-12/msg00020.html
Summary: sys-libs/glibc-2.7-r1 fails to build with bsd awk
Keywords:  
Status Whiteboard: 
Opened: 2007-12-16 19:52 0000
Description:   Opened: 2007-12-16 19:52 0000
using crossdev -t amd64 on ~x86-fbsd, glibc 2.7-r1 fails:

                 
/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/elf/librtld.os
-Wl,--version-script=/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/ld.map
           \
                  -Wl,-soname=ld-linux-x86-64.so.2 -T
/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/elf/ld.so.lds
rm -f
/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/elf/ld.so.lds
readelf -s
/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/elf/ld.so
\
          | awk '($7 ~ /^UND(|EF)$/ && $1 != "0:" && $4 != "REGISTER") { print;
p=1 } END { exit p != 0 }'
awk: illegal primary in regular expression ^UND(|EF)$ at EF)$
 source line number 1
 context is
        ($7 ~ >>>  /^UND(|EF)$/ <<<
gmake[2]: ***
[/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/build-amd64-x86_64-pc-linux-gnu-nptl/elf/ld.so]
Error 2
gmake[2]: Leaving directory
`/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/glibc-2.7/elf'
gmake[1]: *** [elf/subdir_lib] Error 2
gmake[1]: Leaving directory
`/var/tmp/cross/x86_64-pc-linux-gnu/portage/cross-x86_64-pc-linux-gnu/glibc-2.7-r1/work/glibc-2.7'
gmake: *** [all] Error 2
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m ERROR: cross-x86_64-pc-linux-gnu/glibc-2.7-r1 failed.
 ^[[31;01m*^[[0m Call stack:
 ^[[31;01m*^[[0m               ebuild.sh, line   46:  Called src_compile
 ^[[31;01m*^[[0m             environment, line 3322:  Called eblit-run
'src_compile'
 ^[[31;01m*^[[0m             environment, line 1079:  Called
eblit-glibc-src_compile
 ^[[31;01m*^[[0m       src_compile.eblit, line  168:  Called src_compile
 ^[[31;01m*^[[0m             environment, line 3322:  Called eblit-run
'src_compile'
 ^[[31;01m*^[[0m             environment, line 1079:  Called
eblit-glibc-src_compile
 ^[[31;01m*^[[0m       src_compile.eblit, line  179:  Called
toolchain-glibc_src_compile

forcing to use gawk (by e.g. replacing bsd's awk by gawk) workarounds it.

------- Comment #1 From Alexis Ballier 2007-12-21 11:00:38 0000 -------
Created an attachment (id=139031) [details]
proposed patch

bsd awk doesnt seem to like having to match the empty string. I haven't found
any reliable documentation about this corner case, but changing the regexp like
that fixes the problem here.
Another solution would be to force it using gawk, but considering the size of
the patch that seems silly to add such a requirement.

Please let me know if you want me to send it upstream (and where to send it),
but the patch is so trivial that I think it could be sent with other ones.

------- Comment #2 From SpanKY 2007-12-22 07:44:52 0000 -------
while i consider the syntax used here pretty useful, i think it's a violation
of POSIX ... please refer to:
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html

9.4.3 ERE Special Characters
The vertical-line is special except when used in a bracket expression (see RE
Bracket Expression). A vertical-line appearing first or last in an ERE, or
immediately following a vertical-line or a left-parenthesis, or immediately
preceding a right-parenthesis, produces undefined results.

my interpretation of this is that "(|DEF)" is invalid

anyone else feel like reading that and confirming ?

------- Comment #3 From SpanKY 2007-12-24 19:15:46 0000 -------
thinking about it, these two should be completely interchangeable:
moo(|cow)
moo(cow)?

so i'll patch it to do the latter

------- Comment #4 From SpanKY 2007-12-24 19:25:40 0000 -------
added to current glibc-2.7-r1 ebuild

http://sources.gentoo.org/gentoo/src/patchsets/glibc/2.7/1050_all_glibc-posix-awk.patch?rev=1.1