Discuss here different C compiler set ups, and compiling executables for the ESP8266

User avatar
By jcmvbkbc
#40389
bouvrais wrote:
  • Would libstdc++ need to be recompiled with -mlongcalls? Why is that not the default (or is it and something else explains this)?

Yes, but currently crosstool-NG does not support that. Will fix that soon.
User avatar
By bouvrais
#40406 That's very good to hear. It would be awesome.
Would you be kind enough to notify this topic whenever this is enabled?
I'll go and watch the crosstool-NG repo from time to time but I'm afraid I'll miss it :)
User avatar
By dkinzer
#40501
bouvrais wrote:I had to stub some libc functions on which libstdc++ rely and are not provided with the toolchain.

Are these the routines to which you refer?
Code: Select allvoid * operator new(size_t size);
void operator delete(void * ptr);
__extension__ typedef int __guard __attribute__((mode (__DI__)));
extern "C" int  __cxa_guard_acquire(__guard *);
extern "C" void __cxa_guard_release(__guard *);
extern "C" void __cxa_guard_abort(__guard *);
extern "C" void __cxa_pure_virtual(void);

#if defined(__xtensa__)
extern "C"
void abort()
{
    while (1)
        ;
}
#endif

void *
operator new(size_t size)
{
    return(os_malloc(size));
}

void *
operator new[](size_t size)
{
    return(os_malloc(size));
}

void
operator delete(void *ptr)
{
    if (ptr)
        os_free(ptr);
}

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

int
__cxa_guard_acquire(__guard *g)
{
    return(!*(char *)(g));
}

void
__cxa_guard_release(__guard *g)
{
    *(char *)g = 1;
}

void
__cxa_guard_abort(__guard *)
{
#if !defined(__AVR__)
    abort();
#endif
}

void
__cxa_pure_virtual(void)
{
#if !defined(__AVR__)
    abort();
#endif
}

void
__cxa_deleted_virtual(void)
{
#if !defined(__AVR__)
    abort();
#endif
}
User avatar
By bouvrais
#40531
dkinzer wrote:Are these the routines to which you refer?
Code: Select allvoid * operator new(size_t size);
void operator delete(void * ptr);
__extension__ typedef int __guard __attribute__((mode (__DI__)));
extern "C" int  __cxa_guard_acquire(__guard *);
extern "C" void __cxa_guard_release(__guard *);
extern "C" void __cxa_guard_abort(__guard *);
extern "C" void __cxa_pure_virtual(void);

#if defined(__xtensa__)
extern "C"
void abort()
{
    while (1)
        ;
}
#endif

void *
operator new(size_t size)
{
    return(os_malloc(size));
}

void *
operator new[](size_t size)
{
    return(os_malloc(size));
}

void
operator delete(void *ptr)
{
    if (ptr)
        os_free(ptr);
}

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

int
__cxa_guard_acquire(__guard *g)
{
    return(!*(char *)(g));
}

void
__cxa_guard_release(__guard *g)
{
    *(char *)g = 1;
}

void
__cxa_guard_abort(__guard *)
{
#if !defined(__AVR__)
    abort();
#endif
}

void
__cxa_pure_virtual(void)
{
#if !defined(__AVR__)
    abort();
#endif
}

void
__cxa_deleted_virtual(void)
{
#if !defined(__AVR__)
    abort();
#endif
}


Well, yes and no. I had those C++ allocation methods already in my project. I had seen on the forum (here) that those were needed as they don't seem to be provided by the toolchain by default.

I was actually referring to some standard libc functions (malloc, free, strlen, etc) for which Espressif usually provided replacement but with non-standard names/prototype. Since the C++ standard library relies on their standard prototype, those replacement are needed.
This is actually something I was inspired to do by looking at the Arduino IDE port and this file in particular.

JU