wasi: handling of missing linker symbols (exceptions) (#19)

This commit is contained in:
sylefeb 2026-04-07 13:36:29 +02:00 committed by GitHub
parent e8eab9a45b
commit dc48418a51
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include <iostream>
#include <stdexcept>
#include <streambuf>
#include "wasmexcept.hpp"
#include "Bitstream.hpp"
#include "Chip.hpp"
#include "ChipConfig.hpp"

View File

@ -23,6 +23,7 @@
#include <iostream>
#include <stdexcept>
#include <streambuf>
#include "wasmexcept.hpp"
#include "Bitstream.hpp"
#include "Chip.hpp"
#include "ChipConfig.hpp"

View File

@ -0,0 +1,25 @@
#if defined(__wasm)
#include <cstdint>
#include <iostream>
extern "C" {
// FIXME: WASI does not currently support exceptions.
void *__cxa_allocate_exception(size_t thrown_size) throw() { return malloc(thrown_size); }
bool __cxa_uncaught_exception() throw();
void __cxa_throw(void *thrown_exception, struct std::type_info *tinfo, void (*dest)(void *)) { (void)thrown_exception; (void)tinfo; (void)dest; std::terminate(); }
}
namespace boost {
struct source_location;
void throw_exception(std::exception const &e) {
std::cerr << "boost::exception(): " << e.what() << std::endl;
exit(1);
}
void throw_exception(std::exception const &e, boost::source_location const &) {
std::cerr << "boost::exception(): " << e.what() << std::endl;
exit(1);
}
} // namespace boost
#endif