Skip to content

Commit

Permalink
Remove the LLVM bootstrap and use Hombrew installed LLVM-12. (carbon-…
Browse files Browse the repository at this point in the history
…language#551)

Now that LLVM 12 has been released we no longer have any need to
bootstrap LLVM to get the desired featureset. LLVM 12 is available
widely, including in Homebrew across multiple platforms and in the
GitHub action runners.

Sadly, the Linux distribution builds of LLVM-12 are largely broken and
not as useful for us. The Homebrew Linux install was also broken
originally, but I've worked extensively with the Homebrew folks to get
the Linux install into a really good shape. It should now work reliably.

There are two primary bugs in Linux LLVM packages that need to be fixed
before we can just use them:

- https://bugs.llvm.org/show_bug.cgi?id=43604
- https://bugs.llvm.org/show_bug.cgi?id=46321

Once those are addressed and point releases with the fixes widely
available we can further simplify things.

Even with the need to use Homebrew installs, using the released LLVM has
the extra advantage of making it easy to properly support Darwin ARM and
I've added that configuration so that I can test things there.

Last but not least, this will significantly shrink our build outputs
which should allow building much more in continuous integration on
GitHub actions without exceeding the action cache size limits. I've even
added several tweaks and adjustments to the compile and build flags to
improve the build performance and reduce the build output size.

Once this is landed and stable, we can consider adding the refactoring
tooling back to our CI.

One of the biggest downsides of this path is that our CI has to download
and install the LLVM toolchain from Homebrew on each run. This is pretty
slow (takes a couple of minutes). But it is a fixed overhead -- it won't
get worse over time. Eventually, we can either look at a much fancier
action configuration to avoid this or hopefully the Debian packages will
get updated and we can move back to those.

The bootstrapping has served us long enough at this point. We can
resurrect it if we ever find a compelling reason for breaking off of the
latest LLVM release as our host toolchain.

Co-authored-by: Jon Meow <[email protected]>
  • Loading branch information
chandlerc and jonmeow committed Jun 9, 2021
1 parent 40f60e6 commit 05261b7
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 340 deletions.
9 changes: 7 additions & 2 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ build --host_crosstool_top=@bazel_cc_toolchain
# https://github.com/bazelbuild/bazel/issues/13315
build --incompatible_dont_enable_host_nonhost_crosstool_features=false

# Default dynamic linking to off. While this can help build performance in some
# edge cases with very large linked executables and a slow linker, between using
# fast linkers on all platforms (LLD and the Apple linker), as well as having
# relatively few such executables, shared objects simply waste too much space in
# our builds.
build --dynamic_mode=off

# Completely disable Bazel's automatic stripping of debug information. Removing
# that information causes unhelpful backtraces from unittest failures and other
# crashes. Optimized builds already avoid using debug information by default.
build --strip=never

build:force_local_bootstrap --repo_env=CARBON_FORCE_LOCAL_BOOTSTRAP_BUILD=1

# Configuration for enabling Address Sanitizer. Note that this is enabled by
# default for fastbuild. The config is provided to enable ASan even in
# optimized or other build configurations.
Expand Down
40 changes: 38 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,47 @@ jobs:
go get github.com/bazelbuild/bazelisk
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
# Print the various tool versions to help in debugging.
- name: Print tool versions
# Setup to the latest LLVM and Clang release on Linux runners.
#
# Ideally we would use the pre-installed versions in the image, but the
# debian packages for LLVM-12 are broken due to several bugs:
# https://bugs.llvm.org/show_bug.cgi?id=43604
# https://bugs.llvm.org/show_bug.cgi?id=46321
#
# For now, we rely on Homebrew to manage installing a correctly built
# toolchain. We also take some care to be as resilient as possible to
# issues fetching and installing the toolchain.
- name: Setup LLVM and Clang on Ubuntu
if: matrix.os == 'ubuntu-latest'
run: |
brew update
brew install --force-bottle --only-dependencies llvm
brew install --force-bottle --force --verbose llvm
brew info llvm
brew config
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
# Just add the Homebrew installed LLVM to the path on macOS, the image has
# LLVM-12 pre-installed.
- name: Setup LLVM and Clang on macOS
if: matrix.os == 'macos-latest'
run: |
echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH
# Print the various tool paths and versions to help in debugging.
- name: Print tool debugging info
run: |
echo $PATH
which bazelisk
bazelisk --version
which python
python --version
which clang
clang --version
which clang++
clang++ --version
which clang-format
clang-format --version
# Make the date available to subsequent steps.
- name: Get date
Expand Down
10 changes: 1 addition & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,10 @@ pip_install(
requirements = "//github_tools:requirements.txt",
)

# Bootstrap a Clang and LLVM toolchain.
load("//bazel/cc_toolchains:clang_bootstrap.bzl", "bootstrap_clang_toolchain")

bootstrap_clang_toolchain(name = "bootstrap_clang_toolchain")

# Configure the bootstrapped Clang and LLVM toolchain for Bazel.
load("//bazel/cc_toolchains:clang_configuration.bzl", "configure_clang_toolchain")

configure_clang_toolchain(
name = "bazel_cc_toolchain",
clang = "@bootstrap_clang_toolchain//:bin/clang",
)
configure_clang_toolchain(name = "bazel_cc_toolchain")

local_repository(
name = "llvm_bazel",
Expand Down
1 change: 0 additions & 1 deletion bazel-clang-toolchain

This file was deleted.

280 changes: 0 additions & 280 deletions bazel/cc_toolchains/clang_bootstrap.bzl

This file was deleted.

Loading

0 comments on commit 05261b7

Please sign in to comment.