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

Split the /opt:ref,icf arguments to i686-pc-windows-msvc linker #29126

Closed
alexchandel opened this Issue Oct 17, 2015 · 14 comments

Comments

Projects
None yet
6 participants
@alexchandel
Copy link

alexchandel commented Oct 17, 2015

Currently rustc passes /opt:ref,icf to the linker for the i686-pc-windows-msvc target, even when -C opt-level=0 is explicitly passed. LLD's link.exe flavor doesn't support comma-separated arguments, and would require /opt:ref /opt:icf. rustc should pass these separately.

Moreover, rustc needs provide a way to stop them from being passed at all, as I explicitly specified zero optimiations, and didn't pass -C lto.

@alexchandel alexchandel referenced this issue Oct 18, 2015

Open

Rust, Windows, and MSVC #1061

18 of 47 tasks complete
@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Oct 18, 2015

Is there an issue for LLD's inability to handle comma-separated arguments in LLVM's bug tracker yet?

@alexchandel

This comment has been minimized.

Copy link
Author

alexchandel commented Oct 18, 2015

There is, https://llvm.org/bugs/show_bug.cgi?id=25228. Apparently commas are sparsely documented.

@luqmana

This comment has been minimized.

Copy link
Member

luqmana commented Oct 19, 2015

Fix for lld accepting comma-separated arguments committed upstream: r250728.

@alexchandel

This comment has been minimized.

Copy link
Author

alexchandel commented Oct 20, 2015

@retep998 As of that fix, assuming lld is installed and the link.exe -> lld symlink exists, and the Win10 SDK libraries and VC6 libraries exist at i686-pc-windows-msvc-w10/lib and $HOME/i686-pc-windows-msvc-vc6/lib, then the following: LIB="$HOME/i686-pc-windows-msvc-w10/lib;$HOME/i686-pc-windows-msvc-vc6/lib" rustc --target i686-pc-windows-msvc -O -C lto test.rs produces a working Windows executable on OS X x86_64. However, compiling with optimizations still misses symbols:

note: libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _roundf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _truncf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fmaf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _exp2f
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _log2f
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _nextafterf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fmaxf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fminf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fdimf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _cbrtf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: __hypotf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _expm1f
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _log1pf
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _round
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _trunc
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fma
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _exp2
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _log2
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _nextafter
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fmax
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fmin
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _fdim
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _cbrt
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _expm1
libstd-10cbabc2.rlib(std-10cbabc2.0.o): undefined symbol: _log1p
Link failed

Just closing.

@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Oct 20, 2015

@alexchandel That looks like you're simply forgetting to link in msvcrt.

@alexchandel

This comment has been minimized.

Copy link
Author

alexchandel commented Oct 21, 2015

@retep998 Except these are only math functions. Clearly msvcrt's entry point is present, as are the memory functions. More importantly I'm not calling the linker: rustc is. The link arguments is uses are "link.exe" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:/usr/local/lib/rustlib/i686-pc-windows-msvc/lib" "test.0.o" "/OUT:test.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:/usr/local/lib/rustlib/i686-pc-windows-msvc/lib" "/LIBPATH:/Users/alex/Desktop/.rust/lib/i686-pc-windows-msvc" "/LIBPATH:/Users/alex/Desktop/lib/i686-pc-windows-msvc" "ws2_32.lib" "userenv.lib" "advapi32.lib" "kernel32.lib" "shell32.lib" "msvcrt.lib" "compiler-rt.lib".

Also, this only happens when -O -C lto are not passed.

@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Oct 21, 2015

@alexchandel Are you still using the old VC6 msvcrt? It might not have those specific symbols.

@alexchandel

This comment has been minimized.

Copy link
Author

alexchandel commented Oct 21, 2015

@retep998 That is probably it. It's possible that nextafter is only supported post-VC2010, which is frightening. This lingering issue is a reason to leave msvcrt's math functions for openlibm's though.

Also, it would be nice to have just i686-pc-windows-msvc-w10/lib, and not LIB="$HOME/i686-pc-windows-msvc-w10/lib;$HOME/i686-pc-windows-msvc-ucrt10/lib;$HOME/i686-pc-windows-msvc-vc14/lib" when trying to compile with a newer msvcrt.

@9prady9

This comment has been minimized.

Copy link

9prady9 commented Nov 25, 2015

Is this issue fixed in nightly(1.6) or beta(1.5) ? Is there any temporary work around for this with 1.4 stable release ?

@alexchandel

This comment has been minimized.

Copy link
Author

alexchandel commented Dec 1, 2015

@9prady9 rustc still doesn't split the arguments, but LLD's head can handle them now. However, we are still relying on an undocumented feature.

The other tangential issue discussed still exists, in that Rust's standard library isn't compatible with VC6's msvcrt, but requires VS 2013's. That could be resolved by rolling our own libm, which also solves many other issues, as proposed in rust-lang/rfcs#711.

@retep998

This comment has been minimized.

Copy link
Member

retep998 commented Dec 1, 2015

@alexchandel It's not an undocumented feature. The documentation makes use of flags with commas in several places. It just doesn't have any documentation specifically pointing out that you can use commas (or at least I couldn't find any).

@9prady9

This comment has been minimized.

Copy link

9prady9 commented Dec 1, 2015

@alexchandel Thank you for clarifying.

@brson

This comment has been minimized.

Copy link
Contributor

brson commented May 4, 2017

Is this fixed upstream yet? Can we close? cc @retep998

@brson brson added the P-low label May 4, 2017

@retep998

This comment has been minimized.

Copy link
Member

retep998 commented May 4, 2017

Yes, LLD fixed this.

@retep998 retep998 closed this May 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.