Some will disagree that this is a problem so hear me out to the end. Run `ldd /bin/grep` and you'll get: libpcre.so.0 => /usr/lib/libpcre.so.0 (0x4002d000) libc.so.6 => /lib/libc.so.6 (0x40037000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) Everything looks ok? Well, IMO since grep is in /bin is should not depend on anything in /usr . I keep /usr as a different mount point than my root filesystem and if my machine were to have problems where I couldn't mount /usr but could mount the root I would not be able to use the grep command during recovery. How would I solve this? I think anything in /bin should be statically compiled to improve the probability of recovery when all goes to hell but that is a policy issue for people more involved with Gentoo. You could have two grep packages, grep and sgrep, kinda like there are two python packages. sgrep would be staticly compiled and merge into /bin and grep would be normally compiled and merge into /usr/bin . If you did this you would probably want to make it so /usr/bin was before /bin in the user's $PATH . Maybe just staticly compile the grep package but then you lose the advantage of libs. Or move /usr/lib/libpcre.so.0 to /lib/libpcre.so.0 but I don't like this idea.
I can confirm this. When I shutdown my machine, the last thing before system halt is a message about /usr/lib/libpcre.so.X missing. My /usr and / are on different volumes. A quick ldd /bin/* shows that only grep is the looking for something in /usr/lib. There are a couple of solutions: 1. move libpcre into /lib 2. build /bin/grep without libprce 3. link libprce statically. Some research shows that other distros (eg. redhat and debian) are not doing 1 or 3. option 2 is the best because we get a vanilla /bin/grep with no libpcre but if the user wants a libpcre-grep, then dev-libs/libprce provides just that: /usr/bin/pcregrep.
OK, I think your solution #2 is best. Here's what I would recommend, but it needs testing (especially in a bootstrap environment). in the DEPEND section: perl?( libpcre ) and then in src_compile(): use perl || myconf="${myconf} --disable-perl-regexp" That should compile without libpcre if you build it with -perl in USE :)
I did a few test compiles and it seems there is no way to force a static compile of grep. The perl regexp feature was just added in the last release so not much out there is going to need it. I think changing the start of src_compile to: src_compile() { local myconf myconf="--disable-perl-regexp" [ -z "`use nls`" ] && myconf="--disable-nls" ...etc... would be the best solution.
Fixed in CVS but masked (sys-apps/grep-2.5-r1) until more people test it.