Skip to content

Commit

Permalink
Fix __cxa_finalize() signature
Browse files Browse the repository at this point in the history
Starting in gcc 11, <cxxabi.h> declares the __cxa_finalize() function
to return void, not an int as it was previously. The change has no
practical importance (our implementation always returned 0 anyway, there
was never any interesting integer to returned). But to get our
implementation to compile against both gcc-11 and pre-gcc-11's version
of cxxabi.h, we need to hide cxxabi.h's declaration.

Signed-off-by: Nadav Har'El <[email protected]>
Message-Id: <[email protected]>
  • Loading branch information
nyh authored and wkozaczuk committed Jun 14, 2021
1 parent 3601eba commit 4f67366
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <cstring>
#include <string.h>
#include <exception>
#include <cxxabi.h>
#include <sys/mman.h>
#include <unistd.h>
#include <link.h>
Expand Down Expand Up @@ -62,6 +61,14 @@
#include <pty.h>
#include <osv/pid.h>

// cxxabi.h from gcc 10 and earlier used to say that __cxa_finalize returns
// an int, while it should return void (and does so on gcc 11). To allow us
// to define __cxa_finalize with neither gcc 10 or 11 complaining, we need
// to hide the declaration in the header file
#define __cxa_finalize __cxa_finalize_ignore
#include <cxxabi.h>
#undef __cxa_finalize

#define __LC_LAST 13

#define __ALIAS(old, new) \
Expand Down Expand Up @@ -169,11 +176,11 @@ int __cxa_atexit(destructor_t destructor, void *arg, void *dso)
return 0;
}

int __cxa_finalize(void *dso)
void __cxa_finalize(void *dso)
{
if (!dso || dso == &__dso_handle) {
debug("__cxa_finalize() running kernel's destructors not supported\n");
return 0;
return;
}
std::vector<std::pair<destructor_t,void*>> my_destructors;
WITH_LOCK(destructors_mutex) {
Expand All @@ -183,7 +190,7 @@ int __cxa_finalize(void *dso)
for (auto d : boost::adaptors::reverse(my_destructors)) {
d.first(d.second);
}
return 0;
return;
}
}

Expand Down

0 comments on commit 4f67366

Please sign in to comment.