cross icon indicating copy to clipboard operation
cross copied to clipboard

x86_64-pc-windows-msvc Link error with very large number of objects

Open estk opened this issue 1 year ago • 10 comments

Checklist

Describe your issue

Linking fails with a very large number of objects on x86_64-pc-windows-msvc.

What target(s) are you cross-compiling for?

other (specify in description)

Which operating system is the host (e.g computer cross is on) running?

  • [ ] macOS
  • [ ] Windows
  • [X] Linux / BSD
  • [ ] other OS (specify in description)

What architecture is the host?

  • [X] x86_64 / AMD64
  • [ ] arm32
  • [ ] arm64 (including Mac M1)

What container engine is cross using?

  • [X] docker
  • [ ] podman
  • [ ] other container engine (specify in description)

cross version

0.2.5

Example

cross build --release -p mypackage
...
 = note: 0048:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
          0048:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
          0048:err:systray:initialize_systray Could not create tray window
          0024:err:environ:build_command_line command line too long (38785)

Additional information / notes

I found this issue in rustc: https://github.com/rust-lang/rust/issues/41190, and it makes me wonder if the workaround implemented there is somehow not getting triggered in the cross docker container.

Note: that the msvc docker container was built unmodified from the cross-toolchain image

estk avatar Feb 07 '24 17:02 estk

~~are you sure you're actually using cross? We only support msvc via https://github.com/cross-rs/cross-toolchains, which you need to build yourself. Cross will output a warning if it fallbacks to not using a container~~

I should've read the last note in your report :)

Emilgardis avatar Feb 08 '24 20:02 Emilgardis

Can you show the entire build log with -v added to the cross invocation

Emilgardis avatar Feb 08 '24 20:02 Emilgardis

@Emilgardis unfortunately I cant post the log publicly. Can you tell me what you're looking for?

I can confirm that the link command is extremely long 38k chars sounds right.

If you look at the rust issue, their fix seemed trivial, however i am not familiar enough with how rust links to know if we can get in the middle of object generation and linking...

estk avatar Feb 08 '24 23:02 estk

I just wanted more context, but it's fine :) A way to reproduce this would be good though.

Do you see any "linker failed with exit code" message?

https://github.com/rust-lang/rust/blob/5d3d3479d774754856db2db3e439dfb88ef3c52f/compiler/rustc_codegen_ssa/src/back/link.rs#L1544-L1557

I suspect this is the root problem, the fallback is never invoked, and I think that's because WINE doesn't give us error code E2BIG (7)

I think a fix would have to be done in rustc here or we wrap wine and translate the error code

Emilgardis avatar Feb 09 '24 09:02 Emilgardis