From 2c79bdaf854155c9bfbd856000a641fa344d8368 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Wed, 6 Nov 2024 16:30:22 +0800 Subject: [PATCH] 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 --- .../qemu/qemu-armv7a/configs/gprof/defconfig | 75 +++++++++++ libs/libxx/.gitignore | 10 +- libs/libxx/CMakeLists.txt | 14 +- libs/libxx/Makefile | 10 +- libs/libxx/{etl.defs => etl/Make.defs} | 32 +++-- libs/libxx/libcxx.cmake | 125 ----------------- libs/libxx/libcxx/.gitignore | 1 + ...0001-Fix-build-error-about-__GLIBC__.patch | 0 .../0001-libcxx-fix-ld-errors.patch | 0 .../0001-libcxx-remove-mach-time-h.patch | 0 .../0001_fix_stdatomic_h_miss_typedef.patch | 0 libs/libxx/libcxx/CMakeLists.txt | 127 ++++++++++++++++++ libs/libxx/{libcxx.defs => libcxx/Make.defs} | 55 ++++---- libs/libxx/{ => libcxx}/mbstate_t.patch | 0 libs/libxx/libcxxabi.cmake | 123 ----------------- libs/libxx/libcxxabi/.gitignore | 1 + ...ild-warnings-generated-by-CMake-comp.patch | 0 ...002-libcxxabi-fix-compilation-errors.patch | 0 libs/libxx/libcxxabi/CMakeLists.txt | 125 +++++++++++++++++ .../{libcxxabi.defs => libcxxabi/Make.defs} | 31 +++-- .../CMakeLists.txt} | 52 +++---- .../{libcxxmini.defs => libcxxmini/Make.defs} | 2 +- libs/libxx/uClibc++.cmake | 114 ---------------- libs/libxx/uClibc++/.gitignore | 1 + ...efinitions-fix-GCC-specific-definiti.patch | 0 ...rload-constructor-of-filebuf-ostream.patch | 0 libs/libxx/uClibc++/CMakeLists.txt | 116 ++++++++++++++++ .../{uClibc++.defs => uClibc++/Make.defs} | 34 ++--- .../{ => uClibc++}/system_configuration.h | 0 29 files changed, 558 insertions(+), 490 deletions(-) create mode 100644 boards/arm/qemu/qemu-armv7a/configs/gprof/defconfig rename libs/libxx/{etl.defs => etl/Make.defs} (62%) delete mode 100644 libs/libxx/libcxx.cmake create mode 100644 libs/libxx/libcxx/.gitignore rename libs/libxx/{ => libcxx}/0001-Fix-build-error-about-__GLIBC__.patch (100%) rename libs/libxx/{ => libcxx}/0001-libcxx-fix-ld-errors.patch (100%) rename libs/libxx/{ => libcxx}/0001-libcxx-remove-mach-time-h.patch (100%) rename libs/libxx/{ => libcxx}/0001_fix_stdatomic_h_miss_typedef.patch (100%) create mode 100644 libs/libxx/libcxx/CMakeLists.txt rename libs/libxx/{libcxx.defs => libcxx/Make.defs} (60%) rename libs/libxx/{ => libcxx}/mbstate_t.patch (100%) delete mode 100644 libs/libxx/libcxxabi.cmake create mode 100644 libs/libxx/libcxxabi/.gitignore rename libs/libxx/{ => libcxxabi}/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch (100%) rename libs/libxx/{ => libcxxabi}/0002-libcxxabi-fix-compilation-errors.patch (100%) create mode 100644 libs/libxx/libcxxabi/CMakeLists.txt rename libs/libxx/{libcxxabi.defs => libcxxabi/Make.defs} (77%) rename libs/libxx/{libcxxmini.cmake => libcxxmini/CMakeLists.txt} (52%) rename libs/libxx/{libcxxmini.defs => libcxxmini/Make.defs} (97%) delete mode 100644 libs/libxx/uClibc++.cmake create mode 100644 libs/libxx/uClibc++/.gitignore rename libs/libxx/{ => uClibc++}/0001-uClibcxx-basic_definitions-fix-GCC-specific-definiti.patch (100%) rename libs/libxx/{ => uClibc++}/0001-uclibxx-use-overload-constructor-of-filebuf-ostream.patch (100%) create mode 100644 libs/libxx/uClibc++/CMakeLists.txt rename libs/libxx/{uClibc++.defs => uClibc++/Make.defs} (65%) rename libs/libxx/{ => uClibc++}/system_configuration.h (100%) diff --git a/boards/arm/qemu/qemu-armv7a/configs/gprof/defconfig b/boards/arm/qemu/qemu-armv7a/configs/gprof/defconfig new file mode 100644 index 0000000000000..0b6240065f86d --- /dev/null +++ b/boards/arm/qemu/qemu-armv7a/configs/gprof/defconfig @@ -0,0 +1,75 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ALARM_ARCH=y +CONFIG_ARCH="arm" +CONFIG_ARCH_BOARD="qemu-armv7a" +CONFIG_ARCH_BOARD_QEMU_ARMV7A=y +CONFIG_ARCH_CHIP="qemu" +CONFIG_ARCH_CHIP_QEMU_ARM=y +CONFIG_ARCH_CHIP_QEMU_CORTEXA7=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_LOWVECTORS=y +CONFIG_BUILTIN=y +CONFIG_DEBUG_ASSERTIONS=y +CONFIG_DEBUG_FEATURES=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SCHED=y +CONFIG_DEBUG_SCHED_ERROR=y +CONFIG_DEBUG_SCHED_INFO=y +CONFIG_DEBUG_SCHED_WARN=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_DEFAULT_TASK_STACKSIZE=4096 +CONFIG_DEV_ZERO=y +CONFIG_EXAMPLES_HELLO=y +CONFIG_EXPERIMENTAL=y +CONFIG_FLASH_SIZE=127926272 +CONFIG_FLASH_START=0x00600000 +CONFIG_FLASH_VSTART=0x00600000 +CONFIG_FS_PROCFS=y +CONFIG_FS_ROMFS=y +CONFIG_FS_TMPFS=y +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +CONFIG_IDLETHREAD_STACKSIZE=4096 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INTELHEX_BINARY=y +CONFIG_LIBC_EXECFUNCS=y +CONFIG_LIBC_MEMFD_ERROR=y +CONFIG_NSH_ARCHINIT=y +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_FILEIOSIZE=512 +CONFIG_NSH_READLINE=y +CONFIG_ONESHOT=y +CONFIG_PREALLOC_TIMERS=4 +CONFIG_RAMLOG=y +CONFIG_RAM_SIZE=132120576 +CONFIG_RAM_START=0x40200000 +CONFIG_RAM_VSTART=0x40200000 +CONFIG_RAW_BINARY=y +CONFIG_READLINE_CMD_HISTORY=y +CONFIG_RR_INTERVAL=200 +CONFIG_SCHED_GPROF=y +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_HPWORKPRIORITY=192 +CONFIG_STACK_COLORATION=y +CONFIG_START_DAY=25 +CONFIG_START_MONTH=4 +CONFIG_START_YEAR=2023 +CONFIG_SYMTAB_ORDEREDBYNAME=y +CONFIG_SYSTEM_GPROF=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SYSTEM=y +CONFIG_TESTING_GETPRIME=y +CONFIG_TESTING_KASAN=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART1_BASE=0x9000000 +CONFIG_UART1_IRQ=33 +CONFIG_UART1_PL011=y +CONFIG_UART1_SERIAL_CONSOLE=y +CONFIG_UART_PL011=y +CONFIG_USEC_PER_TICK=1000 diff --git a/libs/libxx/.gitignore b/libs/libxx/.gitignore index 318167c570687..12d63e1fd7c2e 100644 --- a/libs/libxx/.gitignore +++ b/libs/libxx/.gitignore @@ -1,8 +1,2 @@ -/uClibc++ -/libcxx -/libcxxabi -/libcxx-*.src.tar.xz -/libcxxabi-*.src.tar.xz -/etl -/.libcxx_patch -/.libcxxabi_patch +*.xz +*.bz2 diff --git a/libs/libxx/CMakeLists.txt b/libs/libxx/CMakeLists.txt index be615f4dd9391..56804a5557066 100644 --- a/libs/libxx/CMakeLists.txt +++ b/libs/libxx/CMakeLists.txt @@ -29,16 +29,4 @@ # the configuration problem. Refer to the README.txt file in the NuttX uClibc++ # GIT repository for more information -if(CONFIG_HAVE_CXX) - if(CONFIG_UCLIBCXX) - include(uClibc++.cmake) - elseif(CONFIG_LIBCXX) - include(libcxx.cmake) - elseif(CONFIG_LIBCXXMINI) - include(libcxxmini.cmake) - endif() - - if(CONFIG_LIBCXXABI) - include(libcxxabi.cmake) - endif() -endif() +nuttx_add_subdirectory() diff --git a/libs/libxx/Makefile b/libs/libxx/Makefile index 622b8809dbb66..86a9f0b7f792c 100644 --- a/libs/libxx/Makefile +++ b/libs/libxx/Makefile @@ -32,19 +32,19 @@ include $(TOPDIR)/Make.defs # in the NuttX uClibc++ GIT repository for more information ifeq ($(CONFIG_UCLIBCXX),y) -include uClibc++.defs +include uClibc++/Make.defs else ifeq ($(CONFIG_LIBCXX),y) -include libcxx.defs +include libcxx/Make.defs else ifeq ($(CONFIG_LIBCXXMINI),y) -include libcxxmini.defs +include libcxxmini/Make.defs endif ifeq ($(CONFIG_ETL),y) -include etl.defs +include etl/Make.defs endif ifeq ($(CONFIG_LIBCXXABI),y) -include libcxxabi.defs +include libcxxabi/Make.defs endif # Object Files diff --git a/libs/libxx/etl.defs b/libs/libxx/etl/Make.defs similarity index 62% rename from libs/libxx/etl.defs rename to libs/libxx/etl/Make.defs index 823c05d4d409e..c4f2230752de0 100644 --- a/libs/libxx/etl.defs +++ b/libs/libxx/etl/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# libs/libxx/etl.defs +# libs/libxx/etl/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -23,34 +23,32 @@ ETL_VERSION=20.32.1 # Download and unpack tarball if no git repo found -ifeq ($(wildcard etl/.git),) +ifeq ($(wildcard etl/etl/.git),) $(ETL_VERSION).tar.gz: - $(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$(ETL_VERSION).tar.gz) + $(call DOWNLOAD,https://github.com/ETLCPP/etl/archive/refs/tags,$@) -etl: $(ETL_VERSION).tar.gz - $(Q) tar -xf $(ETL_VERSION).tar.gz - $(Q) $(DELFILE) $(ETL_VERSION).tar.gz - $(Q) mv etl-$(ETL_VERSION) etl - $(Q) touch $@ +etl/etl: $(ETL_VERSION).tar.gz + $(Q) tar -xf $< + $(Q) $(DELFILE) $< + $(Q) mv etl-$(ETL_VERSION) $@ endif -$(TOPDIR)/include/etl: etl - $(Q) $(DIRLINK) $(CURDIR)/etl/include $(TOPDIR)/include/etl +$(TOPDIR)/include/etl: etl/etl + $(Q) $(DIRLINK) $(CURDIR)/$= 12), 1) CXXFLAGS += -Wno-maybe-uninitialized -Wno-alloc-size-larger-than endif -CPPSRCS += $(wildcard libcxx/src/*.cpp) -CPPSRCS += $(wildcard libcxx/src/experimental/*.cpp) -CPPSRCS += $(wildcard libcxx/src/filesystem/*.cpp) -CPPSRCS += $(wildcard libcxx/src/ryu/*.cpp) +CPPSRCS += $(wildcard libcxx/libcxx/src/*.cpp) +CPPSRCS += $(wildcard libcxx/libcxx/src/experimental/*.cpp) +CPPSRCS += $(wildcard libcxx/libcxx/src/filesystem/*.cpp) +CPPSRCS += $(wildcard libcxx/libcxx/src/ryu/*.cpp) ifeq ($(CONFIG_CXX_LOCALIZATION),) - LOCALE_CPPSRCS := libcxx/src/ios.cpp - LOCALE_CPPSRCS += libcxx/src/ios.instantiations.cpp - LOCALE_CPPSRCS += libcxx/src/iostream.cpp - LOCALE_CPPSRCS += libcxx/src/locale.cpp - LOCALE_CPPSRCS += libcxx/src/regex.cpp - LOCALE_CPPSRCS += libcxx/src/strstream.cpp + LOCALE_CPPSRCS := libcxx/libcxx/src/ios.cpp + LOCALE_CPPSRCS += libcxx/libcxx/src/ios.instantiations.cpp + LOCALE_CPPSRCS += libcxx/libcxx/src/iostream.cpp + LOCALE_CPPSRCS += libcxx/libcxx/src/locale.cpp + LOCALE_CPPSRCS += libcxx/libcxx/src/regex.cpp + LOCALE_CPPSRCS += libcxx/libcxx/src/strstream.cpp CPPSRCS := $(filter-out $(LOCALE_CPPSRCS), $(CPPSRCS)) endif - diff --git a/libs/libxx/mbstate_t.patch b/libs/libxx/libcxx/mbstate_t.patch similarity index 100% rename from libs/libxx/mbstate_t.patch rename to libs/libxx/libcxx/mbstate_t.patch diff --git a/libs/libxx/libcxxabi.cmake b/libs/libxx/libcxxabi.cmake deleted file mode 100644 index 078d35df9eec3..0000000000000 --- a/libs/libxx/libcxxabi.cmake +++ /dev/null @@ -1,123 +0,0 @@ -# ############################################################################## -# libs/libxx/libcxxabi.cmake -# -# SPDX-License-Identifier: Apache-2.0 -# -# 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. -# -# ############################################################################## - -if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxxabi) - - set(LIBCXXABI_VERSION ${CONFIG_LIBCXXABI_VERSION}) - - FetchContent_Declare( - libcxxabi - DOWNLOAD_NAME "libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz" - DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR} - URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LIBCXXABI_VERSION}/libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz" - SOURCE_DIR - ${CMAKE_CURRENT_LIST_DIR}/libcxxabi - BINARY_DIR - ${CMAKE_BINARY_DIR}/libs/libc/libcxxabi - CONFIGURE_COMMAND - "" - BUILD_COMMAND - "" - INSTALL_COMMAND - "" - TEST_COMMAND - "" - PATCH_COMMAND "" - DOWNLOAD_NO_PROGRESS true - TIMEOUT 30) - - FetchContent_GetProperties(libcxxabi) - - if(NOT libcxxabi_POPULATED) - FetchContent_Populate(libcxxabi) - endif() -endif() - -set_property( - TARGET nuttx - APPEND - PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES - ${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include) - -nuttx_add_system_library(libcxxabi) - -set(SRCS) - -# C++ABI files -list( - APPEND - SRCS - cxa_aux_runtime.cpp - cxa_default_handlers.cpp - cxa_demangle.cpp - cxa_exception_storage.cpp - cxa_guard.cpp - cxa_handlers.cpp - cxa_thread_atexit.cpp - cxa_vector.cpp - cxa_virtual.cpp) - -# C++ STL files -list(APPEND SRCS stdlib_exception.cpp stdlib_new_delete.cpp - stdlib_stdexcept.cpp stdlib_typeinfo.cpp) - -# Internal files -list(APPEND SRCS abort_message.cpp fallback_malloc.cpp private_typeinfo.cpp) - -if(CONFIG_CXX_EXCEPTION) - list(APPEND SRCS cxa_exception.cpp cxa_personality.cpp) -endif() - -if(CONFIG_LIBCXXABI) - add_compile_definitions(LIBCXX_BUILDING_LIBCXXABI) -endif() - -set(TARGET_SRCS) - -foreach(src ${SRCS}) - string(PREPEND src libcxxabi/src/) - list(APPEND TARGET_SRCS ${src}) -endforeach() - -# RTTI is required for building the libcxxabi library -target_compile_options(libcxxabi PRIVATE -frtti) - -if(CONFIG_SIM_UBSAN OR CONFIG_MM_UBSAN) - target_compile_options(libcxxabi PRIVATE -fno-sanitize=vptr) -endif() - -# Fix compilation error on ARM32:libcxxabi/src/cxa_personality.cpp:594:22: -# error: '_URC_FATAL_PHASE1_ERROR' was not declared in this scope 594 | -# results.reason = _URC_FATAL_PHASE1_ERROR; -if(CONFIG_ARCH_ARM) - target_compile_definitions(libcxxabi - PRIVATE _URC_FATAL_PHASE2_ERROR=_URC_FAILURE) - target_compile_definitions(libcxxabi - PRIVATE _URC_FATAL_PHASE1_ERROR=_URC_FAILURE) -endif() - -target_compile_definitions(libcxxabi PRIVATE LIBCXXABI_NON_DEMANGLING_TERMINATE) - -target_sources(libcxxabi PRIVATE ${TARGET_SRCS}) -target_include_directories( - libcxxabi BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include - ${CMAKE_CURRENT_LIST_DIR}/libcxx/src) diff --git a/libs/libxx/libcxxabi/.gitignore b/libs/libxx/libcxxabi/.gitignore new file mode 100644 index 0000000000000..8ed42390dc61a --- /dev/null +++ b/libs/libxx/libcxxabi/.gitignore @@ -0,0 +1 @@ +/libcxxabi diff --git a/libs/libxx/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch b/libs/libxx/libcxxabi/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch similarity index 100% rename from libs/libxx/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch rename to libs/libxx/libcxxabi/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch diff --git a/libs/libxx/0002-libcxxabi-fix-compilation-errors.patch b/libs/libxx/libcxxabi/0002-libcxxabi-fix-compilation-errors.patch similarity index 100% rename from libs/libxx/0002-libcxxabi-fix-compilation-errors.patch rename to libs/libxx/libcxxabi/0002-libcxxabi-fix-compilation-errors.patch diff --git a/libs/libxx/libcxxabi/CMakeLists.txt b/libs/libxx/libcxxabi/CMakeLists.txt new file mode 100644 index 0000000000000..96a6b2da2cd51 --- /dev/null +++ b/libs/libxx/libcxxabi/CMakeLists.txt @@ -0,0 +1,125 @@ +# ############################################################################## +# libs/libxx/libcxxabi/CMakeLists.txt +# +# SPDX-License-Identifier: Apache-2.0 +# +# 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. +# +# ############################################################################## +if(CONFIG_LIBCXXABI) + if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/libcxxabi) + + set(LIBCXXABI_VERSION ${CONFIG_LIBCXXABI_VERSION}) + + FetchContent_Declare( + libcxxabi + DOWNLOAD_NAME "libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz" + DOWNLOAD_DIR ${CMAKE_CURRENT_LIST_DIR} + URL "https://github.com/llvm/llvm-project/releases/download/llvmorg-${LIBCXXABI_VERSION}/libcxxabi-${LIBCXXABI_VERSION}.src.tar.xz" + SOURCE_DIR + ${CMAKE_CURRENT_LIST_DIR}/libcxxabi + BINARY_DIR + ${CMAKE_BINARY_DIR}/libs/libc/libcxxabi + CONFIGURE_COMMAND + "" + BUILD_COMMAND + "" + INSTALL_COMMAND + "" + TEST_COMMAND + "" + PATCH_COMMAND "" + DOWNLOAD_NO_PROGRESS true + TIMEOUT 30) + + FetchContent_GetProperties(libcxxabi) + + if(NOT libcxxabi_POPULATED) + FetchContent_Populate(libcxxabi) + endif() + endif() + + set_property( + TARGET nuttx + APPEND + PROPERTY NUTTX_CXX_INCLUDE_DIRECTORIES + ${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include) + + nuttx_add_system_library(libcxxabi) + + set(SRCS) + + # C++ABI files + list( + APPEND + SRCS + cxa_aux_runtime.cpp + cxa_default_handlers.cpp + cxa_demangle.cpp + cxa_exception_storage.cpp + cxa_guard.cpp + cxa_handlers.cpp + cxa_thread_atexit.cpp + cxa_vector.cpp + cxa_virtual.cpp) + + # C++ STL files + list(APPEND SRCS stdlib_exception.cpp stdlib_new_delete.cpp + stdlib_stdexcept.cpp stdlib_typeinfo.cpp) + + # Internal files + list(APPEND SRCS abort_message.cpp fallback_malloc.cpp private_typeinfo.cpp) + + if(CONFIG_CXX_EXCEPTION) + list(APPEND SRCS cxa_exception.cpp cxa_personality.cpp) + endif() + + if(CONFIG_LIBCXXABI) + add_compile_definitions(LIBCXX_BUILDING_LIBCXXABI) + endif() + + set(TARGET_SRCS) + + foreach(src ${SRCS}) + string(PREPEND src libcxxabi/src/) + list(APPEND TARGET_SRCS ${src}) + endforeach() + + # RTTI is required for building the libcxxabi library + target_compile_options(libcxxabi PRIVATE -frtti) + + if(CONFIG_SIM_UBSAN OR CONFIG_MM_UBSAN) + target_compile_options(libcxxabi PRIVATE -fno-sanitize=vptr) + endif() + + # Fix compilation error on ARM32:libcxxabi/src/cxa_personality.cpp:594:22: + # error: '_URC_FATAL_PHASE1_ERROR' was not declared in this scope 594 | + # results.reason = _URC_FATAL_PHASE1_ERROR; + if(CONFIG_ARCH_ARM) + target_compile_definitions(libcxxabi + PRIVATE _URC_FATAL_PHASE2_ERROR=_URC_FAILURE) + target_compile_definitions(libcxxabi + PRIVATE _URC_FATAL_PHASE1_ERROR=_URC_FAILURE) + endif() + + target_compile_definitions(libcxxabi + PRIVATE LIBCXXABI_NON_DEMANGLING_TERMINATE) + + target_sources(libcxxabi PRIVATE ${TARGET_SRCS}) + target_include_directories( + libcxxabi BEFORE PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libcxxabi/include + ${CMAKE_CURRENT_LIST_DIR}/libcxx/src) +endif() diff --git a/libs/libxx/libcxxabi.defs b/libs/libxx/libcxxabi/Make.defs similarity index 77% rename from libs/libxx/libcxxabi.defs rename to libs/libxx/libcxxabi/Make.defs index 76a028f9f44ca..362a7a575fce5 100644 --- a/libs/libxx/libcxxabi.defs +++ b/libs/libxx/libcxxabi/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# libs/libxx/libcxxabi.defs +# libs/libxx/libcxxabi/Make.defs # # SPDX-License-Identifier: Apache-2.0 # @@ -23,34 +23,33 @@ LIBCXXABI_VERSION=$(patsubst "%",%,$(CONFIG_LIBCXXABI_VERSION)) # Download and unpack tarball if no git repo found -ifeq ($(wildcard libcxxabi/.git),) +ifeq ($(wildcard libcxxabi/libcxxabi/.git),) 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) + $(call DOWNLOAD,https://github.com/llvm/llvm-project/releases/download/llvmorg-$(LIBCXXABI_VERSION),$@) -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-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch - $(Q) patch -p0 < 0002-libcxxabi-fix-compilation-errors.patch - $(Q) touch $@ +libcxxabi/libcxxabi: libcxxabi-$(LIBCXXABI_VERSION).src.tar.xz + $(Q) tar -xf $< + $(Q) mv libcxxabi-$(LIBCXXABI_VERSION).src $@ + $(Q) patch -p0 < libcxxabi/0001-libcxxabi-Fix-build-warnings-generated-by-CMake-comp.patch -d libcxxabi + $(Q) patch -p0 < libcxxabi/0002-libcxxabi-fix-compilation-errors.patch -d libcxxabi endif -$(TOPDIR)/include/libcxxabi: libcxxabi - $(Q) $(DIRLINK) $(CURDIR)/libcxxabi/include $(TOPDIR)/include/libcxxabi +$(TOPDIR)/include/libcxxabi: libcxxabi/libcxxabi + $(Q) $(DIRLINK) $(CURDIR)/$