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

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

Open
4 of 11 tasks
estk opened this issue Feb 7, 2024 · 5 comments
Open
4 of 11 tasks

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

estk opened this issue Feb 7, 2024 · 5 comments
Labels
A-windows Area: windows targets

Comments

@estk
Copy link

estk commented Feb 7, 2024

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
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • 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: rust-lang/rust#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

@Emilgardis Emilgardis added the A-windows Area: windows targets label Feb 8, 2024
@Emilgardis
Copy link
Member

Emilgardis commented Feb 8, 2024

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
Copy link
Member

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

@estk
Copy link
Author

estk commented Feb 8, 2024

@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...

@Emilgardis
Copy link
Member

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

@secana
Copy link

secana commented Mar 5, 2025

I ran into the same issue, but with macOS as the underlying system.

Command I ran: cross build --target x86_64-pc-windows-msvc

# Cross.toml

[target.x86_64-pc-windows-msvc]
image = "ghcr.io/cross-rs/x86_64-pc-windows-msvc-cross:local"
pre-build = [
    "dpkg --add-architecture $CROSS_DEB_ARCH", 
    "apt-get update && apt-get --assume-yes install libssl-dev:$CROSS_DEB_ARCH",
    "ln -s /opt/msvc/vc/tools/msvc/14.43.34808/include /opt/msvc/vc/include",
]

[target.x86_64-pc-windows-msvc.env]
passthrough = [
    # Needed by one dependency to find the required header files
    "CROSS_INCLUDE_DIR=/opt/msvc/kits/10/include/10.0.22621.0/ucrt"
]
error: linking with `link.exe` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/opt/msvc/bin/x64:/usr/local/sbin:/usr/local/bin:/usr
/sbin:/usr/bin:/sbin:/bin:/Users/user/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" VSLANG="1033" "link.exe" "/NOLOGO" "/tmp/rustcOmMM8m/symbols.o" "<257 object files omitted
>" "/target/x86_64-pc-windows-msvc/debug/deps/{libinfer-6ed8afa152bcf8d5.rlib,libcfb-9ce7e58d034f0720.rlib,libusage-66dd0f3694dc7933.rlib,libserde_with-a3bd9e85ac1612f0.rlib,libnotify-dccec0099bd
761c0.rlib,libfiletime-68809e8049d5008d.rlib,libnotify_types-ce297fb1d519bbc7.rlib,libcross_authenticode-17564f4ab43d6773.rlib,libobject-bf3c268dc4518907.rlib,libruzstd-d86d15e7b500cd62.rlib,libt
wox_hash-ba2e19d16096f03c.rlib,libflate2-820da1df0dfcae6a.rlib,libminiz_oxide-4485f6f8bd38bec7.rlib,libadler2-3e63d1737e69f244.rlib,libcrc32fast-88158aa6a6e33ea5.rlib,libsha1-27e9e8f8079db749.rli
b,libcms-5bd1de40104b97fa.rlib,libx509_cert-cfd0483bd1ed060c.rlib,libspki-7be930870dff19c1.rlib,libder-d9411a3d561c83b8.rlib,libflagset-5d2c5d86459d26ef.rlib,libpem_rfc7468-f2bd52279539896e.rlib,
libbase64ct-a72d9953368f7a77.rlib,libconst_oid-2398d960790bc375.rlib,libcross_xdg-c541130568907fdc.rlib,libconfig-4bda9a70b2962360.rlib,libpathdiff-cda7525690e362ae.rlib,libjson5-aadc4135defafa3b
.rlib,libpest-ce8f4c1ba06f41ac.rlib,libucd_trie-e1929fb30d84628e.rlib,libron-cc118bdc7da2da27.rlib,libbitflags-16d93d2f69e86157.rlib,libbase64-8714c7fd79e31eef.rlib,libtoml-71052d79f0fe2047.rlib,
libtoml_edit-ee4fe051878b4c2a.rlib,libserde_spanned-cb2572be913aa3a1.rlib,libtoml_datetime-e72c01f9af87f231.rlib,libwinnow-7880e5611c2a294b.rlib,libini-143214ca41baa421.rlib,libtrim_in_place-f63a
b8709f51da07.rlib,libordered_multimap-78a397e08813e66a.rlib,libdlv_list-08bfe07ad4ad995d.rlib,libyaml_rust2-76408f5c14562b5d.rlib,libarraydeque-ce08091bfa34ea4b.rlib,libhashlink-28f6355bab66d31e.
rlib,libhashbrown-d097fcff6935e040.rlib,libahash-2ad02935dda59e36.rlib,libconvert_case-7c1f0b6b47d44b74.rlib,libunicode_segmentation-6ef6eaa9e3015634.rlib,libfoo-8978f5f93ef7c8f2.rlib,libikaru
s_sys-3142a72048b7e270.rlib,libwalkdir-87bc4c23cdea27f6.rlib,libsame_file-5d7e240c4475244a.rlib,libwinapi_util-a30ba16170cdf55e.rlib,libanyhow-a16483e278d91abe.rlib,libnotify_rust-3b7f29fe8ca4424
5.rlib,libtauri_winrt_notification-f03d54961d167a6f.rlib,libwindows_version-1475ac158b8f577e.rlib,libquick_xml-ce01495d5586d1db.rlib,libwindows-26923b71ad6f49a8.rlib,libwindows_core-9fb50d1bbb9ec
774.rlib,libwindows_result-cec64018a74279c0.rlib,libvaas-572c6f533f5330b8.rlib,libwebsockets-538d75a36c5dcf16.rlib,libbase64-96d26a9467c2d577.rlib,libflume-1462351c9358f70b.rlib,libpin_project-ac
a403a45f3cb951.rlib,libsha1-891e1c78583e2b04.rlib,libopaque_debug-7d9e329e02264ef8.rlib,libblock_buffer-ae2c4b31e5f7e8bc.rlib,libdigest-c87c334ba5b56eff.rlib,librand-1e4a0cdc931eace5.rlib,librand
_chacha-0f78772041593c18.rlib,libppv_lite86-8567f105c2345ea6.rlib,libzerocopy-2e3343207d0d2c10.rlib,libbyteorder-2589f6a6768a8036.rlib,librand_core-8925dedeac8480ee.rlib,libgetrandom-2d099dda58ee
f40d.rlib,libreqwest-107fcf5783aff196.rlib,libwindows_registry-8ff03de12dd7a0ed.rlib,libwindows_strings-c324d5b507ac5916.rlib,libwindows_result-db3baccb754a3e02.rlib,libbase64-a6a90567ffe3727a.rl
ib,libipnet-a6c1891cc619ba74.rlib,libhyper_tls-fe8b3320b0c89996.rlib,libtokio_native_tls-2c8543740af0b564.rlib,libencoding_rs-1cae779a235ef74f.rlib,libmime_guess-65f5e7ca54f73bff.rlib,libunicase-
e907e7e00af899af.rlib,libmime-24cba2a741d2c5c9.rlib,libtower-8cd3c3cc6a0d7872.rlib,libsync_wrapper-4bb27a2a52b8aa31.rlib,libtower_layer-99085307ddd5aad5.rlib,libnative_tls-ab676bfd95bc2a6f.rlib,l
ibschannel-dd91ccfd23c53ae5.rlib,libhyper_util-196c8477752f842a.rlib,libtower_service-4bf735055852e3c3.rlib,libhyper-d20894834048b6c0.rlib,libwant-9f4ad7143f0f88cc.rlib,libtry_lock-68847a830ed00d
5e.rlib,libhttparse-e0653b8fda822824.rlib,libh2-5bc842a839d2ed33.rlib,libatomic_waker-f2adb7a92729cb62.rlib,libtokio_util-b536e017e2d96de8.rlib,libhttp_body_util-2436b0e0f3e38a3d.rlib,libhttp_bod
y-cf26f096f06db52d.rlib,libhttp-c36d0c383fb5b14e.rlib,libfnv-e71e685fc6368a2a.rlib,libmigration-d985f3a83266d023.rlib,libsea_orm_migration-9963ceee0b54d6f0.rlib,libsea_schema-1ad5b0f3610aa846.rli
b,libfutures-9bdc0f180be3c3c3.rlib,libsea_orm_cli-238904e133397d7a.rlib,libglob-ba6209a53e0670bf.rlib,libtracing_subscriber-0bde6fd1bb7cdd78.rlib,libtracing_serde-8c03c3bf9b1e768c.rlib,libsharded
_slab-a9256df409874552.rlib,liblazy_static-9d39e1421fe190b8.rlib,libmatchers-a15bfa7afa97a5d1.rlib,libregex_automata-e2b0bd972a7563bc.rlib,libregex_syntax-d4f7ecd0daced5e9.rlib,libregex-24fc0fb3f
3f79612.rlib,libregex_automata-6d9a364e07ef9785.rlib,libaho_corasick-83db7b6080238c39.rlib,libregex_syntax-eb34ca5ae5b7cbfa.rlib,libnu_ansi_term-87edb805d36799d3.rlib,liboverload-71c06da579837f5a
.rlib,libwinapi-5645d261107b4835.rlib,libthread_local-4d90aa5f86a31349.rlib,libtracing_log-12296a599d2ff1fa.rlib,libdotenvy-e6109e5e2ade3e81.rlib,libentity-e902cb842d47a075.rlib,libsea_orm-21cd88
eea238c26b.rlib,libouroboros-703f2d4e772bf7df.rlib,libstatic_assertions-8624aa0f9f84d279.rlib,libaliasable-7117a5d5943eec85.rlib,libasync_stream-99583c35ab21b7db.rlib,libthiserror-0e194d64a1189d7
5.rlib,libstrum-e81c93a14f75f215.rlib,libsea_query_binder-1d1c31d05db5f1dd.rlib,libsqlx-ed3f1b58e258c74e.rlib,libsqlx_sqlite-1239773c0a906def.rlib,libfutures_executor-25e9cee391168f4d.rlib,libflu
me-625b9073a3e0cac6.rlib,libnanorand-c4eb67d290925871.rlib,libspin-b6ad96c7bcb30746.rlib,libserde_urlencoded-bea9dbe5e526379e.rlib,libfutures_intrusive-2f18f9468c71176e.rlib,liblibsqlite3_sys-0b2
33d8ee5dd4af9.rlib,libatoi-d54773081bccfdeb.rlib,libsqlx_core-1ffd34882214d5ae.rlib,libwebpki_roots-15cff3abcf37d79d.rlib,librustls_pemfile-2457dd7d4e4e579d.rlib,libthiserror-9a46b3e32425e06e.rli
b,libindexmap-d15dce1f33a3a6c7.rlib,libsha2-f492c4e0bd37b13a.rlib,libcpufeatures-04f45f0719cb5a56.rlib,libdigest-f8c6778f7d9cf847.rlib,libblock_buffer-c8efeed3047727c4.rlib,libcrypto_common-fa6d6
aaaa00a45e9.rlib,libgeneric_array-7acd6606560ddb75.rlib,libtypenum-4f5167eb0171027a.rlib,librustls-4e03397938b7ff3d.rlib,libsubtle-53010bce089d1cb5.rlib,libwebpki-cec04f2c307c532a.rlib,libring-96
ef2cfc1db78bd8.rlib,libgetrandom-ccff2ae01cec6fa1.rlib,libuntrusted-f9eccc12f187bf08.rlib,libzeroize-a7e89b2eb6d26931.rlib,librustls_pki_types-69e6f80153a9cf50.rlib,libtokio-6a6cd70d7bb1d400.rlib
,libsocket2-7f1f5e83b7c343c4.rlib,libmio-156905fdf767fbdf.rlib,libwindows_sys-949ebdca5b52c9d2.rlib,libparking_lot-f8c1be7dc471173a.rlib,libparking_lot_core-36d6b8d6c28cc6a3.rlib,liblock_api-b4a4
ed9ca8b43ef4.rlib,libscopeguard-dfb4b9f6470db89c.rlib,libbytes-6837dc0bd8ff38d6.rlib,libhashlink-096b3e21ccc508a8.rlib,libhashbrown-b649274e8e6ba7e6.rlib,libfoldhash-e788407b5c415b20.rlib,libequi
valent-ea526e927d6bdfdd.rlib,liballocator_api2-fc0aaa5d464cc3af.rlib,libcrossbeam_queue-9c9440806ca9af66.rlib,libcrossbeam_utils-15beee5ad348e8dc.rlib,libeither-cc8dfeae7ca1662c.rlib,libevent_lis
tener-d185ea2452807142.rlib,libparking-fae2874f17bb6cc4.rlib,libtracing-f87bdabfea85342f.rlib,liblog-4fdef9eca12376c6.rlib,libvalue_bag-79360d588d4e97bf.rlib,libtracing_core-55bf9c18c2d16889.rlib
,libsea_query-02293fc59a4ee088.rlib,libordered_float-4607543662bb2880.rlib,libuuid-34f930a3599be878.rlib,libgetrandom-f3757bf261c10faf.rlib,libcfg_if-eef688fa4f7046e7.rlib,libbigdecimal-4d4bfea3f
866ef88.rlib,liblibm-99ff2bc27b19ce10.rlib,libnum_bigint-4e7795e457790f26.rlib,libnum_integer-029a774ffc793cb4.rlib,librust_decimal-485a62140fe34291.rlib,libarrayvec-0d3657691ac11b56.rlib,libtime
-bb47739bed32655c.rlib,libtime_core-ec0ea454c6546c63.rlib,libnum_conv-c1c15bce9a3cc268.rlib,libderanged-629ea83f5f0dcca8.rlib,libpowerfmt-d72b702f3cc898b4.rlib,libserde_json-32e8be54bbd8676c.rlib
,libitoa-431291101683a3b3.rlib,libryu-fd444af2d3d0a3a1.rlib,libfutures_util-c29e91fb7dfb06d3.rlib,libmemchr-0be8e037d2327e5e.rlib,libfutures_io-5e7b0d13f8f35a5d.rlib,libslab-61a1984a8943869d.rlib
,libfutures_channel-5c4e2cac9267d273.rlib,libpin_project_lite-22561180b02c676d.rlib,libfutures_sink-e25660ff66342745.rlib,libfutures_task-55896196354a0b67.rlib,libpin_utils-2d7edf7b28ab6bac.rlib,
libfutures_core-312ce230b68e4576.rlib,libderive_more-d294bebfa99792e2.rlib,libclap-a77228865ab72e84.rlib,libclap_builder-4e80d011acfb0f75.rlib,libstrsim-b28485eb9f59b232.rlib,libanstream-d326ba52
3f551f2a.rlib,libanstyle_query-a16cd790920be983.rlib,libis_terminal_polyfill-ddd6afaf1db447da.rlib,libanstyle_wincon-9e0daf680f31fe40.rlib,libonce_cell-e4ae4139a31dbb8b.rlib,libwindows_sys-731b11
d582eb8742.rlib,libwindows_targets-6c476f0c60ecd0d9.rlib,libcolorchoice-d8cdfc9d66936c5e.rlib,libanstyle_parse-f6b6962a9ecb992c.rlib,libutf8parse-f13b0fbe15210df3.rlib,libclap_lex-5be1f87910107ec
7.rlib,libanstyle-e1095b1de54a6e24.rlib,libchrono-851a5f8b9db7f449.rlib,libnum_traits-3e378c899ba3df3e.rlib,libwindows_link-28d2f4e520a0b9c5.rlib,liburl-06e292415fdf51fa.rlib,libidna-19d858681e54
e486.rlib,libidna_adapter-76b3e8490afa6dcc.rlib,libicu_normalizer-aa88fc3fe114e687.rlib,libicu_normalizer_data-b8b9f6ab79214527.rlib,libwrite16-169daf0bca954ad0.rlib,libutf8_iter-5d5b3adf92b1d9e4
.rlib,libutf16_iter-7c8693502b39552c.rlib,libsmallvec-5493f80a1623b09c.rlib,libicu_properties-2a06f11e8dc538e1.rlib,libicu_properties_data-a2c86b34384d7f8a.rlib,libicu_locid_transform-af82c51502a
de59a.rlib,libicu_locid_transform_data-5e0979f5ffcbe7cd.rlib,libicu_collections-37046e8135a1fa4e.rlib,libicu_provider-d39334b50dda25f3.rlib,libicu_locid-942f1c1e08d91117.rlib,liblitemap-8e661e92c
0809b27.rlib,libtinystr-426eadc1c6a1cb4b.rlib,libzerovec-827fc50c63f300d2.rlib,libwriteable-2c2e8fe0321802ca.rlib,libyoke-09f289a19759d901.rlib,libzerofrom-fea183817cb3e874.rlib,libstable_deref_t
rait-a3cc2f4075a1a882.rlib,libform_urlencoded-401d35e966e7a77e.rlib,libpercent_encoding-31d04f7be0a74973.rlib,libserde-52f877744fc47054.rlib}" "/Users/user/.rustup/toolchains/stable-x8
6_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-msvc/lib/{libstd-99a5467416e27682.rlib,libpanic_unwind-b2376f55ca9ba5db.rlib,libwindows_targets-e982c2634e026463.rlib,librustc_demangle-622607
d70f9500c2.rlib,libstd_detect-402c0b1e8e67cb33.rlib,libhashbrown-d36035ae19bb0c8b.rlib,librustc_std_workspace_alloc-cb12c14614b55d43.rlib,libunwind-8e666946f8f5db2b.rlib,libcfg_if-ac9947000bdc169
e.rlib,liballoc-4f54ad4ac4b0f4c5.rlib,librustc_std_workspace_core-ff8db640d177ed2a.rlib,libcore-745ff350a54e4299.rlib,libcompiler_builtins-b2f39c5f2779068f.rlib}" "/Users/user/.cargo/r
egistry/src/yyy.xxx.de-19c73f2e90f9e453/foo-sys-0.2.6/vendor/lib/T3_w64.lib" "/Users/user/.cargo/registry/src/yyy.xxx.de-19c73f2e90f9e453/foo-sys-0.2.6/vendor/lib/vdbupda
te_w64.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/index.crate
s.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0
.lib" "advapi32.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/in
dex.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windo
ws.0.52.0.lib" "gdi32.lib" "kernel32.lib" "msimg32.lib" "opengl32.lib" "winspool.lib" "bcrypt.lib" "advapi32.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/wind
ows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/stefan.hauso
tte/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib/windows.0.52.0.lib" "/Users/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x8
6_64_msvc-0.52.6/lib/windows.0.52.0.lib" "kernel32.lib" "kernel32.lib" "advapi32.lib" "ntdll.lib" "userenv.lib" "ws2_32.lib" "dbghelp.lib" "/defaultlib:msvcrt" "/NXCOMPAT" "/LIBPATH:/Users/stefan
.hausotte/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/windows_x86_64_msvc-0.52.6/lib" "/LIBPATH:/target/x86_64-pc-windows-msvc/debug/build/ring-42d26525fc0731b6/out" "/LIBPATH:/target/x8
6_64-pc-windows-msvc/debug/build/libsqlite3-sys-504fbe5ed1cc5297/out" "/LIBPATH:/Users/user/.cargo/registry/src/yyy.xxx.de-19c73f2e90f9e453/foo-sys-0.2.6/vendor/lib" "/LIBPATH:/
target/x86_64-pc-windows-msvc/debug/build/foo-sys-42224a9f61f74c3f/out" "/OUT:/target/x86_64-pc-windows-msvc/debug/deps/gdcli.exe" "/OPT:REF,NOICF" "/DEBUG" "/PDBALTPATH:%_PDB%"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: 0044:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
          0044:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
          0044:err:systray:initialize_systray Could not create tray window
          0024:err:environ:build_command_line command line too long (46957)

I hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-windows Area: windows targets
Projects
None yet
Development

No branches or pull requests

3 participants