Skip to content

Linking a dylib/DLL is broken on windows #25891

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
alexchandel opened this issue May 29, 2015 · 1 comment
Closed

Linking a dylib/DLL is broken on windows #25891

alexchandel opened this issue May 29, 2015 · 1 comment

Comments

@alexchandel
Copy link

Attempting to link a crate as a "dylib" on windows, specifically the nightly i686-pc-windows-gnu, to produce a DLL results in a linker error if that crate uses array subscripting. For example, compiling with no options,

#![crate_type = "dylib"]
pub unsafe extern "system" fn foo() -> f64 {
    let x: [f64; 4] = [0.0, 1.0, 2.0, 3.0];
    x[2]
}

results in a linker error,

error: linking with `gcc` failed: exit code: 1
note: "gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--large-address-aware" "-shared-libgcc" "-L" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib" "alg.o" "-o" "alg.dll" "alg.metadata.o" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libstd-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libcollections-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\librustc_unicode-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\librand-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\liballoc-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\liblibc-11582ce5.rlib" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libcore-11582ce5.rlib" "-L" "C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib" "-L" "c:\Users\alex\Projects\XALG_Counter\.rust\bin\i686-pc-windows-gnu" "-L" "c:\Users\alex\Projects\XALG_Counter\bin\i686-pc-windows-gnu" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "ws2_32" "-l" "userenv" "-l" "advapi32" "-shared" "-l" "compiler-rt"
note: C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libcore-11582ce5.rlib(core-11582ce5.o):(.text+0x7fe4): undefined reference to `rust_begin_unwind'
C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libcore-11582ce5.rlib(core-11582ce5.o):(.eh_frame+0x9a67): undefined reference to `rust_eh_personality'
ld: C:\tools\rust32\bin\rustlib\i686-pc-windows-gnu\lib\libcore-11582ce5.rlib(core-11582ce5.o): bad reloc address 0x9a67 in section `.eh_frame'

error: aborting due to previous error

Passing the -C linker=C:/tools/rust32/bin/rustlib/i686-pc-windows-gnu/bin/gcc.exe, doesn't help, nor does compiling for x86_64, nor with the flag -C linker="C:/tools/rust/bin/rustlib/x86_64-pc-windows-gnu/bin/gcc.exe".

@alexchandel
Copy link
Author

Closing as dupe of #18807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant