libcxx: Remove exiting patches and update libcxx version to 15.0.7

- Add __config_site for NuttX.
   In libcxx 12.0.0. CMake concatenated __config_site with _config,
   which enabled NuttX to build without its inclusion. In 15.0.7, this
   file is configured by CMake and included explicitly in __config.
 - Add additional include directories.
 - Mute always_inline warning.
 - Make the download of libcxx/libcxxabi configurable
This commit is contained in:
Stuart Ianna 2023-01-23 09:08:00 +11:00 committed by Petro Karashchenko
parent d6453cfc3c
commit 4f90a6140c
11 changed files with 74 additions and 362 deletions

View file

@ -1,55 +0,0 @@
From fdc60516f58633382ae5d73256a99c7737b174e5 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Fri, 30 Jul 2021 17:24:51 +0800
Subject: [PATCH] Remove the locale fallback for NuttX
since these functions can handled by NuttX's libc now
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I68c9f6a690313748e030510d391170d8ca83ee7d
---
include/__locale | 2 --
include/__support/nuttx/xlocale.h | 18 ------------------
2 files changed, 20 deletions(-)
delete mode 100644 include/__support/nuttx/xlocale.h
diff --git libcxx/include/__locale libcxx/include/__locale
index 77e5faab2..054973e9f 100644
--- libcxx/include/__locale
+++ libcxx/include/__locale
@@ -22,8 +22,6 @@
#if defined(_LIBCPP_MSVCRT_LIKE)
# include <cstring>
# include <__support/win32/locale_win32.h>
-#elif defined(__NuttX__)
-# include <__support/nuttx/xlocale.h>
#elif defined(_AIX) || defined(__MVS__)
# include <__support/ibm/xlocale.h>
#elif defined(__ANDROID__)
diff --git libcxx/include/__support/nuttx/xlocale.h libcxx/include/__support/nuttx/xlocale.h
deleted file mode 100644
index be738e3b6..000000000
--- libcxx/include/__support/nuttx/xlocale.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_NUTTX_XLOCALE_H
-#define _LIBCPP_SUPPORT_NUTTX_XLOCALE_H
-
-#if defined(__NuttX__)
-#include <__support/xlocale/__posix_l_fallback.h>
-#include <__support/xlocale/__strtonum_fallback.h>
-#endif // __NuttX__
-
-#endif
--
2.17.1

View file

@ -1,28 +0,0 @@
From d74ec1669d8f09d2ac9289423b51ae8b3af13d11 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Sat, 28 Aug 2021 02:11:15 +0800
Subject: [PATCH] [libc++abi] avoid the waring: "__EXCEPTIONS" is not defined,
evaluates to 0 [-Werror=undef]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I228cf44401f7ef9d7f49d8b806177bae1242d674
---
include/__cxxabi_config.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git libcxxabi/include/__cxxabi_config.h libcxxabi/include/__cxxabi_config.h
index cffedb8..05ed8b6 100644
--- libcxxabi/include/__cxxabi_config.h
+++ libcxxabi/include/__cxxabi_config.h
@@ -93,7 +93,7 @@
# if !__has_feature(cxx_exceptions)
# define _LIBCXXABI_NO_EXCEPTIONS
# endif
-#elif defined(_LIBCXXABI_COMPILER_GCC) && !__EXCEPTIONS
+#elif defined(_LIBCXXABI_COMPILER_GCC) && !defined(__EXCEPTIONS)
# define _LIBCXXABI_NO_EXCEPTIONS
#endif
--
2.25.1

View file

@ -1,28 +0,0 @@
From 828208f5061fabe5c42ceee6fb1ab0783c956271 Mon Sep 17 00:00:00 2001
From: Xiang Xiao <xiaoxiang@xiaomi.com>
Date: Sat, 28 Aug 2021 09:20:09 +0800
Subject: [PATCH] [libc++] avoid the waring: "__EXCEPTIONS" is not defined,
evaluates to 0 [-Werror=undef]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: If529bbb2f87e55dce5d0df37f2bf72c3d02bf260
---
include/__config | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git libcxx/include/__config libcxx/include/__config
index e5828628d..edfe51224 100644
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -551,7 +551,7 @@ typedef __char32_t char32_t;
#define _LIBCPP_NORETURN __attribute__((noreturn))
-#if !__EXCEPTIONS
+#if !defined(__EXCEPTIONS)
# define _LIBCPP_NO_EXCEPTIONS
#endif
--
2.25.1

View file

@ -1,182 +0,0 @@
From 213f9acccb725a7ddcd9f41eee9d5234d81e1dc0 Mon Sep 17 00:00:00 2001
From: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Date: Fri, 25 Mar 2022 10:18:40 -0300
Subject: [PATCH 1/2] [libcxx] Rename PS() macro to avoid clashing with Xtensa
register name
This patch addresses a clash with the PS register from Xtensa
defined in the <specreg.h> header file, which is commonly
included in OS implementation.
Issue identified while building libc++ port for Apache NuttX, targeting
Xtensa-based chips (e.g. Espressif's ESP32).
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
Differential Revision: https://reviews.llvm.org/D122479
---
libcxx/src/filesystem/filesystem_common.h | 4 +-
libcxx/src/filesystem/operations.cpp | 46 +++++++++++------------
2 files changed, 24 insertions(+), 26 deletions(-)
diff --git a/libcxx/src/filesystem/filesystem_common.h b/libcxx/src/filesystem/filesystem_common.h
index e0fdbccf96b1..b62f1406de39 100644
--- a/libcxx/src/filesystem/filesystem_common.h
+++ b/libcxx/src/filesystem/filesystem_common.h
@@ -41,9 +41,9 @@
#endif
#if defined(_LIBCPP_WIN32API)
-#define PS(x) (L##x)
+# define PATHSTR(x) (L##x)
#else
-#define PS(x) (x)
+# define PATHSTR(x) (x)
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index 50a895dc2fae..830781def52d 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -188,14 +188,14 @@ public:
switch (State) {
case PS_BeforeBegin:
case PS_AtEnd:
- return PS("");
+ return PATHSTR("");
case PS_InRootDir:
if (RawEntry[0] == '\\')
- return PS("\\");
+ return PATHSTR("\\");
else
- return PS("/");
+ return PATHSTR("/");
case PS_InTrailingSep:
- return PS("");
+ return PATHSTR("");
case PS_InRootName:
case PS_InFilenames:
return RawEntry;
@@ -303,8 +303,8 @@ private:
};
string_view_pair separate_filename(string_view_t const& s) {
- if (s == PS(".") || s == PS("..") || s.empty())
- return string_view_pair{s, PS("")};
+ if (s == PATHSTR(".") || s == PATHSTR("..") || s.empty())
+ return string_view_pair{s, PATHSTR("")};
auto pos = s.find_last_of('.');
if (pos == string_view_t::npos || pos == 0)
return string_view_pair{s, string_view_t{}};
@@ -591,8 +591,8 @@ filesystem_error::~filesystem_error() {}
void filesystem_error::__create_what(int __num_paths) {
const char* derived_what = system_error::what();
__storage_->__what_ = [&]() -> string {
- const path::value_type* p1 = path1().native().empty() ? PS("\"\"") : path1().c_str();
- const path::value_type* p2 = path2().native().empty() ? PS("\"\"") : path2().c_str();
+ const path::value_type* p1 = path1().native().empty() ? PATHSTR("\"\"") : path1().c_str();
+ const path::value_type* p2 = path2().native().empty() ? PATHSTR("\"\"") : path2().c_str();
switch (__num_paths) {
default:
return detail::format_string("filesystem error: %s", derived_what);
@@ -1378,7 +1378,7 @@ path& path::replace_extension(path const& replacement) {
}
if (!replacement.empty()) {
if (replacement.native()[0] != '.') {
- __pn_ += PS(".");
+ __pn_ += PATHSTR(".");
}
__pn_.append(replacement.__pn_);
}
@@ -1500,14 +1500,14 @@ enum PathPartKind : unsigned char {
static PathPartKind ClassifyPathPart(string_view_t Part) {
if (Part.empty())
return PK_TrailingSep;
- if (Part == PS("."))
+ if (Part == PATHSTR("."))
return PK_Dot;
- if (Part == PS(".."))
+ if (Part == PATHSTR(".."))
return PK_DotDot;
- if (Part == PS("/"))
+ if (Part == PATHSTR("/"))
return PK_RootSep;
#if defined(_LIBCPP_WIN32API)
- if (Part == PS("\\"))
+ if (Part == PATHSTR("\\"))
return PK_RootSep;
#endif
return PK_Filename;
@@ -1557,7 +1557,7 @@ path path::lexically_normal() const {
NewPathSize -= Parts.back().first.size();
Parts.pop_back();
} else if (LastKind != PK_RootSep)
- AddPart(PK_DotDot, PS(".."));
+ AddPart(PK_DotDot, PATHSTR(".."));
MaybeNeedTrailingSep = LastKind == PK_Filename;
break;
}
@@ -1572,7 +1572,7 @@ path path::lexically_normal() const {
}
// [fs.path.generic]p6.8: If the path is empty, add a dot.
if (Parts.empty())
- return PS(".");
+ return PATHSTR(".");
// [fs.path.generic]p6.7: If the last filename is dot-dot, remove any
// trailing directory-separator.
@@ -1584,7 +1584,7 @@ path path::lexically_normal() const {
Result /= PK.first;
if (NeedTrailingSep)
- Result /= PS("");
+ Result /= PATHSTR("");
return Result;
}
@@ -1593,9 +1593,9 @@ static int DetermineLexicalElementCount(PathParser PP) {
int Count = 0;
for (; PP; ++PP) {
auto Elem = *PP;
- if (Elem == PS(".."))
+ if (Elem == PATHSTR(".."))
--Count;
- else if (Elem != PS(".") && Elem != PS(""))
+ else if (Elem != PATHSTR(".") && Elem != PATHSTR(""))
++Count;
}
return Count;
@@ -1642,15 +1642,15 @@ path path::lexically_relative(const path& base) const {
return {};
// if n == 0 and (a == end() || a->empty()), returns path("."); otherwise
- if (ElemCount == 0 && (PP.atEnd() || *PP == PS("")))
- return PS(".");
+ if (ElemCount == 0 && (PP.atEnd() || *PP == PATHSTR("")))
+ return PATHSTR(".");
// return a path constructed with 'n' dot-dot elements, followed by the the
// elements of '*this' after the mismatch.
path Result;
// FIXME: Reserve enough room in Result that it won't have to re-allocate.
while (ElemCount--)
- Result /= PS("..");
+ Result /= PATHSTR("..");
for (; PP; ++PP)
Result /= *PP;
return Result;
@@ -1662,9 +1662,7 @@ static int CompareRootName(PathParser *LHS, PathParser *RHS) {
if (!LHS->inRootName() && !RHS->inRootName())
return 0;
- auto GetRootName = [](PathParser *Parser) -> string_view_t {
- return Parser->inRootName() ? **Parser : PS("");
- };
+ auto GetRootName = [](PathParser* Parser) -> string_view_t { return Parser->inRootName() ? **Parser : PATHSTR(""); };
int res = GetRootName(LHS).compare(GetRootName(RHS));
ConsumeRootName(LHS);
ConsumeRootName(RHS);
--
2.32.0

View file

@ -1,38 +0,0 @@
From ff00346174831ec01bc6b85c39c19d502cfa2093 Mon Sep 17 00:00:00 2001
From: Brian Cain <bcain@quicinc.com>
Date: Thu, 27 Jan 2022 08:09:11 -0800
Subject: [PATCH 2/2] Omit atomic_{,un}signed_lock_free if unsupported
On targets that have limited atomic support, e.g. ones that define
ATOMIC_*_LOCK_FREE to '1' ("sometimes lock free"), we would end up
referencing yet-undefined __libcpp_{,un}signed_lock_free.
This commit adds a guard to prevent these references for such
targets.
Differential Revision: https://reviews.llvm.org/D118391
---
libcxx/include/atomic | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libcxx/include/atomic b/libcxx/include/atomic
index 0fc799a24319..57d01ad2791a 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -2791,10 +2791,13 @@ typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, char>::typ
typedef conditional<_LIBCPP_CONTENTION_LOCK_FREE, __cxx_contention_t, unsigned char>::type __libcpp_unsigned_lock_free;
#else
// No signed/unsigned lock-free types
+#define _LIBCPP_NO_LOCK_FREE_TYPES
#endif
+#if !defined(_LIBCPP_NO_LOCK_FREE_TYPES)
typedef atomic<__libcpp_signed_lock_free> atomic_signed_lock_free;
typedef atomic<__libcpp_unsigned_lock_free> atomic_unsigned_lock_free;
+#endif
#define ATOMIC_FLAG_INIT {false}
#define ATOMIC_VAR_INIT(__v) {__v}
--
2.32.0

View file

@ -51,18 +51,14 @@ config UCLIBCXX
endchoice
if LIBCXXMINI
config ETL
bool "Embedded Template Library (ETL)"
depends on ALLOW_MIT_COMPONENTS
depends on LIBCXXMINI && ALLOW_MIT_COMPONENTS
---help---
ETL A C++ Template library for Embedded applications
Implements C++ templates such as containers, string
singleton math without C++ STL libraries
endif
if LIBCXX || UCLIBCXX
choice
@ -84,6 +80,12 @@ config LIBSUPCXX
endchoice
config LIBCXXABI_VERSION
string "Select libcxxabi version"
depends on LIBCXXABI
default LIBCXX_VERSION if LIBCXX
default "15.0.7" if !LIBCXX
endif
config CXX_STANDARD
@ -110,4 +112,10 @@ config UCLIBCXX_BUFSIZE
default 32
endif
config LIBCXX_VERSION
string "Select libcxx version"
depends on LIBCXX
default "15.0.7"
endif

52
libs/libxx/__config_site Normal file
View file

@ -0,0 +1,52 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP___CONFIG_SITE
#define _LIBCPP___CONFIG_SITE
/* The following is generated from include/__config_site.in
* in Ubunutu 22.0.4 with g++ 11.3.0.
*/
#define _LIBCPP_ABI_VERSION 1
#define _LIBCPP_ABI_NAMESPACE __1
/* #undef _LIBCPP_ABI_FORCE_ITANIUM */
/* #undef _LIBCPP_ABI_FORCE_MICROSOFT */
/* #undef _LIBCPP_HAS_NO_THREADS */
/* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */
/* #undef _LIBCPP_HAS_MUSL_LIBC */
/* #undef _LIBCPP_HAS_THREAD_API_PTHREAD */
/* #undef _LIBCPP_HAS_THREAD_API_EXTERNAL */
/* #undef _LIBCPP_HAS_THREAD_API_WIN32 */
/* #undef _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL */
/* #undef _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS */
#define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS
/* #undef _LIBCPP_NO_VCRUNTIME */
/* #undef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION */
/* #undef _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY */
/* #undef _LIBCPP_HAS_PARALLEL_ALGORITHMS */
/* #undef _LIBCPP_HAS_NO_RANDOM_DEVICE */
/* #undef _LIBCPP_HAS_NO_LOCALIZATION */
/* #undef _LIBCPP_HAS_NO_WIDE_CHARACTERS */
#define _LIBCPP_ENABLE_ASSERTIONS_DEFAULT 0
/* #undef _LIBCPP_ENABLE_DEBUG_MODE */
// __USE_MINGW_ANSI_STDIO gets redefined on MinGW
#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wmacro-redefined"
#endif
#ifdef __clang__
# pragma clang diagnostic pop
#endif
#endif // _LIBCPP___CONFIG_SITE

View file

@ -20,7 +20,7 @@
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxx)
set(LIBCXX_VERSION 12.0.0)
set(LIBCXX_VERSION ${CONFIG_LIBCXX_VERSION})
# cmake-format: off
set(LIBCXX_PATCH_COMMAND

View file

@ -18,7 +18,7 @@
#
###########################################################################
LIBCXX_VERSION=12.0.0
LIBCXX_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXX_VERSION))
# Download and unpack tarball if no git repo found
ifeq ($(wildcard libcxx/.git),)
@ -29,17 +29,12 @@ libcxx: libcxx-$(LIBCXX_VERSION).src.tar.xz
$(Q) tar -xf libcxx-$(LIBCXX_VERSION).src.tar.xz \
--exclude libcxx-$(LIBCXX_VERSION).src/test/std/pstl
$(Q) mv libcxx-$(LIBCXX_VERSION).src libcxx
$(Q) patch -p0 < 0001-Remove-the-locale-fallback-for-NuttX.patch
$(Q) patch -p0 < 0001-libc-avoid-the-waring-__EXCEPTIONS-is-not-defined-ev.patch
$(Q) patch -p1 < 0001-libcxx-Rename-PS-macro-to-avoid-clashing-with-Xtensa.patch
ifeq ($(CONFIG_LIBC_ARCH_ATOMIC),y)
$(Q) patch -p1 < 0002-Omit-atomic_-un-signed_lock_free-if-unsupported.patch
endif
$(Q) touch $@
endif
$(TOPDIR)/include/libcxx: libcxx
$(Q) $(DIRLINK) $(CURDIR)/libcxx/include $(TOPDIR)/include/libcxx
$(Q) cp $(CURDIR)/__config_site $(TOPDIR)/include/libcxx/__config_site
context:: $(TOPDIR)/include/libcxx
@ -51,6 +46,7 @@ ifeq ($(wildcard libcxx/.git),)
endif
CXXFLAGS += ${DEFINE_PREFIX}_LIBCPP_BUILDING_LIBRARY
CXXFLAGS += ${INCDIR_PREFIX}$(CURDIR)/libcxx/src
ifeq ($(CONFIG_LIBSUPCXX), y)
CXXFLAGS += ${DEFINE_PREFIX}__GLIBCXX__
@ -67,8 +63,6 @@ endif
# | ^~~~~~~~~~
libcxx/src/barrier.cpp_CXXFLAGS += -Wno-shadow
libcxx/src/locale.cpp_CXXFLAGS += -Wno-shadow
libcxx/src/filesystem/directory_iterator.cpp_CXXFLAGS += -Wno-shadow
libcxx/src/filesystem/operations.cpp_CXXFLAGS += -Wno-shadow
# Workaround the following warning with "GCC 12"
@ -131,14 +125,6 @@ libcxx/src/condition_variable.cpp_CXXFLAGS += -Wno-sign-compare
# std::
libcxx/src/filesystem/directory_iterator.cpp_CXXFLAGS += -Wno-unqualified-std-cast-call
CPPSRCS += $(notdir $(wildcard libcxx/src/*.cpp))
CPPSRCS += $(notdir $(wildcard libcxx/src/experimental/*.cpp))
CPPSRCS += $(notdir $(wildcard libcxx/src/filesystem/*.cpp))
DEPPATH += --dep-path libcxx/src
DEPPATH += --dep-path libcxx/src/experimental
DEPPATH += --dep-path libcxx/src/filesystem
VPATH += libcxx/src
VPATH += libcxx/src/experimental
VPATH += libcxx/src/filesystem
CPPSRCS += $(wildcard libcxx/src/*.cpp)
CPPSRCS += $(wildcard libcxx/src/experimental/*.cpp)
CPPSRCS += $(wildcard libcxx/src/filesystem/*.cpp)

View file

@ -20,7 +20,7 @@
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxxabi)
set(LIBCXXABI_VERSION 12.0.0)
set(LIBCXXABI_VERSION CONFIG_LIBCXXABI_VERSION)
FetchContent_Declare(
libcxxabi

View file

@ -18,7 +18,7 @@
#
###########################################################################
LIBCXXABI_VERSION=12.0.0
LIBCXXABI_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXXABI_VERSION))
libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz:
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXXABI_VERSION),libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz)
@ -26,10 +26,8 @@ libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz:
libcxxabi: libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz
$(Q) tar -xf libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz
$(Q) mv libcxxabi-$(LIBCXXABI_VERSION).src libcxxabi
$(Q) patch -p0 < 0001-libc-abi-avoid-the-waring-__EXCEPTIONS-is-not-define.patch
$(Q) touch $@
# Download and unpack tarball if no git repo found
ifeq ($(wildcard libcxxabi/.git),)
distclean::
@ -64,4 +62,3 @@ CXXFLAGS += -frtti
DEPPATH += --dep-path libcxxabi/src
VPATH += libcxxabi/src