Skip to content

Support for C++ exceptionsΒ #565

@alexcrichton

Description

@alexcrichton

I noticed that there wasn't already a tracking issue for C++ exceptions, so I wanted to open one up to at least track the progress of this. Currently wasi-sdk does not support C++ exceptions, and trying to fiddle with the build locally shows that it's not a turnkey solution at this time or a small PR to some build configuration. Some questions that I ran into locally are:

  • Should exceptions support be provided in existing targets, or a new target? My assumption is that the entire C++ standard library needs to be built with/without exceptions meaning that technically -fexceptions wants an entirely different sysroot than -fno-exceptions. I don't believe that Clang currently dynamically selects a different sysroot based on this flag, so the next best thing we could do would be to add more targets. That would double the size of the target list, however.
  • Right now using the standard wasm exceptions proposal requires -mllvm -wasm-use-legacy-eh=false, and I'm not sure if that would require tripling the sysroot where one uses legacy eh, one doesn't, and one uses no eh.
  • Currently -fwasm-exceptions looks to be required, but I'm not sure if this is a temporary state of affairs or one that's intended to last.
  • Wasi-sdk looks like it will need to build LLVM's libunwind. There's a few build issues with this where it doesn't natively build for wasm as-is (even with all exception-related things turned on). It's not clear to me if (a) libunwind is not expected to build for wasm, (b) libunwind should be buildable as-is but maybe with different configuration, or (c) perhaps there are Emscripten patches to libunwind which haven't made their way into LLVM itself.
  • I don't know where the responsibility of passing -lunwind lies. Should the Clang driver automatically pass that? Should users be required to pass that?

These are the questions I've run into locally myself. From an implementation perspective all the "meat" of C++ exceptions is done in the sense that I was able to edit enough files to get something compiling and executing. The remaining bits of work are all on the toolchain side I believe (all of the above questions)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions