Skip to content

Linking fails with rusqlite and gnu #109623

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

Closed
AndreKR opened this issue Mar 26, 2023 · 5 comments
Closed

Linking fails with rusqlite and gnu #109623

AndreKR opened this issue Mar 26, 2023 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@AndreKR
Copy link

AndreKR commented Mar 26, 2023

I have a new computer and I freshly installed Rust and I'm trying to build a project that built alright on my old computer.

For this issue I have reduced it to simply:

[package]
name = "rust-issue"
version = "0.1.0"
edition = "2021"
[dependencies]
rusqlite = { version = "0.28.0", features = ["bundled"] }
use std::error::Error;
use rusqlite::Connection;

fn main() -> Result<(), Box<dyn Error>> {
	Connection::open("foo")?;
	Ok(())
}

I'm building with

nightly-x86_64-pc-windows-gnu (default)
rustc 1.70.0-nightly (0c61c7a97 2023-03-25)

Without any additional software installed, the build fails with

error: failed to run custom build command for `libsqlite3-sys v0.25.2`
error occurred: Failed to find tool. Is `gcc.exe` installed? (see https://github.com/rust-lang/cc-rs#compile-time-requirements for help)

This is expected. (Well, what I'd really expect is that rustup installed the darn toolchain, but that's a discussion for another time.)

I don't remember which gcc I had on my old computer, probably from MSYS2 or TDM-GCC. By the way, that link isn't very helpful. On https://github.com/rust-lang/cc-rs#compile-time-requirements it says (emphasis mine):

We recommend the MinGW-w64 distribution, which is using the Win-builds installation system. You may also acquire it via MSYS2, as explained here.

This makes it appear as if you could just get MinGW-w64 "normally" or via MSYS2, but as I understand there is no "normal" way, MSYS2 is already the most common way to acquire MinGW-w64.

So anyway, I installed MSYS2 and then ran pacman -S base-devel gcc cmake. I also added <msys installation dir>\usr\bin to my PATH.

I'm getting:

   Compiling rust-issue v0.1.0 (C:\dev\projects\rust-issue)
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\andre\\AppData\\Local\\Temp\\rustcn2rMge\\symbols.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.1dxt61eaz4l27wfx.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.1stlkemhfb7sfqu2.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.22tvrnjz3s1g3xz2.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.24t5fz1nu7b7mfzc.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.25m54u5trj0u2rcg.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2fseeujgpn26bvkw.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2gqzmhoqedn8tdgz.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2lspe89zdtdu5ge1.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2njrtzjk4n56x7ot.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2wvzcnvdkfbgvck1.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2xmvmmspas2jy10r.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.2zndxe9gtx5jzjaj.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.33b5jv8veawqz3mm.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.3eoj2vw0jiyja7l1.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.3jry15kf4a3fdryq.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.4itrliv9xntok2qu.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.4pwb71dr5n3sjte1.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.4vbji5wr33b2p4xg.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.53a2j7bnwjxe1sqo.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.55vnof4315av7yea.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.7m0of9u91b5bfwz.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.99vkwym12gkbh56.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.fyvdj9wwhcj0uai.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.gk5oyiv09gaf1wz.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.n6bwij5ye4niuk6.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.u4r5tiq7vigd7hp.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.wf6h6eq87x8xu9j.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.wiw7yj3xj7kqq7a.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.xzlnbprqgd4z8xk.rcgu.o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.47rr28xmaencr7h8.rcgu.o" "-L" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps" "-L" "c:\\dev\\projects\\rust-issue\\target\\debug\\build\\libsqlite3-sys-c4c2c6d1f1266c04\\out" "-L" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\librusqlite-99b46dde7d23ccf6.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libbitflags-6c4d2d0be17bba01.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libsmallvec-639962cd1eeb9ad0.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libfallible_streaming_iterator-476c977ea9be6ed4.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libfallible_iterator-8c2bf4becf96a207.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libhashlink-b0df5a6969b91815.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libhashbrown-a39faff6d51792aa.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libahash-79597c5c0d21a700.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libgetrandom-1c2c8bd7d1f26ba4.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libcfg_if-6d5ed73bca79f013.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libonce_cell-1028a6aa46242399.rlib" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\liblibsqlite3_sys-b59322e04617e62c.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-f664fef7ac104778.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-8a5cadc8acbd190a.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-fa2fb6dfd7200219.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-8ecee2bca8ae69e4.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-ecb83fb0e3e0509e.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-692ab15d0a28a6f4.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-d86464621b913d43.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-6643d1d5273eb0ff.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-70303bc7d83795c3.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-de9865f00f7ce604.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-fd3b505b70e9d5d9.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-a79f1b9668dabd72.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-582363e1e452755c.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-ab4594ee502ad13c.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-be319144660c2a69.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-de7daba68b820654.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-043dcb5cef4e65e2.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-0e5c5feeef4bd6da.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-5b1160acc1f68c4c.rlib" "-Wl,-Bdynamic" "-lbcrypt" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lntdll" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nostartfiles" "-L" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained" "-o" "c:\\dev\\projects\\rust-issue\\target\\debug\\deps\\rust_issue-aea5771d49566a3a.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: Warning: .drectve `-exclude-symbols:"_ZN4core4cell16RefCell$LT$T$GT$3new17h4418ff2aac74c385E" ' unrecognized
          Warning: corrupt .drectve at end of def file
          Warning: .drectve `-exclude-symbols:_ZN4core5error5Error11description17h25aded071e0a2ff3E ' unrecognized
          Warning: .drectve `-exclude-symbols:_ZN4core5error5Error5cause17h01459c8d20c3630bE ' unrecognized
          Warning: .drectve `-exclude-symbols:_ZN4core5error5Error7provide17had4fc66738f77b27E ' unrecognized
          Warning: corrupt .drectve at end of def file
          Warning: .drectve `-exclude-symbols:_ZN3std2rt10lang_start17h53bf1b6d3a9f10fbE ' unrecognized
          Warning: corrupt .drectve at end of def file
[a whole lot more of these]
          Warning: corrupt .drectve at end of def file
          Warning: corrupt .drectve at end of def file
          ld: C:\dev\projects\rust-issue\target\debug\deps\liblibsqlite3_sys-b59322e04617e62c.rlib(sqlite3.o): in function `winGetTempname':
          /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:48380: undefined reference to `cygwin_conv_path'
          ld: /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:48386: undefined reference to `__errno'
          ld: C:\dev\projects\rust-issue\target\debug\deps\liblibsqlite3_sys-b59322e04617e62c.rlib(sqlite3.o): in function `winFullPathname':
          /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:49153: undefined reference to `cygwin_conv_path'
          ld: /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:49157: undefined reference to `__errno'
          ld: /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:49175: undefined reference to `cygwin_conv_path'
          ld: /c/dev/tools/Rust/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libsqlite3-sys-0.25.2/sqlite3/sqlite3.c:49179: undefined reference to `__errno'
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)

Googling some of these errors suggests this might mean a mismatch between GNU and MSVC toolchains, but I'm using all GNU, I don't have Visual Studio nor the VS build tools installed.

So I'm a bit lost. I then installed TDM-GCC instead of the MSYS2 one.

With this I'm getting:

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\andre\\AppData\\Local\\Temp\\rustccyH9Ry\\symbols.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.0.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.1.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.10.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.11.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.12.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.2.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.3.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.4.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.5.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.6.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.7.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.8.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.build_script_build.7609c34c-cgu.9.rcgu.o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.zycrj3dkispq3y1.rcgu.o" "-L" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps" "-L" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\dev\\projects\\rust-issue\\target\\debug\\deps\\libversion_check-038583716d3946ad.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-f664fef7ac104778.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-8a5cadc8acbd190a.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-fa2fb6dfd7200219.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-8ecee2bca8ae69e4.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-ecb83fb0e3e0509e.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-692ab15d0a28a6f4.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-d86464621b913d43.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-6643d1d5273eb0ff.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-70303bc7d83795c3.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libminiz_oxide-de9865f00f7ce604.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libadler-fd3b505b70e9d5d9.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-a79f1b9668dabd72.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-582363e1e452755c.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-ab4594ee502ad13c.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-be319144660c2a69.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-de7daba68b820654.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-043dcb5cef4e65e2.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-0e5c5feeef4bd6da.rlib" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-5b1160acc1f68c4c.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lntdll" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "C:\\dev\\projects\\rust-issue\\target\\debug\\build\\ahash-f395dd85a55a5a73\\build_script_build-f395dd85a55a5a73.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\dev\\tools\\Rust\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:/dev/tools/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lgcc_eh
          collect2.exe: error: ld returned 1 exit status
@AndreKR AndreKR added the C-bug Category: This is a bug. label Mar 26, 2023
@AndreKR
Copy link
Author

AndreKR commented Mar 27, 2023

Sooo, I found out what was different. Apparently on my old computer I installed gcc neither through MSYS2 nor through TDM-GCC.

I installed it using mingw-w64-install.exe from here (scroll down to MinGW-W64 Online Installer). This installer however doesn't work anymore but there's a workaround.

So effectively now I installed MinGW-w64 from here and with this version the build works. 🎉

I noticed that in the URL of the working installation pack it says mingw-builds and on the download page there's also a Mingw-builds section, which leads to this GitHub repo where there's another installer, which might work as well - I haven't tried.

I'll leave this issue open so you guys can decide if you want to leave things as they are or improve the documentation or (my preferred solution) bundle MinGW-w64 when installing Rust via rustup.

@Noratrieb Noratrieb added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 5, 2023
@jyn514 jyn514 added A-linkage Area: linking into static, shared libraries and binaries A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools labels Apr 7, 2023
@rbtcollins
Copy link
Contributor

So there are two different things going on here.

The errors you're getting from the gnu linker are to do with the way the gcc compiler has been built, I think.

libgcc_eh is the gcc exception handling library, and assuming your LDPATH etc are all correct for that to be missing suggests it doesn't exist. So the differently sourced toolchains you have are not equivalent.

On the rustup side of things, we basically trust that users know what they are doing if they are using a GNU toolchain: rustup is a rust package manager, not a manager of things that aren't part of the rust toolchain itself. Concretely, we include llvm, because its a rust package, but we don't include ld, platform C headers and other such things.

I don't think this is a principled position: we could change it, but we'd need substantial effort from volunteers to build and maintain such a capability: every different distribution system would need to be autodetected and used appropriate, which I suspect is at minimum dozens of permutations and lots of room for bugs[1]. Today the rustup team is very small, and its not clear that its the best use of Rust volunteer time to steer them at making rustup do more, rather than at making rustc better.

1: yes, rustup does auto install the msvc toolchain OS dependencies on windows; this is a bit of a special case, as there is one and only one right answer for the msvc toolchain.

@mati865
Copy link
Contributor

mati865 commented Apr 11, 2023

https://github.com/rust-lang/rust#mingw explains that you should install mingw-w64-x86_64-gcc (for 64 bits) and use mingw64_shell.bat shell (or add /mingw64/bin to PATH giving probably the same outcome).

I think TDM-GCC is unsupported because of the hacks they apply atop of GCC exceptions libraries.

@AndreKR
Copy link
Author

AndreKR commented Apr 11, 2023

https://github.com/rust-lang/rust#mingw explains that you should install mingw-w64-x86_64-gcc

Oh wow, indeed I missed that part. I will try it out because MSYS2 still feels more "normal" than some obscure installer off sourceforge.

@Dylan-DPC
Copy link
Member

Closing this as it was an issue they were having rather than any action to be done

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools A-linkage Area: linking into static, shared libraries and binaries C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants