From 9be6939ee9490823f9fbafddee3d07000ebccf89 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Tue, 20 Sep 2022 14:21:02 -0700 Subject: [PATCH] Fix LLVM compilation issues (#2198) We've been having issues with asan builds on linux. This change should fix all of that. A build run can be found at: https://github.com/carbon-language/carbon-lang/actions/runs/3093378863/jobs/5005683059 (currently in progress, but I'm expecting it to succeed at this point) It may be that the issues with asan builds were actually related to caching. That is, maybe the brew build command didn't change enough between v14 and v15 that the cache hits were still an issue. We did notice this with 15.0.0 versus 15.0.1 include paths (that is, bazel wasn't happy using the cached results of a 15.0.0 build due to the skew in include paths). In order to address this, I've added CACHE_VERSION to the remote_cache setup. I've also set up corresponding buckets in Cloud. However, I'm also switching Linux to llvm-15 and apt. I'd originally been looking at this because the issues were linux-specific, and we've previously had linux-specific issues with Homebrew. Although it may have been the cache all along, I would prefer to keep this setup (if nothing else, it made the caching issues more obvious, even though we were still confused by the include path manifestation). --- .github/workflows/tests.yaml | 33 +++++++++------- .../clang_cc_toolchain_config.bzl | 4 ++ bazel/cc_toolchains/clang_configuration.bzl | 39 ++++++++++++------- .../clang_detected_variables.tpl.bzl | 1 + 4 files changed, 51 insertions(+), 26 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 1db77f739c6c..f13ebe946097 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -59,26 +59,19 @@ jobs: go get github.com/bazelbuild/bazelisk echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - # Setup to the latest LLVM and Clang release. - # - # Ideally we would use the pre-installed versions in the image, but the - # debian packages for LLVM-15 currently don't work for fastbuild. - # - # 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: Install Clang/LLVM using brew + # On macOS, use Homebrew to install a recent LLVM and Clang. + - name: Setup LLVM and Clang (macOS) + if: matrix.os == 'macos-latest' env: HOMEBREW_NO_INSTALL_CLEANUP: 1 HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1 - # Use llvm@14 because llvm (15) has sanitizer issues. run: | echo '*** Updating brew' brew update echo '*** Installing LLVM deps' - brew install --force-bottle --only-dependencies llvm@14 + brew install --force-bottle --only-dependencies llvm echo '*** Installing LLVM itself' - brew install --force-bottle --force --verbose llvm@14 + brew install --force-bottle --force --verbose llvm echo '*** brew info llvm' brew info llvm echo '*** brew config' @@ -86,6 +79,16 @@ jobs: echo '*** Updating PATH' echo "$(brew --prefix llvm)/bin" >> $GITHUB_PATH + # On Ubuntu, use apt.llvm.org to install a recent LLVM and Clang. + - name: Setup LLVM and Clang (Ubuntu) + if: matrix.os == 'ubuntu-latest' + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 15 all + rm llvm.sh + echo "/usr/lib/llvm-15/bin" >> $GITHUB_PATH + # Print the various tool paths and versions to help in debugging. - name: Print tool debugging info run: | @@ -114,10 +117,14 @@ jobs: # Add our bazel configuration and print basic info to ease debugging. - name: Configure Bazel and print info + env: + # Add a cache version for changes that bazel won't otherwise detect, + # like llvm version changes. + CACHE_VERSION: 1 run: | cat >user.bazelrc <