Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit db31e56

Browse files
W-M-Rxiaoxiang781216
authored andcommittedNov 7, 2024·
libxx: All cxx libraries move down one level
Since there are some patches that need to be loaded manually, the original method is rather confusing. Now these patches that need to be loaded manually are classified into various cxx library folders, and each dynamically downloaded cxx library is moved down one directory to make the directory structure clearer. Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
1 parent 6611480 commit db31e56

28 files changed

+483
-490
lines changed
 

‎libs/libxx/.gitignore

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
/uClibc++
2-
/libcxx
3-
/libcxxabi
4-
/libcxx-*.src.tar.xz
5-
/libcxxabi-*.src.tar.xz
6-
/etl
7-
/.libcxx_patch
8-
/.libcxxabi_patch
1+
*.xz
2+
*.bz2

‎libs/libxx/CMakeLists.txt

+1-13
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,4 @@
2929
# the configuration problem. Refer to the README.txt file in the NuttX uClibc++
3030
# GIT repository for more information
3131

32-
if(CONFIG_HAVE_CXX)
33-
if(CONFIG_UCLIBCXX)
34-
include(uClibc++.cmake)
35-
elseif(CONFIG_LIBCXX)
36-
include(libcxx.cmake)
37-
elseif(CONFIG_LIBCXXMINI)
38-
include(libcxxmini.cmake)
39-
endif()
40-
41-
if(CONFIG_LIBCXXABI)
42-
include(libcxxabi.cmake)
43-
endif()
44-
endif()
32+
nuttx_add_subdirectory()

‎libs/libxx/Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ include $(TOPDIR)/Make.defs
3232
# in the NuttX uClibc++ GIT repository for more information
3333

3434
ifeq ($(CONFIG_UCLIBCXX),y)
35-
include uClibc++.defs
35+
include uClibc++/Make.defs
3636
else ifeq ($(CONFIG_LIBCXX),y)
37-
include libcxx.defs
37+
include libcxx/Make.defs
3838
else ifeq ($(CONFIG_LIBCXXMINI),y)
39-
include libcxxmini.defs
39+
include libcxxmini/Make.defs
4040
endif
4141

4242
ifeq ($(CONFIG_ETL),y)
43-
include etl.defs
43+
include etl/Make.defs
4444
endif
4545

4646
ifeq ($(CONFIG_LIBCXXABI),y)
47-
include libcxxabi.defs
47+
include libcxxabi/Make.defs
4848
endif
4949

5050
# Object Files
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# libs/libxx/etl.defs
2+
# libs/libxx/etl/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -23,34 +23,32 @@
2323
ETL_VERSION=20.32.1
2424

2525
# Download and unpack tarball if no git repo found
26-
ifeq ($(wildcard etl/.git),)
26+
ifeq ($(wildcard etl/etl/.git),)
2727
$(ETL_VERSION).tar.gz:
28-
$(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$(ETL_VERSION).tar.gz)
28+
$(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$@)
2929

30-
etl: $(ETL_VERSION).tar.gz
31-
$(Q) tar -xf $(ETL_VERSION).tar.gz
32-
$(Q) $(DELFILE) $(ETL_VERSION).tar.gz
33-
$(Q) mv etl-$(ETL_VERSION) etl
34-
$(Q) touch $@
30+
etl/etl: $(ETL_VERSION).tar.gz
31+
$(Q) tar -xf $<
32+
$(Q) $(DELFILE) $<
33+
$(Q) mv etl-$(ETL_VERSION) $@
3534
endif
3635

37-
$(TOPDIR)/include/etl: etl
38-
$(Q) $(DIRLINK) $(CURDIR)/etl/include $(TOPDIR)/include/etl
36+
$(TOPDIR)/include/etl: etl/etl
37+
$(Q) $(DIRLINK) $(CURDIR)/$</include $(TOPDIR)/include/etl
3938
ifeq ($(CONFIG_ARCH_ARMV5M), y)
40-
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv5_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
39+
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv5_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
4140
else ifeq ($(CONFIG_ARCH_ARMV6M), y)
42-
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv6_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
41+
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv6_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
4342
else ifeq ($(CONFIG_ARCH_ARMV7M), y)
44-
$(Q) cp $(CURDIR)/etl/include/etl/profiles/armv7_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
43+
$(Q) cp $(CURDIR)/$</include/etl/profiles/armv7_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
4544
else
46-
$(Q) cp $(CURDIR)/etl/include/etl/profiles/gcc_generic_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
45+
$(Q) cp $(CURDIR)/$</include/etl/profiles/gcc_generic_no_stl.h $(CURDIR)/etl/include/etl/etl_profile.h
4746
endif
4847

4948
context:: $(TOPDIR)/include/etl
5049

5150
distclean::
5251
$(Q) $(DIRUNLINK) $(TOPDIR)/include/etl
53-
ifeq ($(wildcard etl/.git),)
54-
$(Q) $(DELFILE) $(ETL_VERSION).tar.gz
55-
$(call DELDIR, etl)
52+
ifeq ($(wildcard etl/etl/.git),)
53+
$(call DELDIR, etl/etl)
5654
endif

‎libs/libxx/libcxx.cmake

-125
This file was deleted.

‎libs/libxx/libcxx/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/libcxx

‎libs/libxx/libcxx/CMakeLists.txt

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# ##############################################################################
2+
# libs/libxx/libcxx/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_LIBCXX)
24+
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxx)
25+
26+
set(LIBCXX_VERSION ${CONFIG_LIBCXX_VERSION})
27+
28+
FetchContent_Declare(
29+
libcxx
30+
DOWNLOAD_NAME "libcxx-${LIBCXX_VERSION}.src.tar.xz"
31+
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
32+
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LIBCXX_VERSION}/libcxx-${LIBCXX_VERSION}.src.tar.xz"
33+
SOURCE_DIR
34+
${CMAKE_CURRENT_LIST_DIR}/libcxx
35+
BINARY_DIR
36+
${CMAKE_BINARY_DIR}/libs/libc/libcxx
37+
CONFIGURE_COMMAND
38+
""
39+
BUILD_COMMAND
40+
""
41+
INSTALL_COMMAND
42+
""
43+
TEST_COMMAND
44+
""
45+
PATCH_COMMAND
46+
patch -p1 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
47+
${CMAKE_CURRENT_LIST_DIR}/0001_fix_stdatomic_h_miss_typedef.patch &&
48+
patch -p3 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
49+
${CMAKE_CURRENT_LIST_DIR}/mbstate_t.patch && patch -p1 -d
50+
${CMAKE_CURRENT_LIST_DIR}/libcxx <
51+
${CMAKE_CURRENT_LIST_DIR}/0001-libcxx-remove-mach-time-h.patch && patch
52+
-p1 -d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
53+
${CMAKE_CURRENT_LIST_DIR}/0001-libcxx-fix-ld-errors.patch && patch -p1
54+
-d ${CMAKE_CURRENT_LIST_DIR}/libcxx <
55+
${CMAKE_CURRENT_LIST_DIR}/0001-Fix-build-error-about-__GLIBC__.patch
56+
DOWNLOAD_NO_PROGRESS true
57+
TIMEOUT 30)
58+
59+
FetchContent_GetProperties(libcxx)
60+
61+
if(NOT libcxx_POPULATED)
62+
FetchContent_Populate(libcxx)
63+
endif()
64+
65+
endif()
66+
67+
nuttx_create_symlink(${CMAKE_CURRENT_LIST_DIR}/libcxx/include
68+
${CMAKE_BINARY_DIR}/include/libcxx)
69+
70+
configure_file(${CMAKE_CURRENT_LIST_DIR}/../__config_site
71+
${CMAKE_BINARY_DIR}/include/libcxx/__config_site COPYONLY)
72+
73+
set_property(
74+
TARGET nuttx
75+
APPEND
76+
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/include/libcxx)
77+
78+
add_compile_definitions(_LIBCPP_BUILDING_LIBRARY)
79+
if(CONFIG_LIBSUPCXX_TOOLCHAIN)
80+
add_compile_definitions(__GLIBCXX__)
81+
endif()
82+
83+
if(CONFIG_LIBSUPCXX)
84+
add_compile_definitions(__GLIBCXX__)
85+
endif()
86+
87+
set(CMAKE_CXX_STANDARD 20)
88+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
89+
set(CMAKE_CXX_EXTENSIONS ON)
90+
91+
set(SRCS)
92+
set(SRCSTMP)
93+
94+
file(GLOB SRCS ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/*.cpp)
95+
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/experimental/*.cpp)
96+
list(APPEND SRCS ${SRCSTMP})
97+
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/filesystem/*.cpp)
98+
list(APPEND SRCS ${SRCSTMP})
99+
file(GLOB SRCSTMP ${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ryu/*.cpp)
100+
list(APPEND SRCS ${SRCSTMP})
101+
102+
if(NOT CONFIG_CXX_LOCALIZATION)
103+
file(
104+
GLOB
105+
SRCSTMP
106+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ios.cpp
107+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/ios.instantiations.cpp
108+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/iostream.cpp
109+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/locale.cpp
110+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/regex.cpp
111+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src/strstream.cpp)
112+
list(REMOVE_ITEM SRCS ${SRCSTMP})
113+
endif()
114+
115+
set(FLAGS -Wno-attributes -Wno-deprecated-declarations -Wno-shadow
116+
-Wno-sign-compare -Wno-cpp)
117+
118+
if(GCCVER GREATER_EQUAL 12)
119+
list(APPEND FLAGS -Wno-maybe-uninitialized -Wno-alloc-size-larger-than)
120+
endif()
121+
122+
nuttx_add_system_library(libcxx)
123+
target_sources(libcxx PRIVATE ${SRCS})
124+
target_compile_options(libcxx PRIVATE ${FLAGS})
125+
target_include_directories(libcxx BEFORE
126+
PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxx/src)
127+
endif()
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# libs/libxx/libcxx.defs
2+
# libs/libxx/libcxx/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -23,37 +23,37 @@
2323
LIBCXX_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXX_VERSION))
2424

2525
# Download and unpack tarball if no git repo found
26-
ifeq ($(wildcard libcxx/.git),)
26+
ifeq ($(wildcard libcxx/libcxx/.git),)
2727
libcxx-$(LIBCXX_VERSION).src.tar.xz:
28-
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXX_VERSION),libcxx-$(LIBCXX_VERSION).src.tar.xz)
28+
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXX_VERSION),$@)
2929

30-
libcxx: libcxx-$(LIBCXX_VERSION).src.tar.xz
31-
$(Q) tar -xf libcxx-$(LIBCXX_VERSION).src.tar.xz \
30+
libcxx/libcxx: libcxx-$(LIBCXX_VERSION).src.tar.xz
31+
$(Q) tar -xf $< \
3232
--exclude libcxx-$(LIBCXX_VERSION).src/test/std/pstl
33-
$(Q) mv libcxx-$(LIBCXX_VERSION).src libcxx
34-
$(Q) patch -p0 < 0001_fix_stdatomic_h_miss_typedef.patch
35-
$(Q) patch -p2 < mbstate_t.patch
36-
$(Q) patch -p0 < 0001-libcxx-remove-mach-time-h.patch
37-
$(Q) patch -p0 < 0001-libcxx-fix-ld-errors.patch
38-
$(Q) patch -p0 < 0001-Fix-build-error-about-__GLIBC__.patch
39-
$(Q) touch $@
33+
$(Q) mv libcxx-$(LIBCXX_VERSION).src $@
34+
$(Q) patch -p0 < libcxx/0001_fix_stdatomic_h_miss_typedef.patch -d libcxx
35+
$(Q) patch -p2 < libcxx/mbstate_t.patch -d libcxx
36+
$(Q) patch -p0 < libcxx/0001-libcxx-remove-mach-time-h.patch -d libcxx
37+
$(Q) patch -p0 < libcxx/0001-libcxx-fix-ld-errors.patch -d libcxx
38+
$(Q) patch -p0 < libcxx/0001-Fix-build-error-about-__GLIBC__.patch -d libcxx
39+
4040
endif
4141

42-
$(TOPDIR)/include/libcxx: libcxx
43-
$(Q) $(DIRLINK) $(CURDIR)/libcxx/include $(TOPDIR)/include/libcxx
42+
$(TOPDIR)/include/libcxx: libcxx/libcxx
43+
$(Q) $(DIRLINK) $(CURDIR)/$</include $(TOPDIR)/include/libcxx
4444
$(Q) cp $(CURDIR)/__config_site $(TOPDIR)/include/libcxx/__config_site
4545

4646
context:: $(TOPDIR)/include/libcxx
4747

4848
distclean::
4949
$(Q) $(DIRUNLINK) $(TOPDIR)/include/libcxx
50-
ifeq ($(wildcard libcxx/.git),)
50+
ifeq ($(wildcard libcxx/libcxx/.git),)
5151
$(Q) $(DELFILE) libcxx-$(LIBCXX_VERSION).src.tar.xz
52-
$(call DELDIR, libcxx)
52+
$(call DELDIR, libcxx/libcxx)
5353
endif
5454

5555
CXXFLAGS += ${DEFINE_PREFIX}_LIBCPP_BUILDING_LIBRARY
56-
CXXFLAGS += ${INCDIR_PREFIX}$(CURDIR)/libcxx/src
56+
CXXFLAGS += ${INCDIR_PREFIX}$(CURDIR)/libcxx/libcxx/src
5757

5858
ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
5959
CXXFLAGS += ${DEFINE_PREFIX}__GLIBCXX__
@@ -70,18 +70,17 @@ ifeq ($(shell expr "$(GCCVER)" \>= 12), 1)
7070
CXXFLAGS += -Wno-maybe-uninitialized -Wno-alloc-size-larger-than
7171
endif
7272

73-
CPPSRCS += $(wildcard libcxx/src/*.cpp)
74-
CPPSRCS += $(wildcard libcxx/src/experimental/*.cpp)
75-
CPPSRCS += $(wildcard libcxx/src/filesystem/*.cpp)
76-
CPPSRCS += $(wildcard libcxx/src/ryu/*.cpp)
73+
CPPSRCS += $(wildcard libcxx/libcxx/src/*.cpp)
74+
CPPSRCS += $(wildcard libcxx/libcxx/src/experimental/*.cpp)
75+
CPPSRCS += $(wildcard libcxx/libcxx/src/filesystem/*.cpp)
76+
CPPSRCS += $(wildcard libcxx/libcxx/src/ryu/*.cpp)
7777

7878
ifeq ($(CONFIG_CXX_LOCALIZATION),)
79-
LOCALE_CPPSRCS := libcxx/src/ios.cpp
80-
LOCALE_CPPSRCS += libcxx/src/ios.instantiations.cpp
81-
LOCALE_CPPSRCS += libcxx/src/iostream.cpp
82-
LOCALE_CPPSRCS += libcxx/src/locale.cpp
83-
LOCALE_CPPSRCS += libcxx/src/regex.cpp
84-
LOCALE_CPPSRCS += libcxx/src/strstream.cpp
79+
LOCALE_CPPSRCS := libcxx/libcxx/src/ios.cpp
80+
LOCALE_CPPSRCS += libcxx/libcxx/src/ios.instantiations.cpp
81+
LOCALE_CPPSRCS += libcxx/libcxx/src/iostream.cpp
82+
LOCALE_CPPSRCS += libcxx/libcxx/src/locale.cpp
83+
LOCALE_CPPSRCS += libcxx/libcxx/src/regex.cpp
84+
LOCALE_CPPSRCS += libcxx/libcxx/src/strstream.cpp
8585
CPPSRCS := $(filter-out $(LOCALE_CPPSRCS), $(CPPSRCS))
8686
endif
87-
File renamed without changes.

‎libs/libxx/libcxxabi.cmake

-123
This file was deleted.

‎libs/libxx/libcxxabi/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/libcxxabi

‎libs/libxx/libcxxabi/CMakeLists.txt

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ##############################################################################
2+
# libs/libxx/libcxxabi/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
if(CONFIG_LIBCXXABI)
23+
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxxabi)
24+
25+
set(LIBCXXABI_VERSION ${CONFIG_LIBCXXABI_VERSION})
26+
27+
FetchContent_Declare(
28+
libcxxabi
29+
DOWNLOAD_NAME "libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz"
30+
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
31+
URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LIBCXXABI_VERSION}/libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz"
32+
SOURCE_DIR
33+
${CMAKE_CURRENT_LIST_DIR}/libcxxabi
34+
BINARY_DIR
35+
${CMAKE_BINARY_DIR}/libs/libc/libcxxabi
36+
CONFIGURE_COMMAND
37+
""
38+
BUILD_COMMAND
39+
""
40+
INSTALL_COMMAND
41+
""
42+
TEST_COMMAND
43+
""
44+
PATCH_COMMAND ""
45+
DOWNLOAD_NO_PROGRESS true
46+
TIMEOUT 30)
47+
48+
FetchContent_GetProperties(libcxxabi)
49+
50+
if(NOT libcxxabi_POPULATED)
51+
FetchContent_Populate(libcxxabi)
52+
endif()
53+
endif()
54+
55+
set_property(
56+
TARGET nuttx
57+
APPEND
58+
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES
59+
${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include)
60+
61+
nuttx_add_system_library(libcxxabi)
62+
63+
set(SRCS)
64+
65+
# C++ABI files
66+
list(
67+
APPEND
68+
SRCS
69+
cxa_aux_runtime.cpp
70+
cxa_default_handlers.cpp
71+
cxa_demangle.cpp
72+
cxa_exception_storage.cpp
73+
cxa_guard.cpp
74+
cxa_handlers.cpp
75+
cxa_thread_atexit.cpp
76+
cxa_vector.cpp
77+
cxa_virtual.cpp)
78+
79+
# C++ STL files
80+
list(APPEND SRCS stdlib_exception.cpp stdlib_new_delete.cpp
81+
stdlib_stdexcept.cpp stdlib_typeinfo.cpp)
82+
83+
# Internal files
84+
list(APPEND SRCS abort_message.cpp fallback_malloc.cpp private_typeinfo.cpp)
85+
86+
if(CONFIG_CXX_EXCEPTION)
87+
list(APPEND SRCS cxa_exception.cpp cxa_personality.cpp)
88+
endif()
89+
90+
if(CONFIG_LIBCXXABI)
91+
add_compile_definitions(LIBCXX_BUILDING_LIBCXXABI)
92+
endif()
93+
94+
set(TARGET_SRCS)
95+
96+
foreach(src ${SRCS})
97+
string(PREPEND src libcxxabi/src/)
98+
list(APPEND TARGET_SRCS ${src})
99+
endforeach()
100+
101+
# RTTI is required for building the libcxxabi library
102+
target_compile_options(libcxxabi PRIVATE -frtti)
103+
104+
if(CONFIG_SIM_UBSAN OR CONFIG_MM_UBSAN)
105+
target_compile_options(libcxxabi PRIVATE -fno-sanitize=vptr)
106+
endif()
107+
108+
# Fix compilation error on ARM32:libcxxabi/src/cxa_personality.cpp:594:22:
109+
# error: '_URC_FATAL_PHASE1_ERROR' was not declared in this scope 594 |
110+
# results.reason = _URC_FATAL_PHASE1_ERROR;
111+
if(CONFIG_ARCH_ARM)
112+
target_compile_definitions(libcxxabi
113+
PRIVATE _URC_FATAL_PHASE2_ERROR=_URC_FAILURE)
114+
target_compile_definitions(libcxxabi
115+
PRIVATE _URC_FATAL_PHASE1_ERROR=_URC_FAILURE)
116+
endif()
117+
118+
target_compile_definitions(libcxxabi
119+
PRIVATE LIBCXXABI_NON_DEMANGLING_TERMINATE)
120+
121+
target_sources(libcxxabi PRIVATE ${TARGET_SRCS})
122+
target_include_directories(
123+
libcxxabi BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include
124+
${CMAKE_CURRENT_LIST_DIR}/libcxx/src)
125+
endif()

‎libs/libxx/libcxxabi.defs ‎libs/libxx/libcxxabi/Make.defs

+15-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# libs/libxx/libcxxabi.defs
2+
# libs/libxx/libcxxabi/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -23,34 +23,33 @@
2323
LIBCXXABI_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXXABI_VERSION))
2424

2525
# Download and unpack tarball if no git repo found
26-
ifeq ($(wildcard libcxxabi/.git),)
26+
ifeq ($(wildcard libcxxabi/libcxxabi/.git),)
2727
libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz:
28-
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXXABI_VERSION),libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz)
28+
$(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXXABI_VERSION),$@)
2929

30-
libcxxabi: libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz
31-
$(Q) tar -xf libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz
32-
$(Q) mv libcxxabi-$(LIBCXXABI_VERSION).src libcxxabi
33-
$(Q) patch -p0 < 0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch
34-
$(Q) patch -p0 < 0002-libcxxabi-fix-compilation-errors.patch
35-
$(Q) touch $@
30+
libcxxabi/libcxxabi: libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz
31+
$(Q) tar -xf $<
32+
$(Q) mv libcxxabi-$(LIBCXXABI_VERSION).src $@
33+
$(Q) patch -p0 < libcxxabi/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch -d libcxxabi
34+
$(Q) patch -p0 < libcxxabi/0002-libcxxabi-fix-compilation-errors.patch -d libcxxabi
3635
endif
3736

38-
$(TOPDIR)/include/libcxxabi: libcxxabi
39-
$(Q) $(DIRLINK) $(CURDIR)/libcxxabi/include $(TOPDIR)/include/libcxxabi
37+
$(TOPDIR)/include/libcxxabi: libcxxabi/libcxxabi
38+
$(Q) $(DIRLINK) $(CURDIR)/$</include $(TOPDIR)/include/libcxxabi
4039
$(Q) cp $(CURDIR)/__config_site $(TOPDIR)/include/libcxxabi/__config_site
4140

4241
context:: $(TOPDIR)/include/libcxxabi
4342

4443
distclean::
4544
$(Q) $(DIRUNLINK) $(TOPDIR)/include/libcxxabi
46-
ifeq ($(wildcard libcxxabi/.git),)
45+
ifeq ($(wildcard libcxxabi/libcxxabi/.git),)
4746
$(Q) $(DELFILE) libcxxabi-$(LIBCXX_VERSION).src.tar.xz
48-
$(call DELDIR, libcxxabi)
47+
$(call DELDIR, libcxxabi/libcxxabi)
4948
endif
5049

5150
ifeq ($(CONFIG_LIBCXXABI), y)
5251
CXXFLAGS += ${DEFINE_PREFIX}LIBCXX_BUILDING_LIBCXXABI
53-
CXXFLAGS += -I $(TOPDIR)/libs/libxx/libcxxabi/include
52+
CXXFLAGS += -I $(TOPDIR)/libs/libxx/libcxxabi/libcxxabi/include
5453

5554
# Disable dynamic type checking when enabling libcxxabi
5655
# It results in a recursive call:
@@ -85,5 +84,5 @@ CXXFLAGS += -DLIBCXXABI_NON_DEMANGLING_TERMINATE
8584
# RTTI is required for building the libcxxabi library
8685
CXXFLAGS += -frtti
8786

88-
DEPPATH += --dep-path libcxxabi/src
89-
VPATH += libcxxabi/src
87+
DEPPATH += --dep-path libcxxabi/libcxxabi/src
88+
VPATH += libcxxabi/libcxxabi/src
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# ##############################################################################
2-
# libs/libxx/libcxxmini.cmake
2+
# libs/libxx/libcxxmini/CMakeLists.txt
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -20,31 +20,35 @@
2020
#
2121
# ##############################################################################
2222

23-
nuttx_add_system_library(libcxxmini)
23+
if(CONFIG_LIBCXXMINI)
2424

25-
if(NOT CONFIG_XTENSA_TOOLCHAIN_XCC)
26-
add_compile_options(-Wno-missing-exception-spec)
27-
endif()
25+
nuttx_add_system_library(libcxxmini)
26+
27+
if(NOT CONFIG_XTENSA_TOOLCHAIN_XCC)
28+
add_compile_options(-Wno-missing-exception-spec)
29+
endif()
2830

29-
target_sources(
30-
libcxxmini
31-
PRIVATE libcxxmini/libxx_cxa_guard.cxx
32-
libcxxmini/libxx_cxapurevirtual.cxx
33-
libcxxmini/libxx_delete.cxx
34-
libcxxmini/libxx_delete_sized.cxx
35-
libcxxmini/libxx_deletea.cxx
36-
libcxxmini/libxx_deletea_sized.cxx
37-
libcxxmini/libxx_new.cxx
38-
libcxxmini/libxx_newa.cxx)
31+
target_sources(
32+
libcxxmini
33+
PRIVATE libxx_cxa_guard.cxx
34+
libxx_cxapurevirtual.cxx
35+
libxx_delete.cxx
36+
libxx_delete_sized.cxx
37+
libxx_deletea.cxx
38+
libxx_deletea_sized.cxx
39+
libxx_new.cxx
40+
libxx_newa.cxx)
3941

40-
# Why c++14? * libcxx seems to require c++11. * The compiler defaults varies:
41-
# clang/macOS (from xcode): 199711L gcc/ubuntu: 201402L * There is
42-
# a precedent to use c++14. (boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs)
42+
# Why c++14? * libcxx seems to require c++11. * The compiler defaults varies:
43+
# clang/macOS (from xcode): 199711L gcc/ubuntu: 201402L * There
44+
# is a precedent to use c++14.
45+
# (boards/arm/stm32l4/nucleo-l476rg/scripts/Make.defs)
4346

44-
set(CMAKE_CXX_STANDARD 14)
45-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
47+
set(CMAKE_CXX_STANDARD 14)
48+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4649

47-
set_property(
48-
TARGET nuttx
49-
APPEND
50-
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${NUTTX_DIR}/include/cxx)
50+
set_property(
51+
TARGET nuttx
52+
APPEND
53+
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${NUTTX_DIR}/include/cxx)
54+
endif()

‎libs/libxx/libcxxmini.defs ‎libs/libxx/libcxxmini/Make.defs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# libs/libxx/libcxxmini.defs
2+
# libs/libxx/libcxxmini/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#

‎libs/libxx/uClibc++.cmake

-114
This file was deleted.

‎libs/libxx/uClibc++/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/uClibc++

‎libs/libxx/uClibc++/CMakeLists.txt

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# ##############################################################################
2+
# libs/libxx/uClibc++/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_UCLIBCXX)
24+
set(UCLIBCXX_DIR ${CMAKE_CURRENT_LIST_DIR}/uClibc++)
25+
26+
if(NOT EXISTS ${UCLIBCXX_DIR})
27+
28+
set(UCLIBCXX_VERSION 0.2.5)
29+
30+
FetchContent_Declare(
31+
uClibc++
32+
DOWNLOAD_NAME "uClibc++-${UCLIBCXX_VERSION}.tar.bz2"
33+
DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR}
34+
URL "https://git.busybox.net/uClibc++/snapshot/uClibc++-${UCLIBCXX_VERSION}.tar.bz2"
35+
SOURCE_DIR
36+
${CMAKE_CURRENT_LIST_DIR}/uClibc++
37+
BINARY_DIR
38+
${CMAKE_BINARY_DIR}/libs/libc/uClibc++
39+
CONFIGURE_COMMAND
40+
""
41+
BUILD_COMMAND
42+
""
43+
INSTALL_COMMAND
44+
""
45+
TEST_COMMAND
46+
""
47+
PATCH_COMMAND
48+
patch -p1 -d ${CMAKE_CURRENT_LIST_DIR}/uClibc++ <
49+
${CMAKE_CURRENT_LIST_DIR}/0001-uClibcxx-basic_definitions-fix-GCC-specific-definiti.patch
50+
&& patch -p1 -d ${CMAKE_CURRENT_LIST_DIR}/uClibc++ <
51+
${CMAKE_CURRENT_LIST_DIR}/0001-uclibxx-use-overload-constructor-of-filebuf-ostream.patch
52+
DOWNLOAD_NO_PROGRESS true
53+
TIMEOUT 30)
54+
55+
FetchContent_GetProperties(uClibc++)
56+
57+
if(NOT uClibc++_POPULATED)
58+
FetchContent_Populate(uClibc++)
59+
endif()
60+
61+
endif()
62+
63+
nuttx_create_symlink(${CMAKE_CURRENT_LIST_DIR}/uClibc++/include
64+
${CMAKE_BINARY_DIR}/include/uClibc++)
65+
66+
configure_file(
67+
${CMAKE_CURRENT_LIST_DIR}/system_configuration.h
68+
${CMAKE_BINARY_DIR}/include/uClibc++/system_configuration.h COPYONLY)
69+
70+
set_property(
71+
TARGET nuttx
72+
APPEND
73+
PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/include/uClibc++)
74+
75+
set(SRCS
76+
algorithm.cpp
77+
associative_base.cpp
78+
bitset.cpp
79+
char_traits.cpp
80+
complex.cpp
81+
deque.cpp
82+
exception.cpp
83+
fstream.cpp
84+
func_exception.cpp
85+
iomanip.cpp
86+
ios.cpp
87+
iostream.cpp
88+
istream.cpp
89+
iterator.cpp
90+
limits.cpp
91+
list.cpp
92+
locale.cpp
93+
map.cpp
94+
numeric.cpp
95+
ostream.cpp
96+
queue.cpp
97+
set.cpp
98+
sstream.cpp
99+
stack.cpp
100+
stdexcept.cpp
101+
streambuf.cpp
102+
string.cpp
103+
utility.cpp
104+
valarray.cpp
105+
vector.cpp)
106+
107+
set(TARGET_SRCS)
108+
109+
foreach(src ${SRCS})
110+
string(PREPEND src uClibc++/src/)
111+
list(APPEND TARGET_SRCS ${src})
112+
endforeach()
113+
114+
nuttx_add_system_library(uClibc++)
115+
target_sources(uClibc++ PRIVATE ${TARGET_SRCS})
116+
endif()

‎libs/libxx/uClibc++.defs ‎libs/libxx/uClibc++/Make.defs

+18-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
############################################################################
2-
# libs/libxx/uClibc++.defs
2+
# libs/libxx/uClibc++/Make.defs
33
#
44
# SPDX-License-Identifier: Apache-2.0
55
#
@@ -23,27 +23,29 @@
2323
UCLIBCXX_VERSION=0.2.5
2424

2525
# Download and unpack tarball if no git repo found
26-
ifeq ($(wildcard uClibc++/.git),)
27-
uClibc++:
28-
curl -O -L https://git.busybox.net/uClibc++/snapshot/uClibc++-$(UCLIBCXX_VERSION).tar.bz2
29-
$(Q) tar -xf uClibc++-$(UCLIBCXX_VERSION).tar.bz2
30-
$(Q) $(DELFILE) uClibc++-$(UCLIBCXX_VERSION).tar.bz2
31-
$(Q) mv uClibc++-$(UCLIBCXX_VERSION) uClibc++
32-
$(Q) patch -p0 < 0001-uClibcxx-basic_definitions-fix-GCC-specific-definiti.patch
33-
$(Q) patch -p0 < 0001-uclibxx-use-overload-constructor-of-filebuf-ostream.patch
26+
ifeq ($(wildcard uClibc++/uClibc++/.git),)
27+
uClibc++-$(UCLIBCXX_VERSION).tar.bz2:
28+
curl -O -L https://git.busybox.net/uClibc++/snapshot/$@
29+
30+
uClibc++/uClibc++: uClibc++-$(UCLIBCXX_VERSION).tar.bz2
31+
$(Q) tar -xf $<
32+
$(Q) $(DELFILE) $<
33+
$(Q) mv uClibc++-$(UCLIBCXX_VERSION) $@
34+
$(Q) patch -p0 < uClibc++/0001-uClibcxx-basic_definitions-fix-GCC-specific-definiti.patch -d uClibc++
35+
$(Q) patch -p0 < uClibc++/0001-uclibxx-use-overload-constructor-of-filebuf-ostream.patch -d uClibc++
3436
endif
3537

36-
$(TOPDIR)/include/uClibc++: uClibc++
37-
$(Q) $(DIRLINK) $(CURDIR)/uClibc++/include $(TOPDIR)/include/uClibc++
38-
$(Q) $(COPYFILE) $(CURDIR)/system_configuration.h $(TOPDIR)/include/uClibc++
38+
$(TOPDIR)/include/uClibc++: uClibc++/uClibc++
39+
$(Q) $(DIRLINK) $(CURDIR)/uClibc++/uClibc++/include $(TOPDIR)/include/uClibc++
40+
$(Q) $(COPYFILE) $(CURDIR)/uClibc++/system_configuration.h $(TOPDIR)/include/uClibc++
3941

4042
context:: $(TOPDIR)/include/uClibc++
4143

4244
distclean::
4345
$(Q) $(DELFILE) $(TOPDIR)/include/uClibc++/system_configuration.h
4446
$(Q) $(DIRUNLINK) $(TOPDIR)/include/uClibc++
45-
ifeq ($(wildcard uClibc++/.git),)
46-
$(call DELDIR, uClibc++)
47+
ifeq ($(wildcard uClibc++/uClibc++/.git),)
48+
$(call DELDIR, uClibc++/uClibc++)
4749
endif
4850

4951
CPPSRCS += algorithm.cpp associative_base.cpp bitset.cpp char_traits.cpp
@@ -54,5 +56,5 @@ CPPSRCS += ostream.cpp queue.cpp set.cpp sstream.cpp stack.cpp stdexcept.cpp
5456
CPPSRCS += streambuf.cpp string.cpp utility.cpp valarray.cpp
5557
CPPSRCS += vector.cpp
5658

57-
DEPPATH += --dep-path uClibc++/src
58-
VPATH += uClibc++/src
59+
DEPPATH += --dep-path uClibc++/uClibc++/src
60+
VPATH += uClibc++/uClibc++/src
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.