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

Improve target version reliability #2412

Merged
merged 7 commits into from
Mar 31, 2023
Merged

Improve target version reliability #2412

merged 7 commits into from
Mar 31, 2023

Conversation

kennykerr
Copy link
Collaborator

Provides a major update to all crates to deal with the windows-targets versioning issue described here: #2410 (comment)

  • The windows-targets crate now contains version-specific lib file names ensuring semver compatibility.

  • The link macro was previously defined in both the windows and windows-sys crates and thus inaccessible to the windows-bindgen's standalone code generation. It has been consolidated into the windows-targets crate shared by all. This ensures correct lib versioning is handled automatically by the windows-targets crate and everyone can now enjoy optional raw-dylib support.

  • A workaround is provided to merge the metadata from the previous release to ensure the new libs are additive only until v46 yanked some functions - intentional? win32metadata#1496 is fixed.

Once this is merged, I plan to yank the 0.47 crates and release a major new version (0.48) of all the crates.

Fixes: #2410
Fixes: #2411

@riverar
Copy link
Collaborator

riverar commented Mar 30, 2023

CC: @mati865 @glandium just for awareness regarding gnullvm having a target_abi="gnu" and being the only differentiation between gnu (target_abi="") and gnullvm toolchains.

@mati865
Copy link
Contributor

mati865 commented Apr 28, 2023

Sorry to bring bad news but I do believe this change could have broken gnullvm toolchains: msys2/MINGW-packages#16945
In the logs we see Compiling windows_aarch64_gnullvm v0.42.2 so older syntax works but we don't see the build for 0.48 using newer syntax and get this error at the end:

error: linking with `aarch64-w64-mingw32-clang` failed: exit code: 1
  |
  = note: "aarch64-w64-mingw32-clang" "-nolibc" "--unwindlib=none" "C:\\msys64\\tmp\\rustccbwNmC\\symbols.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.0.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.1.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.10.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.11.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.12.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.13.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.14.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.15.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.2.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.3.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.4.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.5.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.6.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.7.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.8.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.build_script_build.8ac08cfc-cgu.9.rcgu.o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.2eopp8tvc01cozim.rcgu.o" "-L" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps" "-L" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib" "-Wl,-Bstatic" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libtar-b4ac165f1cd5b40a.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libfiletime-b9923d04e7341109.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libwindows_sys-fa57eaacbeb84259.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libwindows_targets-a76946424531f1ff.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libflate2-361b9d48c86d32bf.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\liblibz_sys-5675eb3b81db5186.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libcrc32fast-289c1e24e98e2e5f.rlib" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\deps\\libcfg_if-d293f43a67dce076.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libstd-e236c6ffd6678a5c.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libpanic_unwind-f7f60a002777f963.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libobject-23ccaadb88a464a4.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libmemchr-92f521b87802780d.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libaddr2line-11ebd289875e6608.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libgimli-d6c569bc329a4d62.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\librustc_demangle-41df853e753d0398.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libstd_detect-b526c4d7c997cfe5.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libhashbrown-7dff24a1bfb4cdc9.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libminiz_oxide-3c8d603bfc6983a4.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libadler-8ba6be97b7ee01e4.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\librustc_std_workspace_alloc-03ac16c267d4523d.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libunwind-b0181b2d08c30cfa.rlib" "-lunwind" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libcfg_if-02fdd267e43a5852.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\liblibc-4ce88f41533d3be2.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\liballoc-859b6d08816552cd.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\librustc_std_workspace_core-86b72493b6c1a5bc.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libcore-ee0edd5b05add850.rlib" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib\\libcompiler_builtins-048f82b16f04d2b8.rlib" "-Wl,-Bdynamic" "-lwindows.0.48.0" "-lz" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lmingw32" "-lmingwex" "-lmsvcrt" "-lkernel32" "-luser32" "-Wl,--nxcompat" "-L" "C:\\msys64\\clangarm64\\lib\\rustlib\\aarch64-pc-windows-gnullvm\\lib" "-o" "C:\\M_P\\mingw-w64-cargo-c\\src\\cargo-c-0.9.19\\target\\release\\build\\cargo-7b8ecd1f567da8e6\\build_script_build-7b8ecd1f567da8e6.exe" "-Wl,--gc-sections" "-no-pie"
  = note: aarch64-w64-mingw32-clang: warning: argument unused during compilation: '-nolibc' [-Wunused-command-line-argument]
          aarch64-w64-mingw32-clang: warning: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument]
          lld: error: unable to find library -lwindows.0.48.0
          aarch64-w64-mingw32-clang: error: linker command failed with exit code 1 (use -v to see invocation)

I think Cargo doesn't understand target_abi syntax that is unstable (or Rustc is not passing it to Cargo?): rust-lang/rust#80970

@kennykerr
Copy link
Collaborator Author

The following workflow tests gnullvm:

https://github.com/microsoft/windows-rs/blob/master/.github/workflows/cross.yml

Is something missing?

@kennykerr
Copy link
Collaborator Author

Feel free to contribute better tests and a fix if necessary. I don't have any experience with gnullvm.

@mati865
Copy link
Contributor

mati865 commented Apr 28, 2023

It's kind of weird because I wasn't able to reproduce it when cross-compiling yesterday (like on the CI) but let's wait for a response on msys2/MINGW-packages#16945 (comment)

@mati865
Copy link
Contributor

mati865 commented May 22, 2023

Sorry for the delay, it was quite hard issue to pinpoint with limited time and without platform to reproduce the problem.
Opened PR with a workaround: #2515

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

Successfully merging this pull request may close these issues.

Release request for windows-sys Bug: Linker Error When Using windows and mio (uses windows-sys)
3 participants