Andrew Haley <a...@redhat.com> writes:

> On 06/22/2012 11:35 AM, Simon Baldwin wrote:
>> Firstly, has anyone else encountered this or otherwise given it any
>> thought?  And secondly, any hints for practical fixes?
>
> What you effectively seem to be building is a cross-compiler from
> x86-glibc-A to x86-glibc-B.  To run your tests, you want a machine
> that's running x86-glibc-B.  I would have thought the best way to
> achieve this would be to run the tests in a chroot that is your
> sysroot.  That's what gcc is compiling for.

That does not address the problem, at least not in any straightforward
way.  The problem is not running the tests, it's running the expect
binary itself.  Due to the setting of LD_LIBRARY_PATH before starting
expect, expect is picking up the newly built libgcc_s.so.  This fails in
a rather obscure manner because expect is not actually linked against
libgcc_s.so, but instead picks it up via the rather baroque way that
glibc implements pthread_cancel.

Logically, the only way this can be fixed is to not have LD_LIBRARY_PATH
point into the newly built compiler when running expect.  Of course
LD_LIBRARY_PATH does need to be set within expect, so that the newly
built compiler runs correctly.  This is potentially a general problem.
We should not be running any binaries installed on the host system with
this setting of LD_LIBRARY_PATH.  The only binaries we should run with
LD_LIBRARY_PATH set are the ones that we just built.

Therefore, I think it is a bug that we put TARGET_LIB_PATH into
LD_LIBRARY_PATH in HOST_EXPORTS when gcc-bootstrap is true.  Since GCC
is linked with -static-libgcc -static-libstdc++, I think that we can get
away with not doing that.

Looking at the history this code seems to originate with the fix for
http://gcc.gnu.org/PR17369 .  This e-mail messages describes the
problem: http://gcc.gnu.org/ml/gcc/2004-09/msg00209.html .  Since we now
link with -static-libgcc (and -static-libstdc++) I don't think this
should be a problem any more.

So I think we should simply try this patch (plus regenerate the top
level Makefile.in, of course) and see what happens.

Ian

Index: Makefile.tpl
===================================================================
--- Makefile.tpl	(revision 188349)
+++ Makefile.tpl	(working copy)
@@ -228,9 +228,6 @@ HOST_EXPORTS = \
 	CLOOGINC="$(HOST_CLOOGINC)"; export CLOOGINC; \
 	LIBELFLIBS="$(HOST_LIBELFLIBS)" ; export LIBELFLIBS; \
 	LIBELFINC="$(HOST_LIBELFINC)" ; export LIBELFINC; \
-@if gcc-bootstrap
-	$(RPATH_ENVVAR)=`echo "$(TARGET_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR); \
-@endif gcc-bootstrap
 	$(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH)$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR);
 
 POSTSTAGE1_CXX_EXPORT = \

Reply via email to