<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>src/ci/scripts/install-clang.sh - fork/rust @ 1.43.0</title>
<meta name="description" content="src/ci/scripts/install-clang.sh in fork/rust at 1.43.0.">
<meta property="og:title" content="src/ci/scripts/install-clang.sh - fork/rust @ 1.43.0">
<meta property="og:description" content="src/ci/scripts/install-clang.sh in fork/rust at 1.43.0.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="1.43.0" data-tip="4fb7144ed159f94491249e86d5bbd033b5d60550">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/rust</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/rust</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">bors</span><span class="commit-message" data-commit="4fb7144ed159f94491249e86d5bbd033b5d60550">Auto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum</span><span class="snapshot-sha sha" data-commit="4fb7144ed159f94491249e86d5bbd033b5d60550">4fb7144ed15</span><time datetime="2020-04-20T22:16:25+00:00" title="2020-04-20 22:16:25 +0000">2020-04-20</time></p>
<header class="topbar"><details class="switcher"><summary>1.43.0</summary><div class="menu"><strong>branches</strong><a href="/fork/rust/ref/master/">master</a><strong>tags</strong><a href="/fork/rust/ref/1.39.0/">1.39.0</a><a href="/fork/rust/ref/1.40.0/">1.40.0</a><a href="/fork/rust/ref/1.41.0/">1.41.0</a><a href="/fork/rust/ref/1.41.1/">1.41.1</a><a href="/fork/rust/ref/1.42.0/">1.42.0</a><a class="current" href="/fork/rust/ref/1.43.0/">1.43.0</a><a href="/fork/rust/ref/1.43.1/">1.43.1</a><a href="/fork/rust/ref/1.44.0/">1.44.0</a><a class="all" href="/fork/rust/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/rust/">rust</a> / <a href="/fork/rust/ref/1.43.0/tree/src/">src</a> / <a href="/fork/rust/ref/1.43.0/tree/src/ci/">ci</a> / <a href="/fork/rust/ref/1.43.0/tree/src/ci/scripts/">scripts</a> / <span class="cur">install-clang.sh</span></nav>
<span class="view-stats"><span>2.4 KiB</span><span>51 lines</span></span><span class="actions"><a class="raw" href="/fork/rust/raw/c242f5d4562690ba8f0c310bd86df305cee523ef/src/ci/scripts/install-clang.sh">raw</a></span></header>
<pre class="code src" data-hl="src/ci/scripts/install-clang.sh"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text">#!/bin/bash</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"># This script installs clang on the local machine. Note that we don't install</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text"># clang on Linux since its compiler story is just so different. Each container</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"># has its own toolchain configured appropriately already.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text">set -euo pipefail</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">IFS=$'\n\t'</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text">source &quot;$(cd &quot;$(dirname &quot;$0&quot;)&quot; &amp;&amp; pwd)/../shared.sh&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text">if isMacOS; then</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text">    curl -f &quot;${MIRRORS_BASE}/clang%2Bllvm-9.0.0-x86_64-darwin-apple.tar.xz&quot; | tar xJf -</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text">    ciCommandSetEnv CC &quot;$(pwd)/clang+llvm-9.0.0-x86_64-darwin-apple/bin/clang&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text">    ciCommandSetEnv CXX &quot;$(pwd)/clang+llvm-9.0.0-x86_64-darwin-apple/bin/clang++&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text">    # macOS 10.15 onwards doesn't have libraries in /usr/include anymore: those</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text">    # are now located deep into the filesystem, under Xcode's own files. The</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text">    # native clang is configured to use the correct path, but our custom one</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text">    # doesn't. This sets the SDKROOT environment variable to the SDK so that</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text">    # our own clang can figure out the correct include path on its own.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text">    ciCommandSetEnv SDKROOT &quot;$(xcrun --sdk macosx --show-sdk-path)&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text">    # Configure `AR` specifically so rustbuild doesn't try to infer it as</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text">    # `clang-ar` by accident.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text">    ciCommandSetEnv AR &quot;ar&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text">elif isWindows &amp;&amp; [[ ${CUSTOM_MINGW-0} -ne 1 ]]; then</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text">    # If we're compiling for MSVC then we, like most other distribution builders,</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text">    # switch to clang as the compiler. This'll allow us eventually to enable LTO</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text">    # amongst LLVM and rustc. Note that we only do this on MSVC as I don't think</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text">    # clang has an output mode compatible with MinGW that we need. If it does we</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text">    # should switch to clang for MinGW as well!</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text">    #</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text">    # Note that the LLVM installer is an NSIS installer</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text">    #</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text">    # Original downloaded here came from</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text">    # http://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text">    # That installer was run through `wine ./installer.exe /S /NCRC` on Linux</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text">    # and then the resulting installation directory (found in</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text">    # `$HOME/.wine/drive_c/Program Files/LLVM`) was packaged up into a tarball.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text">    # We've had issues otherwise that the installer will randomly hang, provide</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text">    # not a lot of useful information, pollute global state, etc. In general the</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text">    # tarball is just more confined and easier to deal with when working with</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text">    # various CI environments.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text">    mkdir -p citools</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text">    cd citools</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text">    curl -f &quot;${MIRRORS_BASE}/LLVM-9.0.0-win64.tar.gz&quot; | tar xzf -</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text">    ciCommandSetEnv RUST_CONFIGURE_ARGS \</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text">        &quot;${RUST_CONFIGURE_ARGS} --set llvm.clang-cl=$(pwd)/clang-rust/bin/clang-cl.exe&quot;</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text">fi</span></span></pre>
</main>
</body>
</html>
