From 4002171315bb294d9c518dd1f053072ced66e282 Mon Sep 17 00:00:00 2001
From: Joshua Nelson <jyn514@gmail.com>
Date: Sun, 21 Mar 2021 12:10:34 -0400
Subject: [PATCH] Download a more recent LLVM version if `src/version` is
 modified

When bumping the bootstrap version, the name of the generated LLVM
shared object file is changed, even though it's the same contents as
before. If bootstrap tries to use an older version, it will get linking
errors:

```
Building rustdoc for stage1 (x86_64-unknown-linux-gnu)
   Compiling rustdoc-tool v0.0.0 (/home/joshua/rustc/src/tools/rustdoc)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" ... lots of args ...
  = note: /usr/bin/ld: cannot find -lLLVM-12-rust-1.53.0-nightly
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: could not compile `rustdoc-tool`
```
---
 src/bootstrap/bootstrap.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 3e7d1d54f12..075756b73ba 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -463,6 +463,8 @@ class RustBuild(object):
                 "--",
                 "{}/src/llvm-project".format(top_level),
                 "{}/src/bootstrap/download-ci-llvm-stamp".format(top_level),
+                # the LLVM shared object file is named `LLVM-12-rust-{version}-nightly`
+                "{}/src/version".format(top_level)
             ]).decode(sys.getdefaultencoding()).strip()
             llvm_assertions = self.get_toml('assertions', 'llvm') == 'true'
             llvm_root = self.llvm_root()