[LEDE-DEV] [RFC 6/8] uclibc++: fix gcc 6 build

Syrone Wong wong.syrone at gmail.com
Wed Jul 13 06:57:06 PDT 2016


C++14 added sized deallocation, while uclibc++ deleted all files
(extracted from libsupc++.a via "ar x") named "del_op*.o"
in abi/libsupc, so I wrote two wrapper files and let them call
free(ptr) and ignored the size parameter.

GCC upstream URL: https://github.com/gcc-mirror/gcc/commit/d1856d2c87b844afb0e31f7aa9502745b3446189

Signed-off-by: Syrone Wong <wong.syrone at gmail.com>
---

According to https://gcc.gnu.org/gcc-6/changes.html,
default C++ mode changed to -std=gnu++14 instead of -std=gnu++98, I added the previous
mode to presist compiler behaviour.

I think the program in OpenWrt/LEDE codebase linked to libuClibc++ will not use C++14 features.
This is the best workaround I can come up with.

 package/libs/uclibc++/Makefile                  |  4 +++
 package/libs/uclibc++/files/040-fix-gcc-6.patch | 34 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+)
 create mode 100644 package/libs/uclibc++/files/040-fix-gcc-6.patch

diff --git a/package/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile
index 4c7c767..cf083a5 100644
--- a/package/libs/uclibc++/Makefile
+++ b/package/libs/uclibc++/Makefile
@@ -71,6 +71,10 @@ define Build/Prepare
 	$(PKG_UNPACK)
 	$(SED) 's/\r$$$$//' $(PKG_BUILD_DIR)/include/unwind-cxx.h
 	$(Build/Patch)
+	$(if $(CONFIG_GCC_VERSION_6),\
+		( cp ./files/040-fix-gcc-6.patch $(PKG_BUILD_DIR)/;\
+		cd $(PKG_BUILD_DIR);\
+		patch -p1 < ./040-fix-gcc-6.patch;))
 endef
 
 define Build/Configure
diff --git a/package/libs/uclibc++/files/040-fix-gcc-6.patch b/package/libs/uclibc++/files/040-fix-gcc-6.patch
new file mode 100644
index 0000000..3023f38
--- /dev/null
+++ b/package/libs/uclibc++/files/040-fix-gcc-6.patch
@@ -0,0 +1,34 @@
+--- a/bin/Makefile
++++ b/bin/Makefile
+@@ -43,7 +43,7 @@ endif
+ 	echo 'fi' >> $@
+ 	echo '' >> $@
+ ifeq ($(DODEBUG),y)
+-	echo 'echo $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
++	echo 'echo $(CXX) -std=gnu++98 $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
+ endif
+-	echo 'exec $(CXX) $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
++	echo 'exec $(CXX) -std=gnu++98 $(GEN_CFLAGS) $(GEN_CXXFLAGS) $(EH_CXXFLAGS) $$WRAPPER_INCLUDEDIR $$WRAPPER_OPTIONS' >> $@
+ 	chmod 755 $@
+--- /dev/null
++++ b/src/del_ops.cpp
+@@ -0,0 +1,8 @@
++#include <new>
++#include <cstdlib>
++#include <func_exception>
++
++_UCXXEXPORT void operator delete(void* ptr, size_t size) throw(){
++	free(ptr);
++}
++
+--- /dev/null
++++ b/src/del_opvs.cpp
+@@ -0,0 +1,8 @@
++#include <new>
++#include <cstdlib>
++#include <func_exception>
++
++_UCXXEXPORT void operator delete[](void * ptr, size_t size) throw(){
++	free(ptr);
++}
++
-- 
2.9.0




More information about the Lede-dev mailing list