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

[Bug]: x86 build on windows fails if the crate uses proc-macro #599

Closed
sevenc-nanashi opened this issue Jan 3, 2025 · 6 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@sevenc-nanashi
Copy link

sevenc-nanashi commented Jan 3, 2025

Current Behavior

If the crate uses proc-macro, it becomes impossible to do cross-compile for x86-windows on windows.

Expected Behavior

It should success.

Steps To Reproduce

  1. Use some proc-macro crate (Minimum reproduction: https://github.com/sevenc-nanashi/corrosion-x86-min-repro , this uses const_random crate)
  2. cmake -S . -B "build" -A Win32 && cmake --build build

Environment

- OS: Windows 10
- CMake: cmake version 3.31.3
- CMake Generator: Visual Studio 17 2022 / Win32

CMake configure log with Debug log-level

-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- Using Corrosion 0.99.99 with CMake 3.31.3 and the `Visual Studio 17 2022` Generator
-- Rust Toolchain: stable-x86_64-pc-windows-msvc
-- Rust toolchain stable-x86_64-pc-windows-msvc
-- Rust toolchain path C:\Users\katama\.rustup\toolchains\stable-x86_64-pc-windows-msvc
-- Rust Target: i686-pc-windows-msvc
-- Cargo target  is an official target-triple
-- Installed targets: i686-pc-windows-msvc;x86_64-pc-windows-msvc
-- Parsed Target triple: arch: i686, vendor: pc, OS: windows, env: msvc
-- Parsed Target triple: arch: x86_64, vendor: pc, OS: windows, env: msvc
-- Found 1 targets in package rust-lib
-- TARGET rust_lib produces byproducts rust_lib.lib
-- Corrosion created the following CMake targets: rust_lib
-- Output directory property (target rust_lib): ARCHIVE_OUTPUT_DIRECTORY dir: output_directory-NOTFOUND
-- Setting IMPORTED_LOCATION_DEBUG for target rust_lib-static to `E:/corrosion-x86-min-repro/build/rust_lib.lib`.
-- Setting IMPORTED_LOCATION_RELEASE for target rust_lib-static to `E:/corrosion-x86-min-repro/build/rust_lib.lib`.
-- Setting IMPORTED_LOCATION_MINSIZEREL for target rust_lib-static to `E:/corrosion-x86-min-repro/build/rust_lib.lib`.
-- Setting IMPORTED_LOCATION_RELWITHDEBINFO for target rust_lib-static to `E:/corrosion-x86-min-repro/build/rust_lib.lib`.
-- Setting IMPORTED_LOCATION for target rust_lib-static to `E:/corrosion-x86-min-repro/build/rust_lib.lib`.
-- Adding command to copy byproducts `rust_lib.lib` to $<$<CONFIG:Debug>:E:/corrosion-x86-min-repro/build>$<$<CONFIG:Release>:E:/corrosion-x86-min-repro/build>$<$<CONFIG:MinSizeRel>:E:/corrosion-x86-min-repro/build>$<$<CONFIG:RelWithDebInfo>:E:/corrosion-x86-min-repro/build>/rust_lib.lib
-- Configuring done (0.6s)
-- Generating done (0.2s)
-- Build files have been written to: E:/corrosion-x86-min-repro/build

CMake Build step log

__gi_build.log

@sevenc-nanashi sevenc-nanashi added the bug Something isn't working label Jan 3, 2025
@sevenc-nanashi
Copy link
Author

I found that this is caused by environment variable named VSTEL_MSBuildProjectFullPath, and adding --unset=VSTEL_MSBuildProjectFullPath on

"${build_env_variable_genex}"
solves the issue.
But I don't know if it's okay to unset this variable...

sevenc-nanashi added a commit to sevenc-nanashi/corrosion that referenced this issue Jan 3, 2025
@jschwe
Copy link
Collaborator

jschwe commented Jan 3, 2025

Which rust version are you using? Does it only occur with Rust 1.83 or can you also reproduce with Rust 1.82?

@sevenc-nanashi
Copy link
Author

sevenc-nanashi commented Jan 3, 2025

I used 1.83.0 to reproduce the issue.
I did rustup override set 1.82.0, and the error was gone.

@jschwe
Copy link
Collaborator

jschwe commented Jan 3, 2025

Could you also check if the issue is still present in the latest nightly or the beta toolchain?
It looks like rust-lang/rust#134505 fixes rust-lang/rust#133794, which looks similar to this issue.
If the issue is fixed in Rust 1.84 already, then I would prefer to not add any workarounds to corrosion just for one specific Rust version.

@sevenc-nanashi
Copy link
Author

sevenc-nanashi commented Jan 3, 2025

Looks like it's not fixed yet in nightly.

cmake -S . -B "build" -A Win32 -D Rust_RUSTUP_INSTALL_MISSING_TARGET=ON && cmake --build build | tee __gi_build_nightly.log
__gi_build_nightly.log

Oops, I haven't updated my nightly...

@sevenc-nanashi
Copy link
Author

It was fixed on nightly! I'm closing the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants