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

Failed to run "cargo run" using MinGW-W64 with SJLJ exception handling models #91651

Closed
wh201906 opened this issue Dec 8, 2021 · 6 comments
Closed
Labels
O-windows-gnu Toolchain: GNU, Operating system: Windows

Comments

@wh201906
Copy link

wh201906 commented Dec 8, 2021

Hi there.
I use gcc version 8.1.0 (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) at first.
I failed to run "cargo run" in the instructions and got these errors.

PS E:\Documents\source\rust\hello> cargo run
   Compiling hello v0.1.0 (E:\Documents\source\rust\hello)
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:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.2gqdlf8f8gtgwb48.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.2pg8ttz0es2f6a3w.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.330p22tyija6tnq3.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.34xpm6ntgnkmw9i3.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.3dvcen0ak15jp1wb.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.atxoafg6m4hfagr.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.ax3z8lnuwmz4rkl.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.i0jk5y12xey3ltv.rcgu.o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.4wvnen60ldvov5rb.rcgu.o" "-L" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps" "-L" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,--start-group" "-Wl,-Bstatic" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-57e8ea4e1cfb36e3.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwind-d50ed3cb69dbfa89.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-db8fbc6e4b507d8c.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-2c2fe1d9eecdd835.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libaddr2line-8e620bb89415248d.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-50c1bebcf1938271.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-1df005efff689fb6.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_demangle-7bd71b39d5dd92f1.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-79c4ada05aad6e88.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-cfc3e2e8bead46d2.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-adc2f2a5afea326c.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcfg_if-d9c292e85ad6a944.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-fc23eff1f7c571db.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-2b42541821d9e283.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_core-10202bb8c6593b6a.rlib" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-0e8789dc8677c5cb.rlib" "-Wl,--end-group" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-b7726d063fa88be4.rlib" "-Wl,-Bdynamic" "-lkernel32" "-lws2_32" "-lbcrypt" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-o" "E:\\Documents\\source\\rust\\hello\\target\\debug\\deps\\hello-77f9d87c52a665da.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\xxxx\\.rustup\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: E:\Documents\source\rust\hello\target\debug\deps\hello-77f9d87c52a665da.34xpm6ntgnkmw9i3.rcgu.o: In function `core::ops::function::FnOnce::call_once':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops/function.rs:227: undefined reference to `_Unwind_Resume'
          E:\Documents\source\rust\hello\target\debug\deps\hello-77f9d87c52a665da.atxoafg6m4hfagr.rcgu.o: In function `std::sys_common::backtrace::__rust_begin_short_backtrace':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\sys_common/backtrace.rs:119: undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-57e8ea4e1cfb36e3.rlib(std-57e8ea4e1cfb36e3.std.0253c85e-cgu.0.rcgu.o): In function `alloc::collections::btree::mem::replace':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\collections\btree/mem.rs:35: undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-57e8ea4e1cfb36e3.rlib(std-57e8ea4e1cfb36e3.std.0253c85e-cgu.0.rcgu.o): In function `<std::backtrace::BytesOrWide as core::fmt::Debug>::fmt':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src/backtrace.rs:247: undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-57e8ea4e1cfb36e3.rlib(std-57e8ea4e1cfb36e3.std.0253c85e-cgu.0.rcgu.o): In function `core::ops::function::FnOnce::call_once':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops/function.rs:227: undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-57e8ea4e1cfb36e3.rlib(std-57e8ea4e1cfb36e3.std.0253c85e-cgu.0.rcgu.o):/rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src/backtrace.rs:485: more undefined references to `_Unwind_Resume' follow
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-d50ed3cb69dbfa89.rlib(panic_unwind-d50ed3cb69dbfa89.panic_unwind.9edbbfc2-cgu.0.rcgu.o): In function `panic_unwind::real_imp::panic':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\panic_unwind\src/gcc.rs:62: undefined reference to `_Unwind_RaiseException'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-d50ed3cb69dbfa89.rlib(panic_unwind-d50ed3cb69dbfa89.panic_unwind.9edbbfc2-cgu.0.rcgu.o): In function `rust_eh_personality':
          /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\panic_unwind\src/gcc.rs:273: undefined reference to `_GCC_specific_handler'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-db8fbc6e4b507d8c.rlib(object-db8fbc6e4b507d8c.object.f268efff-cgu.0.rcgu.o):object.f268efff-cg:(.text+0x1b4a): undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-db8fbc6e4b507d8c.rlib(object-db8fbc6e4b507d8c.object.f268efff-cgu.0.rcgu.o):object.f268efff-cg:(.text+0x25b7): undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-50c1bebcf1938271.rlib(gimli-50c1bebcf1938271.gimli.8148d4e3-cgu.0.rcgu.o):gimli.8148d4e3-cgu:(.text+0x73e): undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-50c1bebcf1938271.rlib(gimli-50c1bebcf1938271.gimli.8148d4e3-cgu.0.rcgu.o):gimli.8148d4e3-cgu:(.text+0x2b99): undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-50c1bebcf1938271.rlib(gimli-50c1bebcf1938271.gimli.8148d4e3-cgu.0.rcgu.o):gimli.8148d4e3-cgu:(.text+0x2c26): undefined reference to `_Unwind_Resume'
          C:\Users\xxxx\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-50c1bebcf1938271.rlib(gimli-50c1bebcf1938271.gimli.8148d4e3-cgu.0.rcgu.o):gimli.8148d4e3-cgu:(.text+0x2daf): more undefined references to `_Unwind_Resume' follow
          collect2.exe: error: ld returned 1 exit status

  = help: 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)

error: could not compile `hello` due to previous error

Then I found a page saying that I should use SEH rather than SJLJ.
After installing the SEH version of GCC(x86_64-8.1.0-posix-seh-rt_v6-rev0), the "cargo run" works fine.

PS E:\Documents\source\rust\hello> cargo run
   Compiling hello v0.1.0 (E:\Documents\source\rust\hello)
    Finished dev [unoptimized + debuginfo] target(s) in 0.99s
     Running `target\debug\hello.exe`
Hello, world!

Is this a bug?

@sanxiyn sanxiyn added the O-windows-gnu Toolchain: GNU, Operating system: Windows label Dec 16, 2021
@pnkfelix
Copy link
Member

pnkfelix commented Sep 7, 2022

is this the same issue as #53301 ?

@wh201906
Copy link
Author

wh201906 commented Sep 7, 2022

I don't know...

@mati865
Copy link
Contributor

mati865 commented Sep 27, 2022

Rust doesn't support SJLJ exception model for windows-gnu targets, I'm unaware of any plans to change it.

@wh201906
Copy link
Author

If the lack of support in SJLJ exception model is designed so and expected, should I close this issue?

@mati865
Copy link
Contributor

mati865 commented Sep 27, 2022

Dunno what the devs think but personally I don't think its useful to keep this open.

@wh201906
Copy link
Author

Yeah you are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-windows-gnu Toolchain: GNU, Operating system: Windows
Projects
None yet
Development

No branches or pull requests

4 participants