2020-05-17 18:26:59 +08:00
############################################################################
# libs/libxx/libcxx.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
###########################################################################
2023-01-23 06:08:00 +08:00
LIBCXX_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXX_VERSION))
2020-05-17 18:26:59 +08:00
2022-08-28 00:21:40 +08:00
# Download and unpack tarball if no git repo found
ifeq ($(wildcard libcxx/.git),)
2021-08-30 11:48:56 +08:00
libcxx-$(LIBCXX_VERSION).src.tar.xz:
2023-03-08 00:17:54 +08:00
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXX_VERSION),libcxx-$(LIBCXX_VERSION).src.tar.xz)
2020-10-23 08:33:36 +08:00
2021-08-30 11:48:56 +08:00
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
2024-09-27 12:49:56 +08:00
$(Q) patch -p0 < 0001_fix_stdatomic_h_miss_typedef.patch
2023-12-01 21:25:59 +08:00
$(Q) patch -p2 < mbstate_t.patch
2024-02-16 21:22:07 +08:00
$(Q) patch -p0 < 0001-libcxx-remove-mach-time-h.patch
2020-10-23 06:57:19 +08:00
$(Q) touch $@
2022-08-28 00:21:40 +08:00
endif
2020-10-23 06:57:19 +08:00
$(TOPDIR)/include/libcxx: libcxx
2020-05-17 18:26:59 +08:00
$(Q) $(DIRLINK) $(CURDIR)/libcxx/include $(TOPDIR)/include/libcxx
2023-01-23 06:08:00 +08:00
$(Q) cp $(CURDIR)/__config_site $(TOPDIR)/include/libcxx/__config_site
2020-05-17 18:26:59 +08:00
2021-08-19 01:31:06 +08:00
context:: $(TOPDIR)/include/libcxx
2020-05-17 18:26:59 +08:00
distclean::
$(Q) $(DIRUNLINK) $(TOPDIR)/include/libcxx
2022-08-28 00:21:40 +08:00
ifeq ($(wildcard libcxx/.git),)
$(Q) $(DELFILE) libcxx-$(LIBCXX_VERSION).src.tar.xz
2020-05-17 18:26:59 +08:00
$(call DELDIR, libcxx)
2022-08-28 00:21:40 +08:00
endif
2020-05-17 18:26:59 +08:00
2022-11-01 21:47:53 +08:00
CXXFLAGS += ${DEFINE_PREFIX}_LIBCPP_BUILDING_LIBRARY
2023-01-23 06:08:00 +08:00
CXXFLAGS += ${INCDIR_PREFIX}$(CURDIR)/libcxx/src
2020-05-17 18:26:59 +08:00
2021-08-30 12:09:08 +08:00
ifeq ($(CONFIG_LIBSUPCXX), y)
2022-11-01 21:47:53 +08:00
CXXFLAGS += ${DEFINE_PREFIX}__GLIBCXX__
2021-08-19 17:13:43 +08:00
endif
2020-10-23 07:12:47 +08:00
# Workaround the following warning with "c++ (Ubuntu 9.3.0-10ubuntu2) 9.3.0"
#
# libcxx/src/barrier.cpp: In constructor 'std::__1::__barrier_algorithm_base::__barrier_algorithm_base(ptrdiff_t&)':
# libcxx/src/barrier.cpp:35:9: warning: declaration of '__expected' shadows a member of 'std::__1::__barrier_algorithm_base' [-Wshadow]
# 35 | : __expected(__expected)
# | ^
# libcxx/src/barrier.cpp:29:24: note: shadowed declaration is here
# 29 | ptrdiff_t& __expected;
# | ^~~~~~~~~~
libcxx/src/barrier.cpp_CXXFLAGS += -Wno-shadow
2020-10-23 08:16:07 +08:00
libcxx/src/locale.cpp_CXXFLAGS += -Wno-shadow
2020-10-23 10:49:52 +08:00
libcxx/src/filesystem/operations.cpp_CXXFLAGS += -Wno-shadow
2023-08-23 18:56:39 +08:00
# Workaround the following warning with "GCC 12"
2023-02-20 18:21:25 +08:00
#
# ...
# include/libcxx/string:2156:35: warning: '__temp' may be used uninitialized [-Wmaybe-uninitialized]
# 2156 | this->__throw_length_error();
# | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
# include/libcxx/string:614:1: note: by argument 1 of type 'const std::__1::__basic_string_common<true>*' to 'void std::__1::__basic_string_common<<anonymous> >::__throw_length_error() const [with bool <anonymous> = true]' declared here
# 614 | __basic_string_common<__b>::__throw_length_error() const
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~
# include/libcxx/string:2676:32: note: '__temp' declared here
# 2676 | const basic_string __temp (__first, __last, __alloc());
# | ^~~~~~
2023-04-23 12:12:33 +08:00
ifeq ($(GCCVER),)
2023-12-01 21:25:59 +08:00
export GCCVER = $(shell $(CXX) --version | grep ++ | sed -E 's/.* ([0-9]+\.[0-9]+).*/\1/' | cut -d'.' -f1)
2023-04-23 12:12:33 +08:00
endif
2023-08-23 18:56:39 +08:00
ifeq ($(GCCVER),12)
2023-02-21 13:16:13 +08:00
libcxx/src/filesystem/operations.cpp_CXXFLAGS += -Wno-maybe-uninitialized
libs/libxx/libcxx: Fix compilation warnings
Summary
Workaround the following warning with "GCC 12"
CXX: libcxxabi/src/cxa_demangle.cpp In file included from libcxx/src/locale.cpp:15:
In member function 'std::__1::_EnableIf<std::__1::__is_cpp17_forward_iterator<_ForwardIterator>::value> std::__1::basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator, _ForwardIterator) [with _ForwardIterator = const wchar_t*; _CharT = wchar_t; _Traits = std::__1::char_traits<wchar_t>; _Allocator = std::__1::allocator<wchar_t>]', inlined from 'std::__1::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator, _InputIterator) [with _InputIterator = const wchar_t*; <template-parameter-2-2> = void; _CharT = wchar_t; _Traits = std::__1::char_traits<wchar_t>; _Allocator = std::__1::allocator<wchar_t>]' at include/libcxx/string:2182:11,
inlined from 'virtual int std::__1::collate_byname<wchar_t>::do_compare(const char_type*, const char_type*, const char_type*, const char_type*) const' at libcxx/src/locale.cpp:764:33:
include/libcxx/string:2156:35: warning: 'lhs' may be used uninitialized [-Wmaybe-uninitialized]
2156 | this->__throw_length_error();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~^~
include/libcxx/new:237:24: warning: argument 1 value '18446744073709551599' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
237 | return ::operator new(__args...);
| ~~~~~~~~~~~~~~^~~~~~~~~~~
Signed-off-by: wangming9 <wangming9@xiaomi.com>
2023-09-05 19:38:18 +08:00
libcxx/src/locale.cpp_CXXFLAGS += -Wno-maybe-uninitialized
endif
# Workaround the following warning with "GCC 12"
#
# ...
# include/libcxx/new:237:24: warning: argument 1 value '18446744073709551599' exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
# 237 | return ::operator new(__args...);
# | ~~~~~~~~~~~~~~^~~~~~~~~~~
ifeq ($(GCCVER),12)
libcxx/src/string.cpp_CXXFLAGS += -Wno-alloc-size-larger-than
2023-02-21 13:16:13 +08:00
endif
2023-02-20 18:21:25 +08:00
2023-01-20 21:17:20 +08:00
# The following warning was observed with icicle:knsh config.
# Looking at the code in question, it seems harmless to ignore.
#
# Note: For some reasons, GCC -Wall enables a different set of warnings
# for C and C++.
#
# References:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10604
# https://github.com/gcc-mirror/gcc/blob/e54375d85d4aa5889869c2672158083b2106b623/gcc/c-family/c.opt#L1285-L1287
#
# CXX: libcxx/src/condition_variable.cpp
# libcxx/src/condition_variable.cpp: In member function 'void std::__1::condition_variable::__do_timed_wait(std::__1::unique_lock<std::__1::mutex>&, std::__1::chrono::time_point<std::__1::chrono::system_clock, std::__1::chrono::duration<long long int, std::__1::ratio<1, 1000000000> > >)':
# libcxx/src/condition_variable.cpp:64:19: error: comparison of integer expressions of different signedness: 'std::__1::chrono::duration<long long int>::rep' {aka 'long long int'} and 'std::__1::__libcpp_numeric_limits<long unsigned int, true>::type' {aka 'long unsigned int'} [-Werror=sign-compare]
# if (s.count() < ts_sec_max)
# ~~~~~~~~~~^~~~~~~~~~~~
libcxx/src/condition_variable.cpp_CXXFLAGS += -Wno-sign-compare
2023-10-26 09:56:55 +08:00
# When building with GCC 12.2.0
# libcxx has a fallback to use __always_inline__ when the (clang) exclude_from_explicit_instantiation isn't available.
# This causes: `always_inline` function might not be inlinable [-Wattributes] warnings in some modules.
# For example:
# libcxx/src/include/to_chars_floating_point.h:988:17: warning: ‘ always_inline’ function might not be inlinable [-Wattributes]
# Should be OK to ignore these
ifeq ($(GCCVER),12)
libcxx/src/charconv.cpp_CXXFLAGS += -Wno-attributes
endif
# Another warning on gcc 12.2.0
# libcxx/src/locale.cpp:6604:85: warning: type attributes ignored after type is already defined [-Wattributes]
# 6604 | template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char, mbstate_t>;
# | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# libcxx/src/locale.cpp:6605:85: warning: type attributes ignored after type is already defined [-Wattributes]
# 6605 | template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char, mbstate_t>;
ifeq ($(GCCVER),12)
libcxx/src/locale.cpp_CXXFLAGS += -Wno-attributes
endif
2023-12-01 21:25:59 +08:00
# warning on gcc >= 12.3.Rel1
# libcxx/src/string.cpp:58:33: warning: 'template<class _CharT> struct std::__1::char_traits' is deprecated: char_traits<T> for T not equal to char, wchar_t, char8_t, char16_t or char32_t is non-standard and is provided for a temporary period. It will be removed in LLVM 18, so please migrate off of it. [-Wdeprecated-declarations]
# 58 | template string operator+<char, char_traits<char>, allocator<char>>(char const*, string const&);
2024-01-04 16:02:21 +08:00
ifneq ($(GCCVER),)
2023-12-01 21:25:59 +08:00
ifeq ($(shell expr $(GCCVER) \>= 12), 1)
libcxx/src/string.cpp_CXXFLAGS += -Wno-deprecated-declarations
endif
2024-01-04 16:02:21 +08:00
endif
2023-12-01 21:25:59 +08:00
# warning on gcc >= 12.3.Rel1
# libcxx/src/filesystem/path.cpp:14:
# libcxx/src/filesystem/path_parser.h: In constructor 'std::__1::__fs::filesystem::parser::PathParser::PathParser(std::__1::__fs::filesystem::parser::string_view_t, ParserState)':
# libcxx/src/filesystem/path_parser.h:58:43: warning: declaration of 'State' shadows a member of 'std::__1::__fs::filesystem::parser::PathParser' [-Wshadow]
# 58 | PathParser(string_view_t P, ParserState State) noexcept : Path(P),
# | ~~~~~~~~~~~~^~~~~
# libcxx/src/filesystem/path_parser.h:55:15: note: shadowed declaration is here
# 55 | ParserState State;
# | ^~~~~
# libcxx/src/filesystem/path_parser.h: In constructor 'std::__1::__fs::filesystem::parser::PathParser::PathParser(std::__1::__fs::filesystem::parser::string_view_t, ParserState)':
# libcxx/src/filesystem/path_parser.h:58:43: warning: declaration of 'State' shadows a member of 'std::__1::__fs::filesystem::parser::PathParser' [-Wshadow]
# 58 | PathParser(string_view_t P, ParserState State) noexcept : Path(P),
# | ~~~~~~~~~~~~^~~~~
# libcxx/src/filesystem/path_parser.h:55:15: note: shadowed declaration is here
# 55 | ParserState State;
# | ^~~~~
# libcxx/src/filesystem/path_parser.h: In constructor 'std::__1::__fs::filesystem::parser::PathParser::PathParser(std::__1::__fs::filesystem::parser::string_view_t, ParserState)':
# libcxx/src/filesystem/path_parser.h:58:43: warning: declaration of 'State' shadows a member of 'std::__1::__fs::filesystem::parser::PathParser' [-Wshadow]
# 58 | PathParser(string_view_t P, ParserState State) noexcept : Path(P),
# | ~~~~~~~~~~~~^~~~~
# libcxx/src/filesystem/path_parser.h:55:15: note: shadowed declaration is here
# 55 | ParserState State;
# | ^~~~~
2024-01-04 16:02:21 +08:00
ifneq ($(GCCVER),)
2023-12-01 21:25:59 +08:00
ifeq ($(shell expr $(GCCVER) \>= 12), 1)
libcxx/src/filesystem/path.cpp_CXXFLAGS += -Wno-shadow
endif
2024-01-04 16:02:21 +08:00
endif
2023-12-01 21:25:59 +08:00
# warning on gcc >= 12.3.Rel1
# libcxx/src/ryu/d2s.cpp:490:31: warning: '_Trailing_zero_bits' may be used uninitialized [-Wmaybe-uninitialized]
# 490 | _Trailing_zero_bits += 32;
# | ~~~~~~~~~~~~~~~~~~~~^~~~~
2024-01-04 16:02:21 +08:00
ifneq ($(GCCVER),)
2023-12-01 21:25:59 +08:00
ifeq ($(shell expr $(GCCVER) \>= 12), 1)
libcxx/src/ryu/d2s.cpp_CXXFLAGS += -Wno-maybe-uninitialized
endif
2024-01-04 16:02:21 +08:00
endif
2023-12-01 21:25:59 +08:00
2023-10-26 09:56:55 +08:00
2023-01-23 06:08:00 +08:00
CPPSRCS += $(wildcard libcxx/src/*.cpp)
CPPSRCS += $(wildcard libcxx/src/experimental/*.cpp)
CPPSRCS += $(wildcard libcxx/src/filesystem/*.cpp)
2023-12-01 21:25:59 +08:00
CPPSRCS += $(wildcard libcxx/src/ryu/*.cpp)