binutils-2.20: Fix cross native build when using same version on build
authorKhem Raj <raj.khem@gmail.com>
Thu, 31 Dec 2009 00:42:01 +0000 (16:42 -0800)
committerKhem Raj <raj.khem@gmail.com>
Mon, 4 Jan 2010 21:03:39 +0000 (13:03 -0800)
machine.

Signed-off-by: Khem Raj <raj.khem@gmail.com>
recipes/binutils/binutils-2.20/binutils_unexport_LD_LIBRARY_PATH_for_CC_FOR_BUILD.patch [new file with mode: 0644]
recipes/binutils/binutils_2.20.bb

diff --git a/recipes/binutils/binutils-2.20/binutils_unexport_LD_LIBRARY_PATH_for_CC_FOR_BUILD.patch b/recipes/binutils/binutils-2.20/binutils_unexport_LD_LIBRARY_PATH_for_CC_FOR_BUILD.patch
new file mode 100644 (file)
index 0000000..535d714
--- /dev/null
@@ -0,0 +1,95 @@
+Description:
+
+This patch is needed in situations where build system is running same version of
+binutils that is intended to be built  cross-native ( build != host = target)
+ and has shared libraries enabled. binutils/binutils
+Makefile has some tools which are built to run on build system. Toplevel makefile
+for binutils passes HOST_EXPORTS to sub-makefiles which also include RPATH_ENVVARS
+containing LD_LIBRARY_PATH which is modified so that it also includes host libraries
+like opcodes and libbfd which are just built for the host system. 
+
+Now the problem is that same LD_LIBRARY_PATH value gets set in environment even
+for the tools that are being built for build system using CC_FOR_BUILD and the tools
+like as,ld it invokes from build machine get the LD_LIBRARY_PATH set to search
+the newly build host libraries like opcodes and bfd and if host is like a big endian
+system say (mips-linux) the build system linker and assembler do not run because
+ld.so tries to load these shared libraries instead of the ones from /usr/lib for 
+the build tools. 
+
+This patch fixes the issue by clearing LD_LIBRARY_PATH for BUILD tools
+
+This patch would be needed on other versions of binutils. I just cared about 2.20
+May be upstream is also interested in such a patch.
+
+-Khem
+
+Index: binutils-2.20/binutils/Makefile.am
+===================================================================
+--- binutils-2.20.orig/binutils/Makefile.am    2009-12-30 15:30:35.302438121 -0800
++++ binutils-2.20/binutils/Makefile.am 2009-12-30 15:33:09.154420373 -0800
+@@ -251,24 +251,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
+       ./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
+ sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
+-      $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
++      LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
+ syslex.o: syslex.c sysinfo.h config.h
+       if [ -r syslex.c ]; then \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
+       else \
+-        $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
+       fi
+ sysinfo.o: sysinfo.c
+       if [ -r sysinfo.c ]; then \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
+       else \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
+       fi
+ bin2c$(EXEEXT_FOR_BUILD):
+-      $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
++      LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
+ embedspu: embedspu.sh
+       sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
+Index: binutils-2.20/binutils/Makefile.in
+===================================================================
+--- binutils-2.20.orig/binutils/Makefile.in    2009-12-30 15:30:44.582922535 -0800
++++ binutils-2.20/binutils/Makefile.in 2009-12-30 15:33:47.322422313 -0800
+@@ -1193,24 +1193,24 @@ sysroff.h: sysinfo$(EXEEXT_FOR_BUILD) sy
+       ./sysinfo$(EXEEXT_FOR_BUILD) -d <$(srcdir)/sysroff.info >sysroff.h
+ sysinfo$(EXEEXT_FOR_BUILD): sysinfo.o syslex.o
+-      $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
++      LD_LIBRARY_PATH= $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@ sysinfo.o syslex.o
+ syslex.o: syslex.c sysinfo.h config.h
+       if [ -r syslex.c ]; then \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) syslex.c -Wno-error ; \
+       else \
+-        $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. -I$(srcdir) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/syslex.c -Wno-error ;\
+       fi
+ sysinfo.o: sysinfo.c
+       if [ -r sysinfo.c ]; then \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) sysinfo.c -Wno-error ; \
+       else \
+-        $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
++        LD_LIBRARY_PATH= $(CC_FOR_BUILD) -c -I. $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(srcdir)/sysinfo.c -Wno-error ; \
+       fi
+ bin2c$(EXEEXT_FOR_BUILD):
+-      $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
++      LD_LIBRARY_PATH= $(CC_FOR_BUILD) -o $@ $(AM_CPPFLAGS) $(AM_CFLAGS) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(srcdir)/bin2c.c $(srcdir)/version.c
+ embedspu: embedspu.sh
+       sed "s@^program_transform_name=@program_transform_name=$(program_transform_name)@" < $< > $@
index 6961377..6863582 100644 (file)
@@ -2,7 +2,7 @@ require binutils.inc
 LICENSE = "GPLv3"
 
 INC_PR = "r1"
-PR = "${INC_PR}.3"
+PR = "${INC_PR}.4"
 
 SRC_URI = "\
      ${GNU_MIRROR}/binutils/binutils-${PV}.tar.bz2 \
@@ -14,6 +14,7 @@ SRC_URI = "\
      file://binutils-uclibc-gas-needs-libm.patch;patch=1 \
      file://ld-stub-crash.patch;patch=1;pnum=0 \
      file://binutils-arm-non-empty-know.patch;patch=1 \
+     file://binutils_unexport_LD_LIBRARY_PATH_for_CC_FOR_BUILD.patch;patch=1 \
      "
 
 # powerpc patches