uClibc++: Fix three bugs
authorRosen Penev <rosenp@gmail.com>
Mon, 7 Oct 2019 22:59:52 +0000 (15:59 -0700)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 12 Oct 2019 21:43:08 +0000 (23:43 +0200)
The first allows usage of several functions in the std namespace, which
broke compilation of gddrescue specifically with uClibc-ng and uClibc++.

The second allows usage of long long with normal C++11, which is part of
the standard. Before, std=gnu++11 needed to be passsed to work around it.

As a result of the second patch, the pedantic patch can safely be removed.

Both patches are upstream backports.

Added -std=c++11 to CFLAGS to guarentee proper inclusion of long long.

Added another patch that fixes a typo with the long long support. Sent to
upstream.

Fixed up license information according to SPDX.

Small cleanups for consistency.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
package/libs/uclibc++/Makefile
package/libs/uclibc++/patches/002-undef-functions.patch [new file with mode: 0644]
package/libs/uclibc++/patches/003-no-fPIC.patch
package/libs/uclibc++/patches/004-no-pedantic.patch [deleted file]
package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch [new file with mode: 0644]
package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch [new file with mode: 0644]

index 3adf70b3605b89c774410ba860531db91704cd91..7a0d9094ffac35d15d7d400f97eb352040266733 100644 (file)
@@ -10,18 +10,17 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uclibc++
 PKG_VERSION:=0.2.5
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://cxx.uclibc.org/src/
 PKG_HASH:=596fb9ed7295564ce4c70ae6076a18f92e72f70310d70c98520bbca85c77895a
-
 PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
-PKG_BUILD_PARALLEL:=1
-PKG_USE_MIPS16:=0
-PKG_LICENSE:=LGPL-2.1+
 
+PKG_LICENSE:=LGPL-2.1-or-later
 PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
 
 include $(INCLUDE_DIR)/package.mk
 
@@ -45,7 +44,7 @@ UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
        -e 's/mipsel.*/mips/' \
 )
 
-TARGET_CFLAGS += $(FPIC) -nostdinc++
+TARGET_CFLAGS += $(FPIC) -nostdinc++ -std=c++11
 TARGET_LDFLAGS += -Wl,--gc-sections
 
 ifneq ($(CONFIG_CCACHE),)
diff --git a/package/libs/uclibc++/patches/002-undef-functions.patch b/package/libs/uclibc++/patches/002-undef-functions.patch
new file mode 100644 (file)
index 0000000..47fa158
--- /dev/null
@@ -0,0 +1,35 @@
+From 8245f62c1e7aba150f666b3c3a1dda646dee6d4b Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Fri, 27 Sep 2019 13:12:44 -0700
+Subject: [PATCH] cstdio: Add undef for four functions
+
+When compiling with uClibc-ng, these functions get defined as macros and
+become unavailable for std.
+
+Fixes programs that use the std versions of these functions.
+
+This matches libstdcpp behavior.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/cstdio | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/include/cstdio
++++ b/include/cstdio
+@@ -21,6 +21,15 @@
+ #ifndef __HEADER_CSTDIO
+ #define __HEADER_CSTDIO 1
++#undef clearerr
++#undef feof
++#undef ferror
++#undef fgetc
++#undef fputc
++#undef getc
++#undef getchar
++#undef putc
++#undef putchar
+ namespace std{
+       using ::FILE;
index 206a00de32d01676113df4a7e387cdae5dd07b94..dfd8833ae416c098237062169b07047a9a43d140 100644 (file)
@@ -1,6 +1,6 @@
 --- a/Rules.mak
 +++ b/Rules.mak
-@@ -185,7 +185,6 @@ export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_RUNTIME_LIBDIR UCLIBCXX_RUNTIME_BINDIR U
+@@ -185,7 +185,6 @@ export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_
  
  WRAPPER = $(top_builddir)bin/g++-uc
  OPTIMIZATION:=
diff --git a/package/libs/uclibc++/patches/004-no-pedantic.patch b/package/libs/uclibc++/patches/004-no-pedantic.patch
deleted file mode 100644 (file)
index 5128ca3..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
---- a/Rules.mak
-+++ b/Rules.mak
-@@ -200,10 +200,6 @@ $(eval $(call check-gxx-var,-std=gnu++14))
- $(eval $(call check-gxx-var,-Wno-sized-deallocation))
- $(eval $(call check-gxx-var,-Wno-tautological-compare))
--# Add a bunch of extra pedantic annoyingly strict checks
--XWARNINGS=$(call qstrip,$(UCLIBCXX_WARNINGS)) -Wno-trigraphs -pedantic
--CPU_CFLAGS=$(call qstrip,$(CPU_CFLAGS-y))
--
- # Some nice CFLAGS to work with
- GEN_CFLAGS:=-fno-builtin
- CFLAGS:=$(XWARNINGS) $(CPU_CFLAGS)
diff --git a/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch b/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch
new file mode 100644 (file)
index 0000000..6e13f22
--- /dev/null
@@ -0,0 +1,143 @@
+From 8151579eb36d9366632242415ff3f5177fa5e1e2 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Thu, 3 Oct 2019 18:58:43 -0700
+Subject: [PATCH] uClibc++: Make long long available to C++11
+
+C++11 makes long long available. It is no longer a GNU extension.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/istream         | 4 ++--
+ include/istream_helpers | 2 +-
+ include/ostream         | 8 ++++----
+ include/ostream_helpers | 8 ++++----
+ tests/sstreamtest.cpp   | 4 ++--
+ 5 files changed, 13 insertions(+), 13 deletions(-)
+
+--- a/include/istream
++++ b/include/istream
+@@ -72,7 +72,7 @@ namespace std{
+               basic_istream<charT,traits>& operator>>(void*& p);
+               basic_istream<charT,traits>& operator>>(basic_streambuf<char_type,traits>* sb);
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+               basic_istream<charT,traits>& operator>>(long long& n);
+               basic_istream<charT,traits>& operator>>(unsigned long long& n);
+ #endif
+@@ -455,7 +455,7 @@ namespace std{
+               return *this;
+       }
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
+               basic_istream<charT,traits>::operator>>(long long& n)
+       {
+--- a/include/istream_helpers
++++ b/include/istream_helpers
+@@ -301,7 +301,7 @@ namespace std{
+       };
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long long>{
+       public:
+               inline static void readin(basic_istream<char, traits >& stream, long long & var)
+--- a/include/ostream
++++ b/include/ostream
+@@ -85,7 +85,7 @@ namespace std {
+               basic_ostream<charT,traits>& operator<<(long double f);
+               basic_ostream<charT,traits>& operator<<(void* p);
+               basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+               basic_ostream<charT,traits>& operator<<(long long n);
+               basic_ostream<charT,traits>& operator<<(unsigned long long n);
+ #endif
+@@ -221,7 +221,7 @@ namespace std {
+               return *this;
+       }
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long long n)
+       {
+               sentry s(*this);
+@@ -487,7 +487,7 @@ namespace std {
+ #endif
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ //Support for output of long long data types
+@@ -509,7 +509,7 @@ template<class Ch, class Tr> _UCXXEXPORT
+ }
+-#endif        //__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+--- a/include/ostream_helpers
++++ b/include/ostream_helpers
+@@ -142,7 +142,7 @@ namespace std{
+               }
+       };
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, signed long long int>{
+       public:
+@@ -237,7 +237,7 @@ namespace std{
+       };
+-#endif        //__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, double>{
+       public:
+@@ -357,7 +357,7 @@ namespace std{
+               }
+       };
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, signed long long int>{
+       public:
+@@ -428,7 +428,7 @@ namespace std{
+       };
+-#endif        //__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, double>{
+       public:
+--- a/tests/sstreamtest.cpp
++++ b/tests/sstreamtest.cpp
+@@ -9,7 +9,7 @@ int main(){
+       int i;
+       std::string s;
+       char c;
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       long long ll;
+       unsigned long long ull;
+ #endif
+@@ -32,7 +32,7 @@ int main(){
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+       a.str("678 76 54");
+       a >> ll >> ull >> s;
+       std::cout << "ll (should be 678): " << ll << std::endl;
diff --git a/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch b/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch
new file mode 100644 (file)
index 0000000..66b62c1
--- /dev/null
@@ -0,0 +1,37 @@
+From 7f6dd860818512c0eb313320308b22ba7e2c7205 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Fri, 4 Oct 2019 20:06:53 -0700
+Subject: [PATCH] istream_helpers: Fix sscanf typo
+
+This caused readin not to work properly with long long types.
+
+Found accidentally through a glibc warning
+(declared with warn_unused_result).
+
+Tested with gptfdisk on OpenWrt.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/istream_helpers | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/include/istream_helpers
++++ b/include/istream_helpers
+@@ -317,7 +317,7 @@ namespace std{
+                                       sscanf(temp.c_str(), "%llo", (unsigned long long *)&var );
+                               }else if(stream.flags() & ios_base::hex){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              scanf(temp.c_str(), "%llX", (unsigned long long *)&var );
++                                              sscanf(temp.c_str(), "%llX", (unsigned long long *)&var );
+                                       }else{
+                                               sscanf(temp.c_str(), "%llx", (unsigned long long *)&var);
+                                       }
+@@ -344,7 +344,7 @@ namespace std{
+                                       sscanf(temp.c_str(), "%llo", &var );
+                               }else if(stream.flags() & ios_base::hex){
+                                       if(stream.flags() & ios_base::uppercase){
+-                                              scanf(temp.c_str(), "%llX", &var );
++                                              sscanf(temp.c_str(), "%llX", &var );
+                                       }else{
+                                               sscanf(temp.c_str(), "%llx", &var);
+                                       }