aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.cc
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-05-23 19:50:09 +0000
committerwhitequark <whitequark@whitequark.org>2020-05-23 20:57:26 +0000
commite7bb04769d5d7262d3ecfd0de49953078174a880 (patch)
tree20100cd95832d9da3dcebcdb263ba5b05482ffe2 /common/nextpnr.cc
parent2692c6f6cce41d22847058c85715e8822feb9b87 (diff)
downloadnextpnr-e7bb04769d5d7262d3ecfd0de49953078174a880.tar.gz
nextpnr-e7bb04769d5d7262d3ecfd0de49953078174a880.tar.bz2
nextpnr-e7bb04769d5d7262d3ecfd0de49953078174a880.zip
Port nextpnr-{ice40,ecp5} to WASI.
This involves very few changes, all typical to WASM ports: * WASM doesn't currently support threads or atomics so those are disabled. * WASM doesn't currently support exceptions so the exception machinery is stubbed out. * WASM doesn't (and can't) have mmap(), so an emulation library is used. That library currently doesn't support MAP_SHARED flags, so MAP_PRIVATE is used instead. There is also an update to bring ECP5 bbasm CMake rules to parity with iCE40 ones, since although it is possible to embed chipdb into nextpnr on WASM, a 200 MB WASM file has very few practical uses. The README is not updated and there is no included toolchain file because at the moment it's not possible to build nextpnr with upstream boost and wasi-libc. Boost requires a patch (merged, will be available in boost 1.74.0), wasi-libc requires a few unmerged patches.
Diffstat (limited to 'common/nextpnr.cc')
-rw-r--r--common/nextpnr.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/nextpnr.cc b/common/nextpnr.cc
index 1156490c..c16a601c 100644
--- a/common/nextpnr.cc
+++ b/common/nextpnr.cc
@@ -23,6 +23,25 @@
#include "log.h"
#include "util.h"
+#if defined(__wasm)
+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*)) {
+ std::terminate();
+ }
+}
+
+namespace boost {
+ void throw_exception( std::exception const & e ) {
+ NEXTPNR_NAMESPACE::log_error("boost::exception(): %s\n", e.what());
+ }
+}
+#endif
+
NEXTPNR_NAMESPACE_BEGIN
assertion_failure::assertion_failure(std::string msg, std::string expr_str, std::string filename, int line)