mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 20:56:01 -04:00
b1c754bbb5
C++ support This change adds necessary support for compiling C++ programs: - linking against libstdc++ - implementation of static initialization guards using FreeRTOS primitives: since we don't have condition variables at our disposal, and we don't want to allocate a synchronization primitive for every guard variable generated by the compiler, we imitate condition variables using a combination of a mutex, counting semaphore, and a counter (based on [Microsoft Research paper](https://www.microsoft.com/en-us/research/wp-content/uploads/2004/12/ImplementingCVs.pdf), albeit because we don't need *arbitrary* code to use these CVs, implementation gets simpler). Note that libstdc++ also contains an implementation of `__cxa_guard_{acquire,release,abort}` functions. These implementations come from an `#ifndef GXX_THREADS` branch, i.e. are not aware of multthreading. There are three ways of replacing these libstdc++ functions with our implementation: 1. Move our code into gcc. Pros: cleanest solution. Cons: Such changes are unlikely to be merged by any upstream, so we end up maintaining our own forks of {gcc,crosstool-ng}. 2. Use library as it is built by crosstool, use `ar` to delete one object file (`guards.o`), add this library to ESP-IDF. Pros: easy to implement. Cons: libstdc++ is a 15MB binary 😯 3. Keep using libstdc++ from crosstool, force our implementation to be linked using a `-u` linker flag. Pros: no impact on repo size, easy to implement. Cons: somewhat less clean than 1 (and about as hacky as 2). For the reasons mentioned, option (3) looks like the best tradeoff. Ref. TW6702 See merge request !364 |
||
---|---|---|
.. | ||
hwcrypto | ||
include | ||
ld | ||
lib@21e433b827 | ||
test | ||
brownout.c | ||
component.mk | ||
cpu_freq.c | ||
cpu_start.c | ||
cpu_util.c | ||
crosscore_int.c | ||
deep_sleep.c | ||
event_default_handlers.c | ||
event_loop.c | ||
freertos_hooks.c | ||
gdbstub.c | ||
heap_alloc_caps.c | ||
hw_random.c | ||
int_wdt.c | ||
intr_alloc.c | ||
ipc.c | ||
Kconfig | ||
lib_printf.c | ||
libhal.a | ||
Makefile.projbuild | ||
panic.c | ||
phy_init_data.h | ||
phy_init.c | ||
phy.h | ||
rtc.h | ||
spiram.h | ||
system_api.c | ||
task_wdt.c |