Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 54068 - valgrind ebuilds do not compile
Summary: valgrind ebuilds do not compile
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All All
: Normal normal (vote)
Assignee: solar (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-16 02:44 UTC by Joseph Turian
Modified: 2004-06-20 18:07 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Turian 2004-06-16 02:44:43 UTC
I cannot emerge valgrind, neither version 2.0.0 nor 2.1.1.

From valgrind-2.0.0 output:
if gcc -DHAVE_CONFIG_H -I. -I. -I..  -I./demangle -I../include -DVG_LIBDIR="\"/usr/lib"\"   -Winline -Wall -Wshadow -O -fomit-frame-pointer -mpreferred-stack-boundary=2 -g -mpreferred-stack-boundary=2 -fno-omit-frame-pointer -MT vg_intercept.o -MD -MP -MF ".deps/vg_intercept.Tpo" \
  -c -o vg_intercept.o `test -f 'vg_intercept.c' || echo './'`vg_intercept.c; \
then mv -f ".deps/vg_intercept.Tpo" ".deps/vg_intercept.Po"; \
else rm -f ".deps/vg_intercept.Tpo"; exit 1; \
fi
vg_intercept.c: In function `vgAllRoadsLeadToRome_msgsnd':
vg_intercept.c:125: error: can't find a register in class `BREG' while reloading `asm'
vg_intercept.c:125: error: can't find a register in class `BREG' while reloading `asm'
make[3]: *** [vg_intercept.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/var/tmp/portage/valgrind-2.0.0/work/valgrind-2.0.0/coregrind'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/var/tmp/portage/valgrind-2.0.0/work/valgrind-2.0.0/coregrind'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/valgrind-2.0.0/work/valgrind-2.0.0'
make: *** [all] Error 2


From valgrind-2.1.1:
if gcc -DHAVE_CONFIG_H -I. -I. -I..  -I./demangle -I../include -I./x86 -DVG_LIBDIR="\"/usr/lib/valgrind"\"   -Winline -Wall -Wshadow -O -fno-omit-frame-pointer -mpreferred-stack-boundary=2 -g -DELFSZ=32  -MT vg_to_ucode.o -MD -MP -MF ".deps/vg_to_ucode.Tpo" \
  -c -o vg_to_ucode.o `test -f 'vg_to_ucode.c' || echo './'`vg_to_ucode.c; \
then mv -f ".deps/vg_to_ucode.Tpo" ".deps/vg_to_ucode.Po"; \
else rm -f ".deps/vg_to_ucode.Tpo"; exit 1; \
fi
vg_to_ucode.c: In function `get_cpu_features':
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
vg_to_ucode.c:109: error: can't find a register in class `BREG' while reloading `asm'
make[4]: *** [vg_to_ucode.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[4]: Leaving directory `/var/tmp/portage/valgrind-2.1.1/work/valgrind-2.1.1/coregrind'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/var/tmp/portage/valgrind-2.1.1/work/valgrind-2.1.1/coregrind'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/var/tmp/portage/valgrind-2.1.1/work/valgrind-2.1.1/coregrind'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/portage/valgrind-2.1.1/work/valgrind-2.1.1'
make: *** [all] Error 2
Comment 1 Joseph Turian 2004-06-16 02:57:41 UTC
First of all, I should point out that I'm using gcc-3.3.3-r6

Anyway, the error message is decribed at this url: http://my.execpc.com/~geezer/osd/gotchas/index.htm

"'can't find a register in class `[AREG|BREG|CREG|DREG]' while reloading `asm'
New versions of the GNU assembler are pickier about the clobber lists used in inline asm. Though it worked fine with older versions of the GNU assembler, the following code is now considered incorrect:
static inline void
memset(void *__dest, unsigned int __fill, unsigned int __size) {
    __asm__ __volatile__ ("cld
			   rep
			   stosb"               :
			   /* no outputs */     :
			   "c" (__size),
			   "a" (__fill),
                           "D" (__dest)         :
			   "ecx","eax","edi","memory");
}
because registers ECX, EAX, and EDI are present in both the clobber list and the input constraints. Remove these registers from the clobber list:

                           ...
			   "a" (__fill),
                           "D" (__dest)         :
                                             "memory");
}
and the code should assemble without error."


So, the solution is to remove the "b" line in all functions that cause this error message.
Comment 2 Sergey Vlasov 2004-06-16 07:09:45 UTC
Simply removing the clobbers is incorrect - in this case gcc will assume that the registers do not change and may try to reuse their values after asm, which will lead to hard-to-find bugs.

The proper way to fix this is to add dummy outputs to the asm statement.  Here is the memset implementation from linux-2.6.6/include/asm-i386/string.h:

static inline void * __memset_generic(void * s, char c,size_t count)
{
int d0, d1;
__asm__ __volatile__(
	"rep\n\t"
	"stosb"
	: "=&c" (d0), "=&D" (d1)
	:"a" (c),"1" (s),"0" (count)
	:"memory");
return s;
}

Note the dummy outputs d0 and d1, and the inputs with "1" and "0" constraints (this means that they overlap the specified outputs).
Comment 3 solar (RETIRED) gentoo-dev 2004-06-16 13:10:47 UTC
Joseph,
emerge info ; please
Comment 4 Joseph Turian 2004-06-16 14:35:39 UTC
Tom Hughes and I hashed out this compilation issue on the valgrind-users list.

His latest patch resolves this issue:
http://bugs.kde.org/attachment.cgi?id=6389&action=view

(This is comment #4 in the following bug report: http://bugs.kde.org/show_bug.cgi?id=79696)

Note that you have to run aclocal && automake after applying the patch, since the patch modifies a Makefile.am.

Let me know if you still need my emerge info, otherwise I'll assume it's unneccessary at this point.
Comment 5 solar (RETIRED) gentoo-dev 2004-06-17 09:11:11 UTC
In portage as valgrind-2.1.1-r1.ebuild ~x86
I removed the filter-flags -fPIC as the ebx munching no longer happens with this patch. (thanks)
On another note it would be nice to get all of the trampolines resolved in valgrind as well.

Joseph,
In the future please start all bugs off with 'emerge info'
Reason I say that is that/this bug should of really not shown up unless you were forcing pic code and I don't see fPIC in the CFLAGS which makes me go hrmm.. maybe he is using a gcc compiled with USE=hardened.

None the less please test and confirm that 2.1.1-r1 works for you as expected.
Comment 6 Joseph Turian 2004-06-20 18:07:10 UTC
Okay, it works fine, so I'm changing the status to WORKSFORME.

In the future, I'll include 'emerge info' when it seems relevant.