From a4ea91a4db69a4eb6e98252ee481b866c15f1b3f Mon Sep 17 00:00:00 2001 From: John Marino Date: Tue, 10 Feb 2015 20:28:22 +0100 Subject: [PATCH] Fix static archive libstdc++.a for gcc 5.0 The libstdc++ libaries for gcc 5.0 are built differently than they have been in the past, and closely mirror what the vendor build system does. Three "convenience" librarys are built first: c++98, c++11, and supc++. Both static and PIC versions are built. The final library combines the three components along with about 10 unique objects. It worked fine for the shared version (libstd.so.9) but the static version was unreadable. I fixed it by creating a dedicated "ar" script to dictate what gets assembled in the new static archive. It would have been a sweet solution has "ar" not had an incredible limitation: The script can not have consecutive "+" characters on any line. To work around this, I had to: 1) rename the 3 component libraries (all had ++ in the name) 2) rename the output library (libstdc++.a => libstdcxx.a) 3) copy all the cc files with "++" in their names to a new filename. This affected about 3-4 files. 4) move the output library back to the proper name of libstdc++.a What a pain those hacks were, but it works and gcc-5.0 can now build itself. It still can't complete world due to Werror trigging on new warnings, but it's a good fix. --- .../components/libconv_1998/Makefile | 2 +- .../components/libconv_2011/Makefile | 2 +- .../components/libconv_supc/Makefile | 21 ++++++--- gnu/lib/gcc50/libstdcxx/headers/Makefile | 8 +--- gnu/lib/gcc50/libstdcxx/product/Makefile | 43 +++++++++++++++---- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/gnu/lib/gcc50/libstdcxx/components/libconv_1998/Makefile b/gnu/lib/gcc50/libstdcxx/components/libconv_1998/Makefile index 9042467ec2..ea0081eb79 100644 --- a/gnu/lib/gcc50/libstdcxx/components/libconv_1998/Makefile +++ b/gnu/lib/gcc50/libstdcxx/components/libconv_1998/Makefile @@ -3,7 +3,7 @@ RELUP= /../.. SRCDIR= ${GCCDIR}/libstdc++-v3 .include "Makefile.src" -LIB= c++98convenience +LIB= cxx98convenience INTERNALLIB= yes NOPROFILE= yes INSTALL_PIC_ARCHIVE= yes diff --git a/gnu/lib/gcc50/libstdcxx/components/libconv_2011/Makefile b/gnu/lib/gcc50/libstdcxx/components/libconv_2011/Makefile index 7cf85ab1a4..f819741fd2 100644 --- a/gnu/lib/gcc50/libstdcxx/components/libconv_2011/Makefile +++ b/gnu/lib/gcc50/libstdcxx/components/libconv_2011/Makefile @@ -3,7 +3,7 @@ RELUP= /../.. SRCDIR= ${GCCDIR}/libstdc++-v3 .include "Makefile.src" -LIB= c++11convenience +LIB= cxx11convenience INTERNALLIB= yes NOPROFILE= yes INSTALL_PIC_ARCHIVE= yes diff --git a/gnu/lib/gcc50/libstdcxx/components/libconv_supc/Makefile b/gnu/lib/gcc50/libstdcxx/components/libconv_supc/Makefile index bcfb1fa9dd..1e3b599629 100644 --- a/gnu/lib/gcc50/libstdcxx/components/libconv_supc/Makefile +++ b/gnu/lib/gcc50/libstdcxx/components/libconv_supc/Makefile @@ -3,7 +3,7 @@ RELUP= /../.. SRCDIR= ${GCCDIR}/libstdc++-v3 .include "Makefile.src" -LIB= supc++convenience +LIB= supcxxconvenience INTERNALLIB= yes NOPROFILE= yes INSTALL_PIC_ARCHIVE= yes @@ -12,11 +12,11 @@ INSTALL_PIC_ARCHIVE= yes .PATH: ${GCCDIR}/libgcc .PATH: ${SRCDIR}/libsupc++ -CFLAGS+= -I${.OBJDIR} -CFLAGS+= -I${GCCDIR}/libgcc -CXXFLAGS+= -fno-implicit-templates -CXXFLAGS+= -fdiagnostics-show-location=once -CXXFLAGS+= -ffunction-sections -fdata-sections +CFLAGS+= -I${.OBJDIR} +CFLAGS+= -I${GCCDIR}/libgcc +CXXFLAGS+= -fno-implicit-templates +CXXFLAGS+= -fdiagnostics-show-location=once +CXXFLAGS+= -ffunction-sections -fdata-sections SHARED_CXXFLAGS= -D_GLIBCXX_SHARED FLAGS_GROUPS= gnu11 gnu14 mangle @@ -30,6 +30,13 @@ gnu14_FLAGS_FILES= del_ops.cc del_opvs.cc mangle_FLAGS= -DIN_GLIBCPP_V3 mangle_FLAGS_FILES= cp-demangle.c -SRCS= ${libsupc__convenience_la_SOURCES} +SRCS= ${libsupc__convenience_la_SOURCES} + +unwind.h: unwind-generic.h + cp ${.ALLSRC} ${.TARGET} + +GENHD= unwind.h +CLEANFILES= ${GENHD} +beforedepend: ${GENHD} .include diff --git a/gnu/lib/gcc50/libstdcxx/headers/Makefile b/gnu/lib/gcc50/libstdcxx/headers/Makefile index fdc23b20a8..6d523d89b0 100644 --- a/gnu/lib/gcc50/libstdcxx/headers/Makefile +++ b/gnu/lib/gcc50/libstdcxx/headers/Makefile @@ -49,12 +49,6 @@ host_headers_extraNAME_c_locale.h= c++locale.h host_headers_extraNAME_c_io_stdio.h+= c++io.h host_headers_extraNAME_new_allocator_base.h= c++allocator.h -unwind.h: unwind-generic.h - cp ${.ALLSRC} ${.TARGET} - -unwind-cxx.h: ${SRCDIR}/libsupc++/unwind-cxx.h - cp ${.ALLSRC} ${.TARGET} - cxxabi_forced.h: ${SRCDIR}/libsupc++/cxxabi_forced.h cp ${.ALLSRC} ${.TARGET} @@ -109,6 +103,6 @@ c++config.h: config.h echo "#endif // _GLIBCXX_CXX_CONFIG_H" >> ${.TARGET} CLEANFILES= gthr.h gthr-default.h gthr-single.h gthr-posix.h \ - c++config.h + c++config.h cxxabi_forced.h .include diff --git a/gnu/lib/gcc50/libstdcxx/product/Makefile b/gnu/lib/gcc50/libstdcxx/product/Makefile index ddb1f75511..c0e8274315 100644 --- a/gnu/lib/gcc50/libstdcxx/product/Makefile +++ b/gnu/lib/gcc50/libstdcxx/product/Makefile @@ -18,21 +18,46 @@ VERSION_MAP= ${.CURDIR}/libstdc++-symbols.ver FLAGS_GROUPS= gnu11 gnu11_FLAGS= -std=gnu++11 -gnu11_FLAGS_FILES= ${cxx11_sources} +gnu11_FLAGS_FILES= ${cxx11_sources:S|++|xx|} -CONVARCS= ../components/libconv_supc/libsupc++convenience.a -CONVARCS+= ../components/libconv_1998/libc++98convenience.a -CONVARCS+= ../components/libconv_2011/libc++11convenience.a +CONVARCS= ../components/libconv_supc/libsupcxxconvenience.a +CONVARCS+= ../components/libconv_1998/libcxx98convenience.a +CONVARCS+= ../components/libconv_2011/libcxx11convenience.a LDADD= -Wl,--whole-archive ${CONVARCS:.a=_pic.a} -lm LDADD+= -Wl,--no-whole-archive ARADD= ${CONVARCS} ${LIBM} -SRCS= ${libstdc___la_SOURCES} +# The AR script is a nice trick, but it *cannot* handle "++" on any line +# To work around this incredible limitation, copy files with "++" in +# their names to a new file name (transform ++ => xx) -gstdint.h: - echo "#include " > ${.TARGET} +SRCS= ${libstdc___la_SOURCES:S|++|xx|} +PROBLEMS= ${libstdc___la_SOURCES:M*++*} + +libstdc++.a: ${SRCS:.cc=.o} script.ar + @${ECHO} building static ${LIB} library via script + rm -f ${.TARGET} + ${AR} -M < script.ar + mv libstdcxx.a ${.TARGET} -beforedepend: gstdint.h -CLEANFILES= gstdint.h +${PROBLEMS:S|++|xx|}: ${PROBLEMS} + cp ${SRCDIR}/src/c++11/${.TARGET:S|xx|++|} ${.TARGET} + +gstdint.h: + @echo "#include " > ${.TARGET} + +script.ar: + @echo "CREATE libstdcxx.a" > ${.TARGET} +.for arc in ${CONVARCS} + @echo "ADDLIB ${arc}" >> ${.TARGET} +.endfor +.for obj in ${SRCS:.cc=.o} + @echo "ADDMOD ${obj}" >> ${.TARGET} +.endfor + @echo "SAVE" >> ${.TARGET} + @echo "END" >> ${.TARGET} + +beforedepend: gstdint.h script.ar ${PROBLEMS:S|++|xx|} +CLEANFILES= gstdint.h script.ar ${PROBLEMS:S|++|xx|} .include -- 2.41.0