Summary:
Place a fork of LLVM git rev c179d7b006348005d2da228aed4c3c251590baa3
under `external/llvh`(1) and modify the CMake build to use it.
I am calling it a "fork", because it is not all of LLVM. Only the parts
that are used by Hermes are included, which at this time is only parts
of `libLLVMSupporrt`. Most(2) of LLVM build scripts are removed, and it
is treated just as another ordinary library.
(1) Why `llvh`? To be able to coexist with instances of the "real" LLVM,
we must change the namespace, all public symbols containing the `llvm`
string and the include directory name. `llvh` seemed as good a name as
any. I also considered `llvm-h` and `h-llvm`, but the problem is that
they are a superstring of `llvm` so it becomes harder to search for the
`llvm` string.
Note that the actual rename will happen in a follow up diff. It would be
a massive patch.
(2) libLLVMSupport relies on pretty elaborate feature detection scripts,
which would be painful to duplicate, so for now I have preserved them
under external/llvh/cmake.
Unfortunately turning LLVM into an ordinary library is not enough, since
we were implicitly relying on a lot of functionality provided by the
LLVM build scripts. Things like setting default warning flags, easily
turning exceptions on and off, etc.
I attempted to replace it with Hermes equivalents, which are now
provided by `cmake/Hermes.cmake`:
- `add_llvm_library/tool()` is replaced by `add_hermes_library/tool()`.
- Several `LLVM_xxx` variables are replaced my similar `HERMES_xxx`
ones.
As a result, building Hermes now requires only checking it out, and
running CMake and Ninja. It is a vastly simpler process than before.
== Limitations
- CMake LTO and ASAN builds aren't supported yet.
- The JIT requires the "real" LLVM for disassembly.
Reviewed By: avp
Differential Revision: D19658656
fbshipit-source-id: 5094d2af45e343973b1aab02c550a18b2bf93a06