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

Linking error with MSVC build #29479

Closed
eminence opened this issue Oct 30, 2015 · 5 comments
Closed

Linking error with MSVC build #29479

eminence opened this issue Oct 30, 2015 · 5 comments

Comments

@eminence
Copy link
Contributor

I think this is a duplicate #29126. But given that the 1.4 release notes says the MSVC ABI build is "supported and recommended for use", I expected this to work out-of-the-box, so I'm opening a new issue to raise visibility:

The Rust 1.4 stable MSVC builds (and the 1.5 beta MSVC builds) fail to link a trivial hello world. #29126 suggests a workaround (use -O -C lto), but I feel this shouldn't be needed.

d:\temp> which link
C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/BIN/amd64/link.exe
d:\temp>link /v
Microsoft (R) Incremental Linker Version 11.00.61030.0
Copyright (C) Microsoft Corporation.  All rights reserved.
d:\temp>"c:\Program Files\Rust stable 1.4\bin\rustc.exe" --verbose --version
rustc 1.4.0 (8ab8581f6 2015-10-27)
binary: rustc
commit-hash: 8ab8581f6921bc7a8e3fa4defffd2814372dcb15
commit-date: 2015-10-27
host: x86_64-pc-windows-msvc
release: 1.4.0
d:\temp\lxd\07>"c:\Program Files\Rust stable 1.4\bin\rustc.exe" a.rs
error: linking with `link.exe` failed: exit code: 1120
note: "C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\VC\\bin\\amd64\\link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-
windows-msvc\\lib" "a.0.o" "/OUT:a.exe" "/OPT:REF,ICF" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\libstd-1bf6e69c.rlib" "C:\\Program Files\\Rus
t stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcollections-1bf6e69c.rlib" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\librustc_unic
ode-1bf6e69c.rlib" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\librand-1bf6e69c.rlib" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-
pc-windows-msvc\\lib\\liballoc-1bf6e69c.rlib" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\liballoc_system-1bf6e69c.rlib" "C:\\Program Files\\Rus
t stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\liblibc-1bf6e69c.rlib" "C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib\\libcore-1bf6e69c.rli
b" "/LIBPATH:C:\\Program Files\\Rust stable 1.4\\bin\\rustlib\\x86_64-pc-windows-msvc\\lib" "/LIBPATH:d:\\temp\\lxd\\07\\.rust\\bin\\x86_64-pc-windows-msvc" "/LIBPATH:d:\\temp\\lxd
\\07\\bin\\x86_64-pc-windows-msvc" "ws2_32.lib" "userenv.lib" "advapi32.lib" "kernel32.lib" "shell32.lib" "msvcrt.lib" "compiler-rt.lib"
note: libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol roundf referenced in function _ZN3f323f325round20h8f2525d3eaa87862SuaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol truncf referenced in function _ZN3f323f325trunc20he71016f6e44e57224uaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fmaf referenced in function _ZN3f323f327mul_add20hef17c31d888d4c9f5vaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol exp2f referenced in function _ZN3f323f324exp220hd5ee6b6a6fc0ee8a9xaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol log2f referenced in function _ZN3f323f324log220h020f4d063c57f47a1yaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol nextafterf referenced in function _ZN3f323f3210next_after20h2438fb468b5751e1IAaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fmaxf referenced in function _ZN3f323f323max20h90ff195b4fe3c593YAaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fminf referenced in function _ZN3f323f323min20hfe343509f74c9e57eBaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fdimf referenced in function _ZN3f323f327abs_sub20hb79223d09f0823d4uBaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol cbrtf referenced in function _ZN3f323f324cbrt20h3171361ebb799750KBaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol expm1f referenced in function _ZN3f323f326exp_m120he6dbf034b47f16e9kEaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol log1pf referenced in function _ZN3f323f325ln_1p20h701548988972eea4wEaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol round referenced in function _ZN3f643f645round20h7bb75ef14fe93cd8tMaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol trunc referenced in function _ZN3f643f645trunc20h07d947abf6906940FMaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fma referenced in function _ZN3f643f647mul_add20hf37ac3ca20f21cfa0NaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol exp2 referenced in function _ZN3f643f644exp220h073b1c4944189dbauPaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol log2 referenced in function _ZN3f643f644log220h72c1ea29e5809cc07PaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol nextafter referenced in function _ZN3f643f6410next_after20h8463c6f368b480f6zRaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fmax referenced in function _ZN3f643f643max20hed4839452134d534PRaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fmin referenced in function _ZN3f643f643min20h4def0ee29aefc2485RaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol fdim referenced in function _ZN3f643f647abs_sub20hc7ea4637b880bbeblSaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol cbrt referenced in function _ZN3f643f644cbrt20h2dff7e6a75df2df9BSaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol expm1 referenced in function _ZN3f643f646exp_m120hdc6db078df5aa789HUaE
libstd-1bf6e69c.rlib(std-1bf6e69c.0.o) : error LNK2019: unresolved external symbol log1p referenced in function _ZN3f643f645ln_1p20h237a6107417db16aTUaE
a.exe : fatal error LNK1120: 24 unresolved externals

error: aborting due to previous error

I can reproduce this issue with Visual Studio 2012, Visual Studio 2010, and Visual Studio 2008.

Thanks!

@alexcrichton
Copy link
Member

Most testing of MSVC so far has happened with VS 2013/2015, so that's probably where this error is originating from. Thanks for the report, though! I'm curious what happened to these functions between VS 2012 and now...

@petrochenkov
Copy link
Contributor

I'm curious what happened to these functions between VS 2012 and now...

These are all C99 functions, VC++ didn't supported them before they became part of C++11
http://blogs.msdn.com/b/vcblog/archive/2013/07/19/c99-library-support-in-visual-studio-2013.aspx

@eminence
Copy link
Contributor Author

That makes sense. Perhaps it would be prudent to include a note in https://www.rust-lang.org/downloads.html#win-foot that VS 2013 is a minimum required version.

Unless you think the work involved to fix this in VS2012 is trivial, I'd be fine if this issue was closed as a documentation bug.

@alexcrichton
Copy link
Member

I'd also be totally on board with backcompat to VS2012 and prior if it's possible, but it looks like these functions just weren't provided, so it may not be so trivial.

I'll tag this as docs for now to ensure we document that VS 2013 is needed.

@alexchandel
Copy link

@alexcrichton Sadly we would need openlibm for backcompat to VS 2012. Although if we did use openlibm for math, that would give us backcompat all the way to VC6

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

4 participants