patches/binutils/2.20.1a/280-unexport_LD_LIBRARY_PATH.patch
changeset 2664 346263a07115
parent 2088 4f21ba5f8e91
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/binutils/2.20.1a/280-unexport_LD_LIBRARY_PATH.patch	Sun Sep 11 18:18:53 2011 +0200
     1.3 @@ -0,0 +1,96 @@
     1.4 +Description:
     1.5 +
     1.6 +This patch is needed in situations where build system is running same version of
     1.7 +binutils that is intended to be built  cross-native ( build != host = target)
     1.8 + and has shared libraries enabled. binutils/binutils
     1.9 +Makefile has some tools which are built to run on build system. Toplevel makefile
    1.10 +for binutils passes HOST_EXPORTS to sub-makefiles which also include RPATH_ENVVARS
    1.11 +containing LD_LIBRARY_PATH which is modified so that it also includes host libraries
    1.12 +like opcodes and libbfd which are just built for the host system. 
    1.13 +
    1.14 +Now the problem is that same LD_LIBRARY_PATH value gets set in environment even
    1.15 +for the tools that are being built for build system using CC_FOR_BUILD and the tools
    1.16 +like as,ld it invokes from build machine get the LD_LIBRARY_PATH set to search
    1.17 +the newly build host libraries like opcodes and bfd and if host is like a big endian
    1.18 +system say (mips-linux) the build system linker and assembler do not run because
    1.19 +ld.so tries to load these shared libraries instead of the ones from /usr/lib for 
    1.20 +the build tools. 
    1.21 +
    1.22 +This patch fixes the issue by clearing LD_LIBRARY_PATH for BUILD tools
    1.23 +
    1.24 +This patch would be needed on other versions of binutils. I just cared about 2.20
    1.25 +May be upstream is also interested in such a patch.
    1.26 +
    1.27 +-Khem
    1.28 +
    1.29 +Index: binutils-2.20/binutils/Makefile.am
    1.30 +===================================================================
    1.31 +
    1.32 +diff -durN binutils-2.20.1.orig/binutils/Makefile.am binutils-2.20.1/binutils/Makefile.am
    1.33 +--- binutils-2.20.1.orig/binutils/Makefile.am	2010-01-14 11:48:22.000000000 +0100
    1.34 ++++ binutils-2.20.1/binutils/Makefile.am	2010-08-17 19:32:24.000000000 +0200
    1.35 +@@ -251,24 +251,24 @@
    1.36 + 	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    1.37 + 
    1.38 + sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    1.39 +-	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    1.40 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    1.41 + 
    1.42 + syslex.o: syslex.c sysinfo.h config.h
    1.43 + 	if [ -r syslex.c ]; then \
    1.44 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    1.45 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    1.46 + 	else \
    1.47 +-	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    1.48 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    1.49 + 	fi
    1.50 + 
    1.51 + sysinfo.o: sysinfo.c
    1.52 + 	if [ -r sysinfo.c ]; then \
    1.53 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    1.54 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    1.55 + 	else \
    1.56 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    1.57 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    1.58 + 	fi
    1.59 + 
    1.60 + bin2c$(EXEEXT_FOR_BUILD):
    1.61 +-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    1.62 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    1.63 + 
    1.64 + embedspu: embedspu.sh
    1.65 + 	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
    1.66 +diff -durN binutils-2.20.1.orig/binutils/Makefile.in binutils-2.20.1/binutils/Makefile.in
    1.67 +--- binutils-2.20.1.orig/binutils/Makefile.in	2010-03-03 14:59:46.000000000 +0100
    1.68 ++++ binutils-2.20.1/binutils/Makefile.in	2010-08-17 19:32:24.000000000 +0200
    1.69 +@@ -1193,24 +1193,24 @@
    1.70 + 	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    1.71 + 
    1.72 + sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    1.73 +-	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    1.74 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    1.75 + 
    1.76 + syslex.o: syslex.c sysinfo.h config.h
    1.77 + 	if [ -r syslex.c ]; then \
    1.78 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    1.79 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    1.80 + 	else \
    1.81 +-	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    1.82 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    1.83 + 	fi
    1.84 + 
    1.85 + sysinfo.o: sysinfo.c
    1.86 + 	if [ -r sysinfo.c ]; then \
    1.87 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    1.88 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    1.89 + 	else \
    1.90 +-	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    1.91 ++	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    1.92 + 	fi
    1.93 + 
    1.94 + bin2c$(EXEEXT_FOR_BUILD):
    1.95 +-	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    1.96 ++	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    1.97 + 
    1.98 + embedspu: embedspu.sh
    1.99 + 	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@