DanielKeep / cargo-script

Cargo script subcommand
Other
719 stars 37 forks source link

Cargo Install Failing on Windows MSVC #39

Closed ark- closed 6 years ago

ark- commented 7 years ago

Running cargo install on Rust 1.17,0 nightly.

Get the follwoing error:

error: linking with `link.exe` failed: exit code: 1120
  |
  = note: "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" "/LIBPATH:C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\lib\\amd64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.10240.0\\ucrt\\x64" "/LIBPATH:C:\\Program Files (x86)\\Windows Kits\\8.1\\lib\\winv6.3\\um\\x64" "/NOLOGO" "/NXCOMPAT" "/LIBPATH:C:\\Users\\Mark\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "C:\\Users\\Mark\\AppData\\Local\\Temp\\cargo-install.cmLJgLe0bggr\\release\\deps\\cargo_script-567f819a739f3787.0.o" "/OUT:C:\\Users\\Mark\\AppData\\Local\\Temp\\cargo-install.cmLJgLe0bggr\\release\\deps\\cargo_script-567f819a739f3787.exe" "/OPT:REF,ICF" "/DEBUG" "/LIBPATH:C:\\Users\\Mark\\AppData\\Local\\Temp\\cargo-install.cmLJgLe0bggr\\release\\deps" "/LIBPATH:C:\\Users\\Mark\\AppData\\Local\\Temp\\cargo-install.cmLJgLe0bggr\\release\\build\\hoedown-d145627f9c181af8\\out" "/LIBPATH:C:\\Users\\Mark\\.rustup\\toolchains\\nightly-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" "uuid.lib" "C:\\Users\\Mark\\AppData\\Local\\Temp\\rustc.ahQjd7f18UMo\\libhoedown-c50d084b9ceee5eb.rlib" "C:\\Users\\Mark\\AppData\\Local\\Temp\\rustc.ahQjd7f18UMo\\libcompiler_builtins-c92942f2c930f53c.rlib" "ole32.lib" "kernel32.lib" "advapi32.lib" "shell32.lib" "advapi32.lib" "ws2_32.lib" "userenv.lib" "shell32.lib" "msvcrt.lib"
  = note: cargo_script-567f819a739f3787.0.o : error LNK2019: unresolved external symbol __imp_FOLDERID_LocalAppData referenced in function _ZN12cargo_script8platform5inner17get_cache_dir_for17hf2aa87629ba6be63E
          C:\Users\Mark\AppData\Local\Temp\cargo-install.cmLJgLe0bggr\release\deps\cargo_script-567f819a739f3787.exe : fatal error LNK1120: 1 unresolved externals

It also fails to build on stable 1.15.0.

ehuss commented 7 years ago

As a hackish workaround, I removed the line #[link(name="uuid")] in platform.rs, and it seems to compile and run properly. I am not very familiar with Rust FFI, so I don't really understand.

ark- commented 7 years ago

Fixed it for me too, haven't had any time to look into why.

redhat008 commented 7 years ago

Fixed it for me too. Thanks!

DanielKeep commented 7 years ago

Fixed in 0ea2b12. Turns out the issue was that how rustc does linking on Windows changed in 1.15. The fun part was that "fixing" this broke cargo-script for rustc prior to 1.15. The solution ended up being conditional compilation and using both kinds of linking for different compilers.

pravic commented 7 years ago

The same for me.

rustc 1.18, VS 2015

Type1J commented 7 years ago

rustc 1.18 VS 2017 as well

rustc 1.18.0 (03fc9d622 2017-06-06)

DanielKeep commented 7 years ago

@Type1J: Just to confirm, this is happening with the new 0.2.0 release? I don't have VS 2017, and can't reproduce this problem with 2015.

artemshein commented 6 years ago

Fails on Windows 10 for me as well. Looks like hoedown crate can't be built with MSVS 14.

C:\>cargo install cargo-script
    Updating registry `https://github.com/rust-lang/crates.io-index`
  Installing cargo-script v0.2.7
   Compiling either v1.2.0
   Compiling gcc v0.3.54
   Compiling winapi-build v0.1.1
   Compiling bitflags v0.9.1
   Compiling regex-syntax v0.4.1
   Compiling utf8-ranges v1.0.0
   Compiling utf8-ranges v0.1.3
   Compiling libc v0.2.31
   Compiling semver v0.1.20
   Compiling vec_map v0.8.0
   Compiling winapi v0.2.8
   Compiling bitflags v0.5.0
   Compiling unicode-width v0.1.4
   Compiling void v1.0.2
   Compiling lazy_static v0.2.9
   Compiling rustc-serialize v0.3.24
   Compiling ansi_term v0.9.0
   Compiling strsim v0.6.0
   Compiling open v1.2.1
   Compiling regex-syntax v0.3.9
   Compiling log v0.3.8
   Compiling itertools v0.5.10
   Compiling rand v0.3.16
   Compiling memchr v1.0.1
   Compiling memchr v0.1.11
   Compiling ktmw32-sys v0.1.0
   Compiling advapi32-sys v0.2.0
   Compiling ole32-sys v0.2.0
   Compiling shell32-sys v0.1.1
   Compiling kernel32-sys v0.2.2
   Compiling uuid-sys v0.1.2
   Compiling unreachable v1.0.0
   Compiling rustc_version v0.1.7
   Compiling aho-corasick v0.6.3
   Compiling aho-corasick v0.5.3
   Compiling chan v0.1.19
   Compiling thread_local v0.3.4
   Compiling cargo-script v0.2.7
   Compiling hoedown v6.0.0
   Compiling toml v0.2.1
   Compiling shaman v0.1.0
error: failed to run custom build command for `hoedown v6.0.0`
process didn't exit successfully: `C:\Users\ARTEM~1.SHE\AppData\Local\Temp\cargo-install.TseCO48ojILJ\release\build\hoedown-74e5fbed0b1e664b\build-script-build` (exit code: 101)
--- stdout
TARGET = Some("x86_64-pc-windows-msvc")
OPT_LEVEL = Some("3")
TARGET = Some("x86_64-pc-windows-msvc")
HOST = Some("x86_64-pc-windows-msvc")
TARGET = Some("x86_64-pc-windows-msvc")
TARGET = Some("x86_64-pc-windows-msvc")
HOST = Some("x86_64-pc-windows-msvc")
CC_x86_64-pc-windows-msvc = None
CC_x86_64_pc_windows_msvc = None
HOST_CC = None
CC = Some("\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe\"")
TARGET = Some("x86_64-pc-windows-msvc")
HOST = Some("x86_64-pc-windows-msvc")
CFLAGS_x86_64-pc-windows-msvc = None
CFLAGS_x86_64_pc_windows_msvc = None
HOST_CFLAGS = None
CFLAGS = None
DEBUG = Some("false")
running: "\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe\"" "/nologo" "/MD" "/O2" "/W4" "/FoC:\\Users\\ARTEM~1.SHE\\AppData\\Local\\Temp\\cargo-install.TseCO48ojILJ\\release\\build\\hoedown-57905814e72df0cf\\out\\libhoedown/src\\autolink.o" "/c" "libhoedown/src/autolink.c"

--- stderr
thread 'main' panicked at '

Internal error occurred: Command "\"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\cl.exe\"" "/nologo" "/MD" "/O2" "/W4" "/FoC:\\Users\\ARTEM~1.SHE\\AppData\\Local\\Temp\\cargo-install.TseCO48ojILJ\\release\\build\\hoedown-57905814e72df0cf\\out\\libhoedown/src\\autolink.o" "/c" "libhoedown/src/autolink.c" with args "cl.exe\"" failed to start.

', Users\artem.shein\.cargo\registry\src\github.com-1ecc6299db9ec823\gcc-0.3.54\src\lib.rs:1670:4
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-script v0.2.7`, intermediate artifacts can be found at `C:\Users\ARTEM~1.SHE\AppData\Local\Temp\cargo-install.TseCO48ojILJ`

Caused by:
  build failed
C:\>rustc -V
rustc 1.20.0 (f3d6973f4 2017-08-27)

C:\>cargo -V
cargo 0.21.0 (5b4b8b2ae 2017-08-12)
DanielKeep commented 6 years ago

@artemshein: That looks like an unrelated issue. This issue is about linking failing right at the end. Your error looks like the compiler path is being incorrectly quoted, and the build script is somehow treating the entire compilation line as a single argument (i.e. it reads like it's looking for a program called "(entire command line)", which obviously doesn't exist).

It builds fine for me, although I don't have VS 14, or Windows 10. Perhaps there's a bad interaction between some combination of gcc 0.3.45 (released in the last month), VS 14, and possibly Windows 10.

Either way, this is hoedown failing to build, not cargo-script, so it's technically not my problem. :P Given the simplicity of hoedown's build script, I'd be inclined to pin the blame on the gcc crate.


As for this issue, I'm going to close it since I still can't reproduce the original problem, and I suspect it's been fixed, but haven't been able to get confirmation. I'll reopen if someone confirms that the linking issue still exists in the latest version.

ark- commented 6 years ago

Works for me on nightly 1.21.0 now. Thanks very much.