You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/11/15 11:29:41 UTC
[incubator-nuttx] 01/04: [libc++] Cherry pick patches from mainline
to fix warnings
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 8bc4a5b08adf3d6e697db51babbcf4ab80c74d67
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Wed Nov 11 20:37:45 2020 +0800
[libc++] Cherry pick patches from mainline to fix warnings
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
libs/libxx/0001-libc-Fix-a-few-warnings.patch | 43 +++++++
...sts-failing-with-Clang-after-removing-GCC.patch | 26 ++++
...ix-several-GCC-warnings-in-the-test-suite.patch | 135 +++++++++++++++++++++
...k-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch | 78 ++++++++++++
libs/libxx/libcxx.defs | 4 +
5 files changed, 286 insertions(+)
diff --git a/libs/libxx/0001-libc-Fix-a-few-warnings.patch b/libs/libxx/0001-libc-Fix-a-few-warnings.patch
new file mode 100644
index 0000000..b7bb109
--- /dev/null
+++ b/libs/libxx/0001-libc-Fix-a-few-warnings.patch
@@ -0,0 +1,43 @@
+From acd7be74ca12f8f08e52d6d80850a9b230109134 Mon Sep 17 00:00:00 2001
+From: YAMAMOTO Takashi <ya...@midokura.com>
+Date: Wed, 28 Oct 2020 15:40:16 -0400
+Subject: [PATCH] [libc++] Fix a few warnings
+
+Found during a NuttX porting effort.
+But these changes are not directly relevant to NuttX.
+
+Differential Revision: https://reviews.llvm.org/D90139
+---
+ src/filesystem/operations.cpp | 2 +-
+ src/locale.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/filesystem/operations.cpp libcxx/src/filesystem/operations.cpp
+index 95d7d0d9642..788e31b673a 100644
+--- a/src/filesystem/operations.cpp
++++ libcxx/src/filesystem/operations.cpp
+@@ -534,7 +534,7 @@ path __canonical(path const& orig_p, error_code* ec) {
+ ErrorHandler<path> err("canonical", ec, &orig_p, &cwd);
+
+ path p = __do_absolute(orig_p, &cwd, ec);
+-#if _POSIX_VERSION >= 200112
++#if defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112
+ std::unique_ptr<char, decltype(&::free)>
+ hold(::realpath(p.c_str(), nullptr), &::free);
+ if (hold.get() == nullptr)
+diff --git a/src/locale.cpp libcxx/src/locale.cpp
+index b9180880e49..02dbb334ff8 100644
+--- a/src/locale.cpp
++++ libcxx/src/locale.cpp
+@@ -1149,7 +1149,7 @@ ctype<char>::__classic_upper_table() _NOEXCEPT
+ {
+ return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
+ }
+-#elif __NetBSD__
++#elif defined(__NetBSD__)
+ const short*
+ ctype<char>::__classic_lower_table() _NOEXCEPT
+ {
+--
+2.17.1
+
diff --git a/libs/libxx/0001-libc-Fix-tests-failing-with-Clang-after-removing-GCC.patch b/libs/libxx/0001-libc-Fix-tests-failing-with-Clang-after-removing-GCC.patch
new file mode 100644
index 0000000..5e28838
--- /dev/null
+++ b/libs/libxx/0001-libc-Fix-tests-failing-with-Clang-after-removing-GCC.patch
@@ -0,0 +1,26 @@
+From 81b6aa0e27abc3037c84d1ff2065bf60207f9b8b Mon Sep 17 00:00:00 2001
+From: Louis Dionne <ld...@apple.com>
+Date: Fri, 30 Oct 2020 14:55:37 -0400
+Subject: [PATCH] [libc++] Fix tests failing with Clang after removing GCC
+ warnings
+
+---
+ src/filesystem/filesystem_common.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/filesystem/filesystem_common.h libcxx/src/filesystem/filesystem_common.h
+index a7828ef3863..dc55f93da70 100644
+--- a/src/filesystem/filesystem_common.h
++++ libcxx/src/filesystem/filesystem_common.h
+@@ -198,7 +198,7 @@ private:
+ using chrono::duration;
+ using chrono::duration_cast;
+
+-using TimeSpec = std::timespec;
++using TimeSpec = timespec;
+ using StatT = struct stat;
+
+ template <class FileTimeT, class TimeT,
+--
+2.17.1
+
diff --git a/libs/libxx/0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch b/libs/libxx/0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch
new file mode 100644
index 0000000..e412923
--- /dev/null
+++ b/libs/libxx/0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch
@@ -0,0 +1,135 @@
+From c479e0c99459e4c5596c2a22829d0937224df0bf Mon Sep 17 00:00:00 2001
+From: Louis Dionne <ld...@apple.com>
+Date: Fri, 30 Oct 2020 11:19:07 -0400
+Subject: [PATCH] [libc++] NFC: Fix several GCC warnings in the test suite
+
+- Several -Wshadow warnings
+- Several places where we did not initialize our base class explicitly
+- Unused variable warnings
+- Some tautological comparisons
+- Some places where we'd pass null arguments to functions expecting
+ non-null (in unevaluated contexts)
+- Add a few pragmas to turn off spurious warnings
+- Fix warnings about declarations that don't declare anything
+- Properly disable deprecation warnings in ext/ tests (the pragmas we
+ were using didn't work on GCC)
+- Disable include_as_c.sh.cpp because GCC complains about C++ flags
+ when compiling as C. I couldn't find a way to fix this one properly,
+ so I'm disabling the test. This isn't great, but at least we'll be
+ able to enable warnings in the whole test suite with GCC.
+---
+ src/filesystem/filesystem_common.h | 55 ++++++++++++-----------
+ 1 file changed, 28 insertions(+), 27 deletions(-)
+
+diff --git a/src/filesystem/filesystem_common.h libcxx/src/filesystem/filesystem_common.h
+index fe5c42f5e6d..a7828ef3863 100644
+--- a/src/filesystem/filesystem_common.h
++++ libcxx/src/filesystem/filesystem_common.h
+@@ -13,8 +13,9 @@
+ #include "filesystem"
+ #include "array"
+ #include "chrono"
+-#include "cstdlib"
+ #include "climits"
++#include "cstdlib"
++#include "ctime"
+
+ #include <unistd.h>
+ #include <sys/stat.h>
+@@ -47,7 +48,7 @@ static string format_string_imp(const char* msg, ...) {
+ struct GuardVAList {
+ va_list& target;
+ bool active = true;
+- GuardVAList(va_list& target) : target(target), active(true) {}
++ GuardVAList(va_list& tgt) : target(tgt), active(true) {}
+ void clear() {
+ if (active)
+ va_end(target);
+@@ -134,50 +135,50 @@ path error_value<path>() {
+
+ template <class T>
+ struct ErrorHandler {
+- const char* func_name;
+- error_code* ec = nullptr;
+- const path* p1 = nullptr;
+- const path* p2 = nullptr;
++ const char* func_name_;
++ error_code* ec_ = nullptr;
++ const path* p1_ = nullptr;
++ const path* p2_ = nullptr;
+
+ ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
+ const path* p2 = nullptr)
+- : func_name(fname), ec(ec), p1(p1), p2(p2) {
+- if (ec)
+- ec->clear();
++ : func_name_(fname), ec_(ec), p1_(p1), p2_(p2) {
++ if (ec_)
++ ec_->clear();
+ }
+
+- T report(const error_code& m_ec) const {
+- if (ec) {
+- *ec = m_ec;
++ T report(const error_code& ec) const {
++ if (ec_) {
++ *ec_ = ec;
+ return error_value<T>();
+ }
+- string what = string("in ") + func_name;
+- switch (bool(p1) + bool(p2)) {
++ string what = string("in ") + func_name_;
++ switch (bool(p1_) + bool(p2_)) {
+ case 0:
+- __throw_filesystem_error(what, m_ec);
++ __throw_filesystem_error(what, ec);
+ case 1:
+- __throw_filesystem_error(what, *p1, m_ec);
++ __throw_filesystem_error(what, *p1_, ec);
+ case 2:
+- __throw_filesystem_error(what, *p1, *p2, m_ec);
++ __throw_filesystem_error(what, *p1_, *p2_, ec);
+ }
+ _LIBCPP_UNREACHABLE();
+ }
+
+ template <class... Args>
+- T report(const error_code& m_ec, const char* msg, Args const&... args) const {
+- if (ec) {
+- *ec = m_ec;
++ T report(const error_code& ec, const char* msg, Args const&... args) const {
++ if (ec_) {
++ *ec_ = ec;
+ return error_value<T>();
+ }
+ string what =
+- string("in ") + func_name + ": " + format_string(msg, args...);
+- switch (bool(p1) + bool(p2)) {
++ string("in ") + func_name_ + ": " + format_string(msg, args...);
++ switch (bool(p1_) + bool(p2_)) {
+ case 0:
+- __throw_filesystem_error(what, m_ec);
++ __throw_filesystem_error(what, ec);
+ case 1:
+- __throw_filesystem_error(what, *p1, m_ec);
++ __throw_filesystem_error(what, *p1_, ec);
+ case 2:
+- __throw_filesystem_error(what, *p1, *p2, m_ec);
++ __throw_filesystem_error(what, *p1_, *p2_, ec);
+ }
+ _LIBCPP_UNREACHABLE();
+ }
+@@ -197,8 +198,8 @@ private:
+ using chrono::duration;
+ using chrono::duration_cast;
+
+-using TimeSpec = struct ::timespec;
+-using StatT = struct ::stat;
++using TimeSpec = std::timespec;
++using StatT = struct stat;
+
+ template <class FileTimeT, class TimeT,
+ bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
+--
+2.17.1
+
diff --git a/libs/libxx/0001-libcxx-Check-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch b/libs/libxx/0001-libcxx-Check-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch
new file mode 100644
index 0000000..8757259
--- /dev/null
+++ b/libs/libxx/0001-libcxx-Check-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch
@@ -0,0 +1,78 @@
+From 3e8b517a509ae043571d8d0b00625d8a03eb5d05 Mon Sep 17 00:00:00 2001
+From: Xiang Xiao <xi...@xiaomi.com>
+Date: Mon, 9 Nov 2020 21:45:57 +0800
+Subject: [PATCH] [libcxx] Check _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE first in
+ __locale
+
+just like what's done in __locale.cpp
+
+Co-authored-by: Chao An <an...@xiaomi.com>
+
+Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
+
+Differential Revision: https://reviews.llvm.org/D91074
+---
+ include/__locale | 40 +++++++++++++++++++++-------------------
+ 1 file changed, 21 insertions(+), 19 deletions(-)
+
+diff --git a/include/__locale libcxx/include/__locale
+index 125adcf68c8..e973ce52646 100644
+--- a/include/__locale
++++ libcxx/include/__locale
+@@ -397,7 +397,26 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x,
+ class _LIBCPP_TYPE_VIS ctype_base
+ {
+ public:
+-#if defined(__GLIBC__)
++#if defined(_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE)
++ typedef unsigned long mask;
++ static const mask space = 1<<0;
++ static const mask print = 1<<1;
++ static const mask cntrl = 1<<2;
++ static const mask upper = 1<<3;
++ static const mask lower = 1<<4;
++ static const mask alpha = 1<<5;
++ static const mask digit = 1<<6;
++ static const mask punct = 1<<7;
++ static const mask xdigit = 1<<8;
++ static const mask blank = 1<<9;
++#if defined(__BIONIC__)
++ // Historically this was a part of regex_traits rather than ctype_base. The
++ // historical value of the constant is preserved for ABI compatibility.
++ static const mask __regex_word = 0x8000;
++#else
++ static const mask __regex_word = 1<<10;
++#endif // defined(__BIONIC__)
++#elif defined(__GLIBC__)
+ typedef unsigned short mask;
+ static const mask space = _ISspace;
+ static const mask print = _ISprint;
+@@ -486,24 +505,7 @@ public:
+ # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
+ # define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
+ #else
+- typedef unsigned long mask;
+- static const mask space = 1<<0;
+- static const mask print = 1<<1;
+- static const mask cntrl = 1<<2;
+- static const mask upper = 1<<3;
+- static const mask lower = 1<<4;
+- static const mask alpha = 1<<5;
+- static const mask digit = 1<<6;
+- static const mask punct = 1<<7;
+- static const mask xdigit = 1<<8;
+- static const mask blank = 1<<9;
+-#if defined(__BIONIC__)
+- // Historically this was a part of regex_traits rather than ctype_base. The
+- // historical value of the constant is preserved for ABI compatibility.
+- static const mask __regex_word = 0x8000;
+-#else
+- static const mask __regex_word = 1<<10;
+-#endif // defined(__BIONIC__)
++#error unkown classic_table, try _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
+ #endif
+ static const mask alnum = alpha | digit;
+ static const mask graph = alnum | punct;
+--
+2.17.1
+
diff --git a/libs/libxx/libcxx.defs b/libs/libxx/libcxx.defs
index 82c9179..a96b983 100644
--- a/libs/libxx/libcxx.defs
+++ b/libs/libxx/libcxx.defs
@@ -25,6 +25,10 @@ $(TOPDIR)/include/libcxx:
$(Q) tar -xf libcxx-$(VERSION).src.tar.xz
$(Q) $(DELFILE) libcxx-$(VERSION).src.tar.xz
$(Q) mv libcxx-$(VERSION).src libcxx
+ $(Q) patch -p0 < 0001-libc-Fix-a-few-warnings.patch
+ $(Q) patch -p0 < 0001-libc-NFC-Fix-several-GCC-warnings-in-the-test-suite.patch
+ $(Q) patch -p0 < 0001-libc-Fix-tests-failing-with-Clang-after-removing-GCC.patch
+ $(Q) patch -p0 < 0001-libcxx-Check-_LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE-fir.patch
$(Q) patch -p0 < 0001-libcxx-Port-to-NuttX-https-nuttx.apache.org-RTOS.patch
$(Q) $(DIRLINK) $(CURDIR)/libcxx/include $(TOPDIR)/include/libcxx