* Move ctors and init_array from the CPP library
to the kernel library, as this is common for both C
and C++ and it is the kernel who is running it.
* Rename the hidden kconfig option CPP_STATIC_INIT_GNU
STATIC_INIT_GNU instead.
* If STATIC_INIT_GNU is not selected verify there is
constructors left behind.
* Rename common-rom-cpp.ld to common-rom-init.ld
* Rename z_cpp_init_static to z_init_static,
and have the kernel always call it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Keith Packard <keithp@keithp.com>
These Kconfigs should have been deprecated for more than 2
releases, remove them:
- `CONFIG_CPP_MAIN`
- `CONFIG_CPLUSPLUS`
- `CONFIG_LIB_CPLUSPLUS`
- `CONFIG_EXCEPTIONS`
- `CONFIG_RTTI`
Signed-off-by: Yong Cong Sin <ycsin@meta.com>
LLVM toolchain provides its own C++ standard library called libc++.
This patch adds new LLVM_LIBCXX config which should be used to indicate
that libc++ is used.
Information about library can be found at https://libcxx.llvm.org
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Picolibc dependencies limit ability to use third party minimal
implementations of CPP when enablng PICOLIBC_USE_MODULE.
Signed-off-by: Al Semjonovs <asemjonovs@google.com>
Add a name to the choice group for selecting the C++
standard to be able to override the default standard in
Kconfig.* files.
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
So they depend or select on the right NATIVE_BUILD
instead of NATIVE_APPLICATION.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
With Zephyr now always using `int main(void)`, there's no longer any need
for this definition. The last remaining use which gated the declaration of
_posix_zephyr_main isn't necessary as adding that declaration
unconditionally is harmless.
Signed-off-by: Keith Packard <keithp@keithp.com>
For the POSIX architecture we do not define an
empty __cxa_atexit() as it otherwise would
override its host libC counterpart. And this would
both disable the atexit() hooks, and prevent possible
test code global destructors from being registered.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Introduce Kconfig symbol FULL_LIBCPP_SUPPORTED that is similar to the
C version FULL_LIBC_SUPPORTED. This way we can utilize the same
pattern in tests and samples to filter for when a full libc++ is
needed.
Signed-off-by: Kumar Gala <kumar.gala@intel.com>
Add a prompt to the Kconfig symbol so that applications can select this in
to guide C++ standard library selection towards configurations which
provide a complete implementation.
Signed-off-by: Keith Packard <keithp@keithp.com>
libstdc++ is supported with Picolibc only when the toolchain version of
Picolibc is use -- libstdc++ must be built using a specific Picolibc build
and libstdc++ is included with the toolchain.
Ideally, we'd allow the use of the Picolibc module whenever we weren't
using the GNU libstdc++, including when using the minimal libc++. However,
the obvious dependency settings create a loop:
config PICOLIBC
depends on PICOLIBC_SUPPORTED
config PICOLIBC_SUPPORTED
depends on !(GLIBCXX_LIBCPP && "$(ZEPHYR_TOOCHAIN_VARIANT" = "zephyr")
config GLIBCXX_LIBCPP
depends on NEWLIB_LIBC || PICOLIBC
To break this loop, we replace GLIBCXX_LIBCPP in the second block with
CPP:
config PICOLIBC_SUPPORTED
depends on !(CPP && "$(ZEPHYR_TOOCHAIN_VARIANT" = "zephyr")
This means that picolibc cannot be used with any C++ apps when using the
Zephyr SDK, even when not using the GNU libstdc++. However, Zephyr SDK 0.16
will come with an additional Kconfig file that includes:
config PICOLIBC_SUPPORTED
def_bool y
depends on "$(ZEPHYR_TOOLCHAIN_VARIANT)" = "zephyr"
This will override the Kconfig bits included in Zephyr and allow use of the
Picolibc module with C++ code, including using the minimal libc++ bits.
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit reworks the C++ standard library configurations such that:
* the separation between the Zephyr minimal C++ library and the fully
featured C++ standard libraries, such as GNU libstdc++, is clear.
This is done by deprecating the Kconfig `CONFIG_LIB_CPLUSPLUS`
symbol, which implies that the minimal C++ library is selected when
set to `n`, and introducing the `CONFIG_MINIMAL_LIBCPP` symbol.
* the type of the selected C++ standard library is clear. This is done
by introducing a Kconfig choice, `LIBCPP_IMPLEMENTATION`, for the C++
standard library type and providing the choice symbols for each
library type supported, such as `CONFIG_MINIMAL_LIBCPP` and
`CONFIG_GLIBCXX_LIBCPP`.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
The Kconfig `CONFIG_RTTI` symbol enables the C++ Run-Time Type
Information (RTTI) support and is a feature of the standard C++
library; therefore, it should be prefixed with `CPP_` as with the rest
of the C++-specific symbols.
This commit renames the Kconfig `CONFIG_RTTI` symbol to
`CONFIG_CPP_RTTI` in order to better align with the other existing C++
Kconfig symbols, and deprecates the old `CONFIG_RTTI` symbol.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
`CONFIG_EXCEPTIONS` is ambiguous in that the word "exception" may be
used to refer to many different types of exceptions, from the hardware
generated faults and interrupts (aka. exceptions) to the C++
exceptions.
This commit renames the Kconfig `CONFIG_EXCEPTIONS` symbol to
`CONFIG_CPP_EXCEPTIONS` in order to clarify that the symbol refers to
the C++ exceptions and eliminate any ambiguity, and deprecates the old
`CONFIG_EXCEPTIONS` symbol.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
There is no reason for the top-level C++ Kconfig symbol to be called
`CPLUSPLUS` when the convention used throughout the Zephyr codebase is
to use "cpp" to refer to C++ and the rest of the C++-related Kconfig
symbols are prefixed with `CPP_`.
This commit renames the Kconfig `CPLUSPLUS` symbol to `CPP` in order to
better align with the de-facto standard naming convention used throughout
the Zephyr codebase, and deprecates the old `CPLUSPLUS` symbol.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This commit relocates the "C++ minimal library" components, that
implement a very limited subset of the standard C++ library, to a
dedicated directory, `lib/cpp/minimal`, in order to provide a clear
separation among the different C++ library components.
After this refactoring, the top `lib/cpp` directory should only contain
the sub-directories for each C++ library (i.e. `abi`, `minimal`). In
the future, a C++ library-specific shim layer implementation may be
added as sub-directories under `lib/cpp` as well (e.g. `libstdc++`
sub-directory containing the shim layer implementation for the GCC
libstdc++ library) -- this is similar to how the libc directories are
structured under `lib/libc`.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This commit relocates the "C++ ABI library" components such as
global constructor/destructor and initialiser handlers to a dedicated
directory, `lib/cpp/abi`, in order to provide a clear separation
between the C++ ABI/runtime library and the standard C++ library
components.
Note that the Zephyr C++ ABI library currently implements the GNU/GCC
C++ ABI, which is the de-facto standard ABI used by many compilers
including Clang -- it may be necessary to sub-divide the `lib/cpp/abi`
into `lib/cpp/abi/gnu` and `lib/cpp/abi/someotherabi` in the future
when adding the support for a C++ compiler that expects an ABI vastly
different from the GNU C++ ABI.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>
This commit moves the files under `subsys/cpp` directory to the
`lib/cpp` directory because the C++ ABI runtime library and the
standard C++ library components are not a "subsystem" (aka. API) in
conventional sense and is better described as a "library."
Classifying the C++ ABI runtime library and the standard C++ library as
"libraries" instead of "subsystems" also better aligns with how the
existing C standard library implementation (`lib/libc`) is handled.
Signed-off-by: Stephanos Ioannidis <stephanos.ioannidis@nordicsemi.no>