Change:
// For distribution we want the LLVM tools to be *statically* linked to libstdc++ if builder.config.llvm_tools_enabled || builder.config.lldb_enabled { <del> if !target.contains("windows") { </del> <ins> if !target.contains("msvc") { </ins> if target.contains("apple") { cfg.define("CMAKE_EXE_LINKER_FLAGS", "-static-libstdc++"); } else {

Discussion:
win764 msys64 $ install Updating only changed submodules Submodules updated in 1.12 seconds Finished dev [unoptimized] target(s) in 1.98s Building stage0 std artifacts (x8664-pc-windows-gnu -x8664-pc-windows-gnu) Finished release [optimized] target(s) in 1.75s Copying stage0 std from stage0 (x8664-pc-windows-gnu -x8664-pc-windows-gnu / x8664-pc-windows-gnu) Building stage0 test artifacts (x8664-pc-windows-gnu -x8664-pc-windows-gnu) Finished release [optimized] target(s) in 0.63s Copying stage0 test from stage0 (x8664-pc-windows-gnu -x8664-pc-windows-gnu / x8664-pc-windows-gnu) Building stage0 compiler artifacts (x8664-pc-windows-gnu -x8664-pc-windows-gnu) Finished release [optimized] target(s) in 2.89s Copying stage0 rustc from stage0 (x8664-pc-windows-gnu -x8664-pc-windows-gnu / x8664-pc-windows-gnu) Building stage0 codegen artifacts (x8664-pc-windows-gnu -x8664-pc-windows-gnu, llvm) warning: In file included from ../rustllvm/rustllvm.h:5, warning: from warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef<T::ArrayRef(const std::initializerlist<Tp&) [with T = long long unsigned int]': warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/IR/DIBuilder.h:645:74: required from here warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing 'llvm::ArrayRef<long long unsigned int::Data' from 'std::initializerlist<long long unsigned int::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime] warning: 102 | : Data(() == () ?

(T)nullptr : ()), warning: In file included from ../rustllvm/rustllvm.h:5, warning: from warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef<T::ArrayRef(const std::initializerlist<Tp&) [with T = long long unsigned int]': warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/IR/DIBuilder.h:645:74: required from here warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing 'llvm::ArrayRef<long long unsigned int::Data' from 'std::initializerlist<long long unsigned int::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime] warning: 102 | : Data(() == () ? (T)nullptr : ()), warning: In file included from ../rustllvm/rustllvm.h:5, warning: from warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef<T::ArrayRef(const std::initializerlist<Tp&) [with T = long long unsigned int]': warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/IR/DIBuilder.h:645:74: required from here warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing 'llvm::ArrayRef<long long unsigned int::Data' from 'std::initializerlist<long long unsigned int::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime] warning: 102 | : Data(() == () ?

(T)nullptr : ()), warning: In file included from C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/Linker/IRMover.h:13, warning: from C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/Linker/Linker.h:14, warning: from warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef<T::ArrayRef(const std::initializerlist<Tp&) [with T = long long unsigned int]': warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/IR/DIBuilder.h:645:74: required from here warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:102:37: warning: initializing 'llvm::ArrayRef<long long unsigned int::Data' from 'std::initializerlist<long long unsigned int::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime] warning: 102 | : Data(() == () ? (T)nullptr : ()), Finished release [optimized] target(s) in 0.48s Assembling stage1 compiler (x8664-pc-windows-gnu) Building stage1 std artifacts (x8664-pc-windows-gnu -x8664-pc-windows-gnu) Compiling core v0.0.0 (C:msys64workrustsrclibcore) Compiling compilerbuiltins v0.1.15 error: couldn't load codegen backend "C:msys64workrustbuildx8664-pc-windows-gnustage1librustlibx8664-pc-windows-gnucodegen-backendsrustccodegenllvm-": "The specified procedure could not be found. (os error 127)" error: Could not compile .

warning: build failed, waiting for other jobs to finish... error: build failed command did not execute successfully: "C:msys64workrustbuildx8664-pc-windows-gnustage0bin" "build" "--target" "x8664-pc-windows-gnu" "-j" "4" "--release" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "C:msys64workrust" "--message-format" "json" expected success, got: exit code: 101 failed to run: C:/msys64/work/rust/build/bootstrap/debug/bootstrap install Build completed unsuccessfully in 0:00:33
i found that, unlike stage0, in stage1 not copy following 3 files: libgccsseh-1.dll libstdc++-6.dll libwinpthread-1.dll C:dumpbin /dependents C:msys64workrustbuildx8664-pc-windows-gnust age1librustlibx8664-pc-windows-gnucodegen-backendsrustccodegenllvm- Microsoft (R) COFF/PE Dumper Version 14.22..1 Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file C:msys64workrustbuildx8664-pc-windows-gnustage1lib rustlibx8664-pc-windows-gnucodegen-backendsrustccodegenllvm- File Type: DLL Image has the following dependencies: libgccsseh-1.dll libstdc++-6.dll std- rustccratesioshim- rustcdatastructures- arena- syntaxpos- rustcerrors- rustctarget- syntax- rustcfsutil- rustc- rustcallocator- rustcincremental- rustccodegenutils- rustccodegenssa- Summary 1000 .CRT 2000 .bss .data 8000 .debugabbrev 1000 .debugaranges 3000 .debugframe .debuginfo .debugline 2B000 .debugloc 2000 .debugranges 2000 .debug_str 3EF000 .edata .idata A5000 .pdata FC0000 .rdata .reloc .rustc .text 1000 .tls E3000 .xdata
I have the same issue:
replace llvm with old / latest version in my private (which works fine 2019-5-18 in another computer), result same error.
found the reason, latest mingw gcc 9.1.0 cause some missing dll problem. (although, compile rust source was fine). if you have old version msys2, this will works for you: pacman -R mingw-w64-x8664-gcc mingw-w64-x8664-cmake pacman -R mingw-w64-x8664-gcc-libs pacman -U /var/cache/pacman/pkg/mingw-w64-x8664-gcc-libs-8.3.0-2- pacman -U /var/cache/pacman/pkg/mingw-w64-x8664-gcc-8.3.0-2- pacman -U /var/cache/pacman/pkg/mingw-w64-x8664-cmake-3.14.4-1- install rustc -vV rustc 1.37.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x86_64-pc-windows-gnu release: 1.37.0-dev LLVM version: 8.0
This issue is not fixed and shouldn't have been closed.

Technically correct, but rust is compiled fine with gcc 8.3 version. only problem with gcc 9.x, may be rust need to be modified with gcc 9.x syntax.
Ntldd output: Missing libraries can be found inside so probably something weird happens to during rustbuild. Nightly doesn't depend on :
I had the same issue... and the mingw gcc version is 9.2.0
you can install gcc 8.x from .
triage: P-high, due to blockage of , until someone can convince me otherwise.
triage: assigning to self for initial investigation.
with latest rust and gcc (from ubuntu 19.10), this bug looks like solved. $ ./rustc -vV rustc 1.40.0-dev binary: rustc commit-hash: unknown commit-date: unknown host: x8664-unknown-linux-gnu release: 1.40.0-dev LLVM version: 9.0 $ gcc -v Using built-in specs.

COLLECTGCC=gcc COLLECTLTOWRAPPER=/usr/lib/gcc/x8664-linux-gnu/9/lto-wrapper OFFLOADTARGETNAMES=nvptx-none:hsa OFFLOADTARGETDEFAULT=1 Target: x8664-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-8ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x8664-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x8664-linux-gnu --host=x8664-linux-gnu --target=x8664-linux-gnu Thread model: posix gcc version 9.2.1 (Ubuntu 9.2.1-8ubuntu1) $ uname -a Linux ubuntu 5.3.0-13-generic -Ubuntu SMP Tue Sep 24 02:46:08 UTC 2019 x8664 x8664 x86_64 GNU/Linux
it has never affected targets other than windows-gnu.
One downside of downgrading to gcc 8.3 and cmake 3.14 and building rust source is that I got errors messages similar to: and , both of which are resolved in the newer versions. There are workarounds and backports of the fixes, but it would be a lot easier to be able to just use the latest version of gcc.
visiting for triage.

Being honest (with myself and you): I just can't allocate time/resources to this bug. (It does not help that Windows is not a primary nor secondary dev platform for me.) Unassigning self and will post request for windows-dev to take this on
OK, so after a bit of debugging, here's what going on: The DLLs in are from an older version of MinGW. These come as part of the bootstrap package. The DLLs in are from a newer version of MinGW. They have extra symbols that are not present in the older DLLs. The stage1 rustc is built against the system MinGW libraries and the LLVM codegen backend depends on one of the new symbols from . is used to search for DLLs but the way bootstrap set this up ends up with having priority over . The binary doesn't link against libstdc++ and therefore works fine, however when the LLVM codegen backend is loaded, it will try to use the old which is missing some needed symbols.
As a workaround, you can copy the newer MinGW dlls from into .