gcc: fix libstdc++_pic for AVR32
PATCH 1/1 gcc: fix libstdc++_pic for AVR32
It is not clear why 300-libstdc++-pic.patch pre-applied to
gcc-4.2.2-avr32-2.1.5 seems to have come from some older version
of gcc (as early as 4.0.3). This older patch incorrectly refers to
object files to be included in the library libstdc++_pic.a as *.o,
while their location seems to be in .libs/*.o (see the contents at
e.g. https://github.com/ZigFisher/Midge/blob/master/toolchain/gcc/4.0.3/300-libstdc%2B%2B-pic.patch ). The same patch for gcc 4.1.0 refers to the files as .libs/*.o (see
https://github.com/ZigFisher/Midge/blob/master/toolchain/gcc/4.1.0/300-libstdc%2B%2B-pic.patch ). This patch corrects rules in Makefile.in.
--- .../990-fix-300-libstdc++-pic.patch | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 package/gcc/4.2.2-avr32-2.1.5/990-fix-300-libstdc++-pic.patch
package/gcc/4.2.2-avr32-2.1.5/990-fix-300-libstdc++-pic.patch new file +20 -0
@@ -0,0 +1,20 @@ +libstdc++-v3: fix the effects of pre-applied 300-libstdc++-pic.patch + +This version of GCC comes with a number of pre-applied patches, among which is +300-libstdc++-pic.patch that makes a PIC version of libstdc++. The resulting +Makefile.in incorrectly refers to object files that should be insde the library. + +Signed-off-by: Alexander Lukichev <[email protected]> + +diff -uNrp host-gcc-final-4.2.2-avr32-2.1.5.orig/libstdc++-v3/src/Makefile.in host-gcc-final-4.2.2-avr32-2.1.5/libstdc++-v3/src/Makefile.in +--- host-gcc-final-4.2.2-avr32-2.1.5.orig/libstdc++-v3/src/Makefile.in 2008-07-04 00:18:42.000000000 +0300 ++++ host-gcc-final-4.2.2-avr32-2.1.5/libstdc++-v3/src/Makefile.in 2013-08-08 16:15:56.201258882 +0300 +@@ -804,7 +804,7 @@ install_debug: + + install-exec-local: + ifeq ($(enable_shared),yes) +- $(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o ++ $(AR) cru libstdc++_pic.a .libs/*.o $(top_builddir)/libsupc++/*.o + $(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir) + endif +
Signature · 1 line
1.8.0.1
PATCH 1/1 gcc: fix libstdc++_pic for AVR32
Dear Alexander Lukichev,
Quoted 1 line · Alexander Lukichev
It is not clear why 300-libstdc++-pic.patch pre-applied to
Which 300-libstdc++-pic.patch are you referring to? I don't see anyone in Buildroot.
Simon, Thiago, as our AVR32 people, why do you think of Alexander's patch? Can you give it a spin and tell me what you think?
Thanks,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH 1/1 gcc: fix libstdc++_pic for AVR32
Quoted 2 lines · Thomas Petazzoni
Simon, Thiago, as our AVR32 people, why do you think of Alexander's patch? Can you give it a spin and tell me what you think?
I'm not sure what specific problem this patch is meant to address.
Alexander: are you trying to solve a build problem here? Or a target runtime problem? Perhaps the patch description could be expanded a little...?
Simon
PATCH 1/1 gcc: fix libstdc++_pic for AVR32
Hello,
Sorry for the late reply, was on a trip on weekend.
2013/8/10 Simon Dawson <[email protected]>
Quoted 4 lines
I'm not sure what specific problem this patch is meant to address.
Alexander: are you trying to solve a build problem here? Or a target runtime problem? Perhaps the patch description could be expanded a little...?
The patch I sent fixes a build problem for me, that arises during the
final stage when libstdc++ is built:
/home/alukiche/Projects/buildroot/buildroot-project/output/host/usr/avr32-buildroot-linux-uclibc/bin/ar
cru libstdc++_pic.a *.o ../libsupc++/*.o /home/alukiche/Projects/buildroot/buildroot-project/output/host/usr/avr32-buildroot-linux-uclibc/bin/ar:
*.o: No such file or directory
make[5]: *** [install-exec-local] Error 1
make[5]: Leaving directory `/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/build/avr32-buildroot-linux-uclibc/libstdc++-v3/src' make[4]: *** [install-am] Error 2
make[4]: Leaving directory `/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/build/avr32-buildroot-linux-uclibc/libstdc++-v3/src' make[3]: *** [install-recursive] Error 1
make[3]: Leaving directory `/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/build/avr32-buildroot-linux-uclibc/libstdc++-v3' make[2]: *** [install-target-libstdc++-v3] Error 2
make[2]: Leaving directory `/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/build'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/build'
make: *** [/home/alukiche/Projects/buildroot/buildroot-project/output/build/host-gcc-final-4.2.2-avr32-2.1.5/.stamp_host_installed] Error 2
Lines in
host-gcc-final-4.2.2-avr32-2.1.5/build/avr32-buildroot-linux-uclibc/libstdc++-v3/src/Makefile
install-exec-local:
ifeq ($(enable_shared),yes)
$(AR) cru libstdc++_pic.a *.o $(top_builddir)/libsupc++/*.o
$(INSTALL_DATA) libstdc++_pic.a $(DESTDIR)$(toolexeclibdir)endif
are triggered, failing to find object files for the library libstdc++_pic.a. These files are actually located in .libs/ subdirectory, not in the current directory (where that Makefile is located). This happens when I build AVR32 toolchain with C++ support. I have attached a defconfig that triggers the problem on my host machine.
The triggered lines come from a patch file named 300-libstdc++-pic.patch
that has apparently been applied to GCC 4.2.2 before it was packaged into an archive file gcc-4.2.2-avr32-2.1.5.tar.bz2 (see .applied_patches_list inside this archive). Googling for it revealed that this patch has been used for different versions of the toolchain for AVR32 and MIPS, changing a little with each version to adapt to it. I have found several versions of this patch in a repository for Midge (a project for ADM5120 MIPS microcontroller):
https://github.com/ZigFisher/Midge/tree/master/toolchain/gcc . The patch appears as early as 3.4.4 and alterates in reference to those object files between './' (in gcc 4.0.3) and '.libs/' (in gcc 3.4.4, 3.4.5, 3.4.6, 4.1.0). I have not found a version of this patch for 4.2.2 but concluded that since it fails to find object files for libstdc++_pic.a in current directory and from version to version of gcc it alterates between './' and '.libs/', for 4.2.2 they must be in '.libs/'.
I have checked that object files in '.libs/' indeed contain position
independent code (I looked at the build log, where -fPIC has been given to commands that compile these files; and checked randomly with 'nm <file> | grep _GLOBAL_OFFSET_TABLE_'). And I have build-tested several C++ packages with the built toolchain. I did not go as far as trying to run them: no AVR32 hardware at hand and I am not skilled enough to set up an AVR32 virtual environment quickly.
Without this fix the GCC fails to build with C++ support always, at least
on my host machine ('gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)', binutils 2.20.51.0.7-8.fc14). The fix solves the problem.
It seems strange to me that GCC 4.2.2 for AVR32 is so dependent on which
machine it is built on: apparently not many people on this list have encountered the problem that I have experienced.
Thomas Petazzoni, should I send an updated version of my patch with a
concise version of the explanation above or is it not worth it? Thanks.
--
Best regards,
Alexander Lukichev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130812/3ec1dd0d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: defconfig
Type: application/octet-stream
Size: 260 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20130812/3ec1dd0d/attachment-0001.obj>
PATCH 1/1 gcc: fix libstdc++_pic for AVR32
Quoted 3 lines · Alexander Lukichev
Without this fix the GCC fails to build with C++ support always, at least
on my host machine ('gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)', binutils 2.20.51.0.7-8.fc14). The fix solves the problem.
This works for me too, hence:
Thomas Petazzoni
AppliedPATCH 1/1 gcc: fix libstdc++_pic for AVR32
In reply to Alexander LukichevDear Alexander Lukichev,
Quoted 11 lines · Alexander Lukichev
It is not clear why 300-libstdc++-pic.patch pre-applied to
gcc-4.2.2-avr32-2.1.5 seems to have come from some older version
of gcc (as early as 4.0.3). This older patch incorrectly refers to
object files to be included in the library libstdc++_pic.a as *.o,
while their location seems to be in .libs/*.o (see the contents at
e.g. https://github.com/ZigFisher/Midge/blob/master/toolchain/gcc/4.0.3/300-libstdc%2B%2B-pic.patch ). The same patch for gcc 4.1.0 refers to the files as .libs/*.o (see
https://github.com/ZigFisher/Midge/blob/master/toolchain/gcc/4.1.0/300-libstdc%2B%2B-pic.patch ). This patch corrects rules in Makefile.in.Signed-off-by Alexander Lukichev <[email protected]>
Applied, thanks.
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com