patches/binutils/2.20.1/280-unexport_LD_LIBRARY_PATH.patch
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Wed May 18 23:00:46 2011 +0200 (2011-05-18)
changeset 2467 200836977ce6
parent 1700 eccc37dd1a25
permissions -rw-r--r--
config: rename variables that are arrays

Make it explicit that a variable is an array bu the name of the variable.
It will be used later when .config gets munged to allow both multiple
arguments and arguments with spaces at the same time to be passed from the
configuration down to the build scripts.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
     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 
    29 diff -durN binutils-2.20.1.orig/binutils/Makefile.am binutils-2.20.1/binutils/Makefile.am
    30 --- binutils-2.20.1.orig/binutils/Makefile.am	2010-01-14 11:48:22.000000000 +0100
    31 +++ binutils-2.20.1/binutils/Makefile.am	2010-08-17 19:32:24.000000000 +0200
    32 @@ -251,24 +251,24 @@
    33  	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    34  
    35  sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    36 -	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    37 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    38  
    39  syslex.o: syslex.c sysinfo.h config.h
    40  	if [ -r syslex.c ]; then \
    41 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    42 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    43  	else \
    44 -	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    45 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    46  	fi
    47  
    48  sysinfo.o: sysinfo.c
    49  	if [ -r sysinfo.c ]; then \
    50 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    51 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    52  	else \
    53 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    54 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    55  	fi
    56  
    57  bin2c$(EXEEXT_FOR_BUILD):
    58 -	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    59 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    60  
    61  embedspu: embedspu.sh
    62  	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
    63 diff -durN binutils-2.20.1.orig/binutils/Makefile.in binutils-2.20.1/binutils/Makefile.in
    64 --- binutils-2.20.1.orig/binutils/Makefile.in	2010-03-03 14:59:46.000000000 +0100
    65 +++ binutils-2.20.1/binutils/Makefile.in	2010-08-17 19:32:24.000000000 +0200
    66 @@ -1193,24 +1193,24 @@
    67  	./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
    68  
    69  sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
    70 -	$(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    71 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
    72  
    73  syslex.o: syslex.c sysinfo.h config.h
    74  	if [ -r syslex.c ]; then \
    75 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    76 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) syslex.c ; \
    77  	else \
    78 -	  $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    79 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/syslex.c ;\
    80  	fi
    81  
    82  sysinfo.o: sysinfo.c
    83  	if [ -r sysinfo.c ]; then \
    84 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    85 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) sysinfo.c ; \
    86  	else \
    87 -	  $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    88 +	  LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(NO_WERROR) $(srcdir)/sysinfo.c ; \
    89  	fi
    90  
    91  bin2c$(EXEEXT_FOR_BUILD):
    92 -	$(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    93 +	LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
    94  
    95  embedspu: embedspu.sh
    96  	sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@