Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable exceptions, update to optimized newlib, migrate to new toolchain #5376

Merged
merged 56 commits into from
Dec 3, 2018
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9f88163
Move to PROGMEM aware libc, allow PSTR in printf()
earlephilhower Jan 12, 2018
f2e8c1c
Merge branch 'master' into pgmspace_to_libc
earlephilhower Aug 27, 2018
14b18ac
Fix merge error in #ifdef/#endif
earlephilhower Aug 27, 2018
f3f233d
Fix host test using the newlib generic pgmspace.h
earlephilhower Sep 11, 2018
336a2dc
Merge branch 'master' into pgmspace_to_libc
earlephilhower Sep 11, 2018
d57b7f1
Update with rebuilt libraries using latest newlib
earlephilhower Sep 11, 2018
03050e9
Include binaries built directly from @igrr repo
earlephilhower Oct 18, 2018
9e5b343
Merge branch 'master' into pgmspace_to_libc
earlephilhower Oct 18, 2018
9a0f1d0
Fix merge define conflict in c_types.h
Oct 18, 2018
909775c
Fix strlen_P misaligned source error
earlephilhower Oct 29, 2018
a110581
Fix strlen_P and strcpy_P edge cases
earlephilhower Oct 29, 2018
aba7eca
Fix memcpy_P return value
earlephilhower Oct 29, 2018
2a05f41
Merge branch 'master' into pgmspace_to_libc
earlephilhower Oct 30, 2018
71f1fe0
Fix strnlen_P/strlen_P off-by-4 error
earlephilhower Oct 30, 2018
d196cc0
Add device tests for libc functional verification
earlephilhower Nov 1, 2018
f6da831
Rebuild from igrr's repo (same source as prior)
earlephilhower Nov 1, 2018
5beb1a3
Merge branch 'master' into pgmspace_to_libc
devyte Nov 12, 2018
d459e5b
Merge branch 'master' into pgmspace_to_libc
devyte Nov 13, 2018
912e883
Merge branch 'master' into pgmspace_to_libc
devyte Nov 15, 2018
957dd31
WIP - add exceptions
earlephilhower Nov 23, 2018
671d679
Fix exception to have 0-terminator
earlephilhower Nov 23, 2018
3020504
Move some exception constants to TEXT from RODATA
earlephilhower Nov 24, 2018
877c3cb
Remove throw stubs
earlephilhower Nov 24, 2018
2e52c8a
Move more exception stuff to ROM
earlephilhower Nov 24, 2018
fd6c034
Enable exceptions in platform.io
earlephilhower Nov 25, 2018
857932f
Merge branch 'master' into exceptions
earlephilhower Nov 25, 2018
594622c
Remove atexit, is duplicated in rebuilt lib
earlephilhower Nov 25, 2018
d92a962
Update libgcc to remove soft-fp functions
earlephilhower Nov 25, 2018
3dca3b1
Merge branch 'master' into exceptions
devyte Nov 25, 2018
7089b8c
Merge branch 'master' into pgmspace_to_libc
earlephilhower Nov 26, 2018
aa8621b
Fix merge typos in Makefile
Nov 26, 2018
48f8c1a
Merge branch 'master' into exceptions
earlephilhower Nov 26, 2018
fddf4b8
Add unhandled exception handler to postmortem
earlephilhower Nov 27, 2018
7cde86c
Return our atexit() handler
earlephilhower Nov 27, 2018
e550eef
Latest stdc++, minimize exception emercengy area
earlephilhower Nov 27, 2018
9b4f422
Remove atexit from newlib
earlephilhower Nov 27, 2018
062b137
Move __FUNCTION__ static strings to PROGMEM
earlephilhower Nov 27, 2018
df71fa0
Clean up linker file, update to latest stdc++
earlephilhower Nov 27, 2018
d3bea41
Update to latest stdc++ which doesn't call strerror
earlephilhower Nov 27, 2018
0151dc8
Update to GCC5.1 exception emergency allocator
earlephilhower Nov 27, 2018
2e36af4
Merge branch 'master' into exceptions
earlephilhower Nov 27, 2018
e239a74
Initial try with new compiler toolchain
earlephilhower Nov 28, 2018
dc75c8b
Merge branch 'master' into exceptions
d-a-v Nov 28, 2018
25d9e96
Merge branch 'pgmspace_to_libc' into exceptions
earlephilhower Nov 28, 2018
4cc8911
Include newlib built from esp-quick-toolchain
earlephilhower Nov 28, 2018
ffaa93f
Update JSON with all new esp-quick-toolchain builds
earlephilhower Nov 28, 2018
bdc3d60
Merge branch 'master' into exceptions
earlephilhower Nov 28, 2018
9e05e46
Use 64bit Windows compiler on 64bit Windows
Nov 29, 2018
f5e80fb
Dump std::exception.what() when possible
earlephilhower Nov 30, 2018
d818a1c
Merge branch 'master' into exceptions
earlephilhower Nov 30, 2018
ff9b35a
Merge branch 'master' into exceptions
earlephilhower Dec 1, 2018
a5b6d1a
Use scripted install from esp-quick-toolchain
earlephilhower Dec 2, 2018
7642d03
Merge branch 'master' into exceptions
earlephilhower Dec 2, 2018
7aa4977
Update eqk to remove atexit, fix packaging diff
earlephilhower Dec 3, 2018
7a4a2fc
Merge branch 'master' into exceptions
earlephilhower Dec 3, 2018
2af047e
Merge branch 'master' into exceptions
earlephilhower Dec 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 0 additions & 78 deletions cores/esp8266/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,6 @@ using __cxxabiv1::__guard;
extern void *umm_last_fail_alloc_addr;
extern int umm_last_fail_alloc_size;

void *operator new(size_t size)
{
void *ret = malloc(size);
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
}
return ret;
}

void *operator new[](size_t size)
{
void *ret = malloc(size);
if (0 != size && 0 == ret) {
umm_last_fail_alloc_addr = __builtin_return_address(0);
umm_last_fail_alloc_size = size;
}
return ret;
}

void operator delete(void * ptr)
{
free(ptr);
}

void operator delete[](void * ptr)
{
free(ptr);
}

extern "C" void __cxa_pure_virtual(void) __attribute__ ((__noreturn__));
extern "C" void __cxa_deleted_virtual(void) __attribute__ ((__noreturn__));

Expand Down Expand Up @@ -98,53 +68,5 @@ extern "C" void __cxa_guard_abort(__guard* pg)
xt_wsr_ps(reinterpret_cast<guard_t*>(pg)->ps);
}


namespace std
{
void __throw_bad_function_call()
{
panic();
}

void __throw_length_error(char const*)
{
panic();
}

void __throw_bad_alloc()
{
panic();
}

void __throw_logic_error(const char* str)
{
(void) str;
panic();
}

void __throw_out_of_range(const char* str)
{
(void) str;
panic();
}

void __throw_bad_cast(void)
{
panic();
}

void __throw_ios_failure(const char* str)
{
(void) str;
panic();
}

void __throw_runtime_error(const char* str)
{
(void) str;
panic();
}
} // namespace std

// TODO: rebuild windows toolchain to make this unnecessary:
void* __dso_handle;
14 changes: 14 additions & 0 deletions cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,27 @@ static void loop_task(os_event_t *events) {
panic();
}
}
extern "C" {

struct object { long placeholder[ 10 ]; };
void __register_frame_info (const void *begin, struct object *ob);
extern char __eh_frame[];
}

static void do_global_ctors(void) {
static struct object ob;
__register_frame_info( __eh_frame, &ob );

void (**p)(void) = &__init_array_end;
while (p != &__init_array_start)
(*--p)();
}

void __gnu_cxx::__verbose_terminate_handler ()
{
panic();
}

void init_done() {
system_set_os_print(1);
gdb_init();
Expand Down
5 changes: 0 additions & 5 deletions cores/esp8266/libc_replacements.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,3 @@ void _exit(int status) {
(void) status;
abort();
}

int atexit(void (*func)()) {
(void) func;
return 0;
}
2 changes: 1 addition & 1 deletion platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 -lstdc++ -lm -lc -lgcc

compiler.cpp.cmd=xtensa-lx106-elf-g++
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 -std=c++11 -MMD -ffunction-sections -fdata-sections

compiler.as.cmd=xtensa-lx106-elf-as

Expand Down
1 change: 0 additions & 1 deletion tools/platformio-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def scons_patched_match_splitext(path, suffixes=None):

CXXFLAGS=[
"-fno-rtti",
"-fno-exceptions",
"-std=c++11"
],

Expand Down
21 changes: 20 additions & 1 deletion tools/sdk/ld/eagle.app.v6.common.ld.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,23 @@ SECTIONS
#ifdef VTABLES_IN_FLASH
*(.rodata._ZTV*) /* C++ vtables */
#endif
/* Exception stuff */
*(.rodata._ZTIN*)
*(.rodata._ZTSN*)
*(.rodata._ZZSt*)
*(.rodata._ZTISt*)
*(.rodata._ZTIN*)
*(.rodata._ZTSSt*)

*libgcc.a:unwind-dw2.o(.literal .text .rodata .literal.* .text.* .rodata.*)
*libgcc.a:unwind-dw2-fde.o(.literal .text .rodata .literal.* .text.* .rodata.*)

*libc.a:(.literal .text .literal.* .text.*)
*libm.a:(.literal .text .literal.* .text.*)
*libgcc.a:_umoddi3.o(.literal .text)
*libgcc.a:_udivdi3.o(.literal .text)
*libstdc++.a:( .literal .text .literal.* .text.*)
*libsmartconfig.a:(.literal .text .literal.* .text.*)
*libstdc++.a:(.literal .text .literal.* .text.*)
*liblwip_gcc.a:(.literal .text .literal.* .text.*)
*liblwip_src.a:(.literal .text .literal.* .text.*)
*liblwip2-536.a:(.literal .text .literal.* .text.*)
Expand All @@ -130,6 +141,14 @@ SECTIONS
*libwpa2.a:(.literal.* .text.*)
*libwps.a:(.literal.* .text.*)
*(.irom0.literal .irom.literal .irom.text.literal .irom0.text .irom0.text.* .irom.text .irom.text.*)

. = ALIGN(4);
*(.gcc_except_table .gcc_except_table.*)
. = ALIGN(4);
__eh_frame = ABSOLUTE(.);
KEEP(*(.eh_frame))
. = (. + 7) & ~ 3; /* Add a 0 entry to terminate the list */

_irom0_text_end = ABSOLUTE(.);
_flash_code_end = ABSOLUTE(.);
} >irom0_0_seg :irom0_0_phdr
Expand Down
Binary file modified tools/sdk/lib/libgcc.a
Binary file not shown.
Binary file modified tools/sdk/lib/libstdc++.a
Binary file not shown.