Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

couldn't load codegen backend on windows-gnu #61561

Closed
sailfish009 opened this issue Jun 5, 2019 · 17 comments · Fixed by #65911
Closed

couldn't load codegen backend on windows-gnu #61561

sailfish009 opened this issue Jun 5, 2019 · 17 comments · Fixed by #65911
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@sailfish009
Copy link

win7_64 msys64

$ ./x.py install
Updating only changed submodules
Submodules updated in 1.12 seconds
Finished dev [unoptimized] target(s) in 1.98s
Building stage0 std artifacts (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu)
Finished release [optimized] target(s) in 1.75s
Copying stage0 std from stage0 (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu / x86_64-pc-windows-gnu)
Building stage0 test artifacts (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu)
Finished release [optimized] target(s) in 0.63s
Copying stage0 test from stage0 (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu / x86_64-pc-windows-gnu)
Building stage0 compiler artifacts (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu)
Finished release [optimized] target(s) in 2.89s
Copying stage0 rustc from stage0 (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu / x86_64-pc-windows-gnu)
Building stage0 codegen artifacts (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu, llvm)
warning: In file included from ../rustllvm/rustllvm.h:5,
warning: from ../rustllvm/PassWrapper.cpp:6:
warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef::ArrayRef(const std::initializer_list<_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::Data' from 'std::initializer_list::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
warning: 102 | : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
warning: In file included from ../rustllvm/rustllvm.h:5,
warning: from ../rustllvm/RustWrapper.cpp:1:
warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef::ArrayRef(const std::initializer_list<_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::Data' from 'std::initializer_list::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
warning: 102 | : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
warning: In file included from ../rustllvm/rustllvm.h:5,
warning: from ../rustllvm/ArchiveWrapper.cpp:1:
warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef::ArrayRef(const std::initializer_list<_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::Data' from 'std::initializer_list::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
warning: 102 | : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
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 ../rustllvm/Linker.cpp:1:
warning: C:/msys64/work/rust/src/llvm-project/llvm/include/llvm/ADT/ArrayRef.h: In instantiation of 'llvm::ArrayRef::ArrayRef(const std::initializer_list<_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::Data' from 'std::initializer_list::begin' does not extend the lifetime of the underlying array [-Winit-list-lifetime]
warning: 102 | : Data(Vec.begin() == Vec.end() ? (T*)nullptr : Vec.begin()),
Finished release [optimized] target(s) in 0.48s
Assembling stage1 compiler (x86_64-pc-windows-gnu)
Building stage1 std artifacts (x86_64-pc-windows-gnu -> x86_64-pc-windows-gnu)
Compiling core v0.0.0 (C:\msys64\work\rust\src\libcore)
Compiling compiler_builtins v0.1.15
error: couldn't load codegen backend "C:\msys64\work\rust\build\x86_64-pc-windows-gnu\stage1\lib\rustlib\x86_64-pc-windows-gnu\codegen-backends\rustc_codegen_llvm-llvm.dll": "The specified procedure could not be found. (os error 127)"

error: Could not compile core.
warning: build failed, waiting for other jobs to finish...
error: build failed
command did not execute successfully: "C:\msys64\work\rust\build\x86_64-pc-windows-gnu\stage0\bin\cargo.exe" "build" "--target" "x86_64-pc-windows-gnu" "-j" "4" "--release" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "C:\msys64\work\rust\src/libstd/Cargo.toml" "--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

@jonas-schievink jonas-schievink added A-codegen Area: Code generation C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 5, 2019
@sailfish009
Copy link
Author

i found that, unlike stage0, in stage1 not copy following 3 files:

libgcc_s_seh-1.dll
libstdc++-6.dll
libwinpthread-1.dll

C:>dumpbin /dependents C:\msys64\work\rust\build\x86_64-pc-windows-gnu\st
age1\lib\rustlib\x86_64-pc-windows-gnu\codegen-backends\rustc_codegen_llvm-
llvm.dll
Microsoft (R) COFF/PE Dumper Version 14.22.27706.1
Copyright (C) Microsoft Corporation. All rights reserved.

Dump of file C:\msys64\work\rust\build\x86_64-pc-windows-gnu\stage1\lib\
rustlib\x86_64-pc-windows-gnu\codegen-backends\rustc_codegen_llvm-llvm.dll

File Type: DLL

Image has the following dependencies:

ADVAPI32.dll
KERNEL32.dll
msvcrt.dll
ole32.dll
SHELL32.dll
libgcc_s_seh-1.dll
libstdc++-6.dll
std-628b34239afd544d.dll
rustc_cratesio_shim-1286e1e1e25e9401.dll
rustc_data_structures-2fe798d50cc1988d.dll
arena-6a0e10874a3e95a7.dll
syntax_pos-7d77f4de5c784c3b.dll
rustc_errors-75e0d9f7a3216c59.dll
rustc_target-afb73b93701b273b.dll
syntax-1b86f5297a43462e.dll
rustc_fs_util-51440b05ae415ecd.dll
rustc-7f75934bde937904.dll
rustc_allocator-efb755307bc90225.dll
rustc_incremental-217d1250b4277d9a.dll
rustc_codegen_utils-df25ac251788eeee.dll
rustc_codegen_ssa-26e20ca0ffb36a8b.dll

Summary

    1000 .CRT
    2000 .bss
   75000 .data
    8000 .debug_abbrev
    1000 .debug_aranges
    3000 .debug_frame
   85000 .debug_info
   12000 .debug_line
   2B000 .debug_loc
    2000 .debug_ranges
    2000 .debug_str
  3EF000 .edata
   19000 .idata
   A5000 .pdata
  FC0000 .rdata
   39000 .reloc
   79000 .rustc
 2337000 .text
    1000 .tls
   E3000 .xdata

@YairHalberstadt
Copy link

YairHalberstadt commented Jun 11, 2019

@sailfish009
Copy link
Author

sailfish009 commented Jun 12, 2019

replace llvm with old / latest version in my private repo (which works fine 2019-5-18 in another computer), result same error.

@sailfish009
Copy link
Author

sailfish009 commented Jun 15, 2019

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-x86_64-gcc mingw-w64-x86_64-cmake
pacman -R mingw-w64-x86_64-gcc-libs
pacman -U /var/cache/pacman/pkg/mingw-w64-x86_64-gcc-libs-8.3.0-2-any.pkg.tar.xz
pacman -U /var/cache/pacman/pkg/mingw-w64-x86_64-gcc-8.3.0-2-any.pkg.tar.xz
pacman -U /var/cache/pacman/pkg/mingw-w64-x86_64-cmake-3.14.4-1-any.pkg.tar.xz

./x.py 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

@mati865
Copy link
Contributor

mati865 commented Jul 23, 2019

This issue is not fixed and shouldn't have been closed.

@Centril Centril reopened this Jul 23, 2019
@sailfish009
Copy link
Author

@mati865 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.

@mati865
Copy link
Contributor

mati865 commented Sep 1, 2019

Ntldd output:

$ ntldd /d/Projects/rust/build/x86_64-pc-windows-gnu/stage1/lib/rustlib/x86_64-pc-windows-gnu/codegen-backends/rustc_codegen_llvm-llvm.dll
        std-1bafbda090a28ede.dll => not found
        fmt_macros-b2c296fbc2d2182c.dll => not found
        rustc_driver-acfddf0893838c24.dll => not found
        ADVAPI32.dll => C:\WINDOWS\SYSTEM32\ADVAPI32.dll (0x000000000ab10000)
        KERNEL32.dll => C:\WINDOWS\SYSTEM32\KERNEL32.dll (0x000000000abb0000)
        msvcrt.dll => C:\WINDOWS\SYSTEM32\msvcrt.dll (0x000000000abb0000)
        ole32.dll => C:\WINDOWS\SYSTEM32\ole32.dll (0x000000000ab10000)
        SHELL32.dll => C:\WINDOWS\SYSTEM32\SHELL32.dll (0x000000000af70000)
        libgcc_s_seh-1.dll => D:\msys64\mingw64\bin\libgcc_s_seh-1.dll (0x0000000000080000)
        libstdc++-6.dll => D:\msys64\mingw64\bin\libstdc++-6.dll (0x000000000ab10000)

Missing libraries can be found inside /d/Projekty/rust/build/x86_64-pc-windows-gnu/stage1/bin so probably something weird happens to PATH during rustbuild.

Nightly doesn't depend on fmt_macros:

$ ntldd /c/Users/mateusz/.rustup/toolchains/nightly-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu/codegen-backends/rustc_codegen_llvm-llvm.dll
        std-542b4eb673c8859b.dll => not found
        rustc_driver-dc847589f2996fc8.dll => not found
        ADVAPI32.dll => C:\WINDOWS\SYSTEM32\ADVAPI32.dll (0x0000000006190000)
        libgcc_s_seh-1.dll => D:\msys64\mingw64\bin\libgcc_s_seh-1.dll (0x00000000001c0000)
        KERNEL32.dll => C:\WINDOWS\SYSTEM32\KERNEL32.dll (0x0000000006230000)
        msvcrt.dll => C:\WINDOWS\SYSTEM32\msvcrt.dll (0x0000000006230000)
        ole32.dll => C:\WINDOWS\SYSTEM32\ole32.dll (0x0000000006190000)
        SHELL32.dll => C:\WINDOWS\SYSTEM32\SHELL32.dll (0x00000000065f0000)
        libstdc++-6.dll => D:\msys64\mingw64\bin\libstdc++-6.dll (0x0000000006190000)

@guanqun
Copy link
Contributor

guanqun commented Sep 2, 2019

I had the same issue... and the mingw gcc version is 9.2.0

@sailfish009
Copy link
Author

you can install gcc 8.x from here.

@pnkfelix
Copy link
Member

triage: P-high, due to blockage of #63959, until someone can convince me otherwise.

@pnkfelix pnkfelix added the P-high High priority label Sep 12, 2019
@pnkfelix
Copy link
Member

triage: assigning to self for initial investigation.

@pnkfelix pnkfelix self-assigned this Sep 26, 2019
@sailfish009
Copy link
Author

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: x86_64-unknown-linux-gnu
release: 1.40.0-dev
LLVM version: 9.0

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-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=x86_64-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=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.2.1 20190909 (Ubuntu 9.2.1-8ubuntu1)

$ uname -a
Linux ubuntu 5.3.0-13-generic #14-Ubuntu SMP Tue Sep 24 02:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

@mati865
Copy link
Contributor

mati865 commented Oct 3, 2019

@sailfish009 it has never affected targets other than windows-gnu.

@pnkfelix pnkfelix changed the title couldn't load codegen backend couldn't load codegen backend on windows-gnu Oct 10, 2019
@CDirkx
Copy link
Contributor

CDirkx commented Oct 10, 2019

One downside of downgrading to gcc 8.3 and cmake 3.14 and building rust source is that I got errors messages similar to: gcc internal compiler error and cmake missing dll, 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.

@pnkfelix
Copy link
Member

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

@pnkfelix pnkfelix removed their assignment Oct 17, 2019
@Amanieu
Copy link
Member

Amanieu commented Oct 26, 2019

OK, so after a bit of debugging, here's what going on:

  • The DLLs in build/i686-pc-windows-gnu/stage0/bin are from an older version of MinGW. These come as part of the bootstrap package.
  • The DLLs in /mingw32/bin 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 libstdc++-6.dll.
  • PATH is used to search for DLLs but the way bootstrap set this up ends up with build/i686-pc-windows-gnu/stage0/bin having priority over /mingw32/bin.
  • The rustc 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 libstdc++-6.dll which is missing some needed symbols.

@Amanieu
Copy link
Member

Amanieu commented Oct 26, 2019

As a workaround, you can copy the newer MinGW dlls from /mingw32/bin into build/i686-pc-windows-gnu/stage0/bin.

tmandry added a commit to tmandry/rust that referenced this issue Nov 1, 2019
…lexcrichton

Statically link libstdc++ on windows-gnu

Fixes rust-lang#61561 by not shipping `libstdc++-6.dll` which can conflict with the GCC.
tmandry added a commit to tmandry/rust that referenced this issue Nov 1, 2019
…lexcrichton

Statically link libstdc++ on windows-gnu

Fixes rust-lang#61561 by not shipping `libstdc++-6.dll` which can conflict with the GCC.
@bors bors closed this as completed in d2185f6 Nov 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. O-windows-gnu Toolchain: GNU, Operating system: Windows P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants