patches/binutils/2.20/280-unexport_LD_LIBRARY_PATH.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Fri Apr 15 00:22:42 2011 +0200 (2011-04-15)
branch1.11
changeset 2557 b71761e8cff1
permissions -rw-r--r--
scripts/internals: do not remove lib{32,64}/ symlinks after build

During the build, we create lib{32,64}/ symlinks out of the sysroot.
In some cases (eg. mingw32 target), these symlinks are still required
when running the toolchain. For other combinations, the symlinks are
without incidence, so they can be safely kept after the build.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
(transplanted from 751c3f735ada4a95aa981841b832adb08b88ce27)
     1 Description:
     2 
     3 This patch is needed in situations where build system is running same version of
     4 binutils that is intended to be built  cross-native ( build != host = target)
     5  and has shared libraries enabled. binutils/binutils
     6 Makefile has some tools which are built to run on build system. Toplevel makefile
     7 for binutils passes HOST_EXPORTS to sub-makefiles which also include RPATH_ENVVARS
     8 containing LD_LIBRARY_PATH which is modified so that it also includes host libraries
     9 like opcodes and libbfd which are just built for the host system. 
    10 
    11 Now the problem is that same LD_LIBRARY_PATH value gets set in environment even
    12 for the tools that are being built for build system using CC_FOR_BUILD and the tools
    13 like as,ld it invokes from build machine get the LD_LIBRARY_PATH set to search
    14 the newly build host libraries like opcodes and bfd and if host is like a big endian
    15 system say (mips-linux) the build system linker and assembler do not run because
    16 ld.so tries to load these shared libraries instead of the ones from /usr/lib for 
    17 the build tools. 
    18 
    19 This patch fixes the issue by clearing LD_LIBRARY_PATH for BUILD tools
    20 
    21 This patch would be needed on other versions of binutils. I just cared about 2.20
    22 May be upstream is also interested in such a patch.
    23 
    24 -Khem
    25 
    26 Index: binutils-2.20/binutils/Makefile.am
    27 ===================================================================
    28 --- binutils-2.20.orig/binutils/Makefile.am	2009-12-30 15:30:35.302438121 -0800
    29 +++ binutils-2.20/binutils/Makefile.am	2009-12-30 15:33:09.154420373 -0800
    30 @@ -251,24 +251,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
    31  	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    32  
    33  sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    34 -	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    35 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    36  
    37  syslex.o: syslex.c sysinfo.h config.h
    38  	if [ -r syslex.c ]; then \
    39 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    40 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    41  	else \
    42 -	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    43 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    44  	fi
    45  
    46  sysinfo.o: sysinfo.c
    47  	if [ -r sysinfo.c ]; then \
    48 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    49 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    50  	else \
    51 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    52 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    53  	fi
    54  
    55  bin2c$(EXEEXT_FOR_BUILD):
    56 -	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    57 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    58  
    59  embedspu: embedspu.sh
    60  	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
    61 Index: binutils-2.20/binutils/Makefile.in
    62 ===================================================================
    63 --- binutils-2.20.orig/binutils/Makefile.in	2009-12-30 15:30:44.582922535 -0800
    64 +++ binutils-2.20/binutils/Makefile.in	2009-12-30 15:33:47.322422313 -0800
    65 @@ -1193,24 +1193,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
    66  	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    67  
    68  sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    69 -	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    70 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    71  
    72  syslex.o: syslex.c sysinfo.h config.h
    73  	if [ -r syslex.c ]; then \
    74 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    75 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
    76  	else \
    77 -	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    78 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
    79  	fi
    80  
    81  sysinfo.o: sysinfo.c
    82  	if [ -r sysinfo.c ]; then \
    83 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    84 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
    85  	else \
    86 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    87 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
    88  	fi
    89  
    90  bin2c$(EXEEXT_FOR_BUILD):
    91 -	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    92 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    93  
    94  embedspu: embedspu.sh
    95  	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@