Search code examples
c++rubyllvmsorbet

How to build Sorbet on Centos 7 (missing llvm_toolchain)


I am trying to build Stripe's Sorbet binary on Centos 7.5, and I have bazel 0.28.1 installed.

I tried building using bazel build //main:sorbet --config=dbg, but got this failure:

WARNING: The following configs were expanded more than once: [debugsymbols]. 
For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
INFO: Invocation ID: 1b2a6940-59ff-419f-ae57-f6e4129c2102
ERROR: /data/home/elemental/sorbet/main/BUILD:9:1: every rule of type cc_binary 
implicitly depends upon the target '@llvm_toolchain//:toolchain',
but this target could not be found because of: 
  no such package '@llvm_toolchain//': Traceback (most recent call last):
...

It looked like I was just missing llvm and llvm-toolset-7, but installing those did not help. What am I missing?


Solution

  • The location that needs to be modified is actually https://github.com/DarkDimius/bazel-toolchain/blob/dp-srb-now/toolchain/internal/llvm_distributions.bzl#L52

    Sorbet needs LLVM 8.0 to build(as we're using some of the recent parts of C++ language and standard library) and thus we download LLVM to get the toolchain that we develop with.

    As can be seen at http://releases.llvm.org/, LLVM no longer publishes CentOS builds and thus, I'd expect it to be easier for you to build it inside a ubuntu docker container than to use a custom version of llvm.

    Alternatively, you could attempt to pass --crosstool_top=@bazel_tools//tools/cpp:toolchain --host_crosstool_top=@bazel_tools//tools/cpp:toolchain to force our build to use your local C++ toolchain rather than the one we attempt to download. Note that if your toolchain isn't recent enough it may fail to compile Sorbet. We also do not test performance on any other toolchain than LLVM8 and we have seen in past substantial regressions when compiled with GCC.