Page MenuHomePhabricator

Don't error on CMAKE_SYSTEM_NAME=Wasi
Needs ReviewPublic

Authored by matthewbauer on Apr 16 2019, 10:18 PM.
This revision needs review, but there are no reviewers specified.



When CMAKE_SYSTEM_NAME=Wasi, we are not targeting UNIX or WIN32 but Wasi:

In this case, LLVM should recognize that this is a supported platform even though it is not UNIX or WIN32. Unlike Wasm, Wasi has a set ABI that provides some stability. The casing of "Wasi" is used instead of "WASI" to mirror that of the commonly used value of CMAKE_SYSTEM_NAME=Wasm for generic WebAssembly.

You can build libcxx and libcxxabi for Wasi given that you disable:

  • threads
  • exceptions
  • shared linking

This patch makes it possible to avoid lying to LLVM about Wasi being "UNIX" when it isn't. HandleLLVMOptions.cmake is included by libcxxabi any time you set an LLVM_* flag like LLVM_COMPILER_CHECKED, LLVM_PATH, or LLVM_ENABLE_LIBCXX.

Diff Detail

Event Timeline

matthewbauer created this revision.Apr 16 2019, 10:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 16 2019, 10:18 PM
sunfish added inline comments.Apr 16 2019, 10:35 PM

I don't know a lot about CMake, but would be better to add a predicate for WASI so that we can change these FUCHSIA OR UNIX conditions into FUCHSIA OR UNIX OR WASI conditions?

matthewbauer marked an inline comment as done.Apr 17 2019, 8:28 AM
matthewbauer added inline comments.

Maybe, although we'd have to make sure that LLVM_ON_UNIX and LLVM_HAVE_LINK_VERSION_SCRIPT are okay to set above. I think LLVM_HAVE_LINK_VERSION_SCRIPT is fine (lld should allow it) but not sure about LLVM_ON_UNIX.

We aren't really using this right now although at some point someone could port clang and llvm to run on Wasi I suppose. In the libcxxabi case LLVM_ON_UNIX might not be needed at all. We aren't actually building LLVM for Wasm, just using it for some headers.

matthewbauer marked an inline comment as done.Apr 17 2019, 8:29 AM
matthewbauer added inline comments.

LLVM_ON_UNIX isn't needed at all for libcxxabi. Building LLVM itself is a different story though.

Ericson2314 added inline comments.
129 this is where FUCHSIA comes from. I agree WASI should be defined upstream so it can be used here.

sunfish added inline comments.Apr 24 2019, 2:24 PM

As an updated here, I've now submitted