-
Notifications
You must be signed in to change notification settings - Fork 460
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
Compiling from msbuild
incorrectly uses target build tools for build scripts
#1308
Comments
@NobodyXu @ChrisDenton Would you accept a PR based on your suggestion of parsing the output of The odd thing about it is that the msbuild tools will be used for the native target build scripts, but not otherwise. That's a bit counter-intuitive, perhaps. |
Yes I'm willing to review and merge it |
Well cc doesn't link anything, only compile and then archive. |
Looking at the code, for Visual Studio proper (e.g. after vcvars.bat) we use cc-rs/src/windows/find_tools.rs Lines 390 to 393 in 5daf14e
cc-rs/src/windows/find_tools.rs Lines 358 to 370 in 5daf14e
MSBuild does not set either of those nor does it set anything equivalent. For |
Hmmm how hard would it be?
👍 |
I meant the thing I mentioned earlier about parsing the line that appears at the top of stderr from |
Thanks for clarification that's pretty portable and quite reliable way of doing it, I don't think we have a better way to do it |
When running cargo from MSVC, as of Rust 1.83, it uses build tools for the target MSVC architecture rather than host, when building build scripts. Unsetting 'VSTEL_MSBuildProjectFullPath' works around this issue. This workaround can be removed once the upstream issue has been fixed: rust-lang/cc-rs#1308
When running cargo from MSVC, as of Rust 1.83, it uses build tools for the target MSVC architecture rather than host, when building build scripts. Unsetting 'VSTEL_MSBuildProjectFullPath' works around this issue. This workaround can be removed once the upstream issue has been fixed: rust-lang/cc-rs#1308
msbuild
uses target linker for build scriptsmsbuild
uses target build tools for build scripts
I've now opened #1310 to fix this issue. Thank you both for the help! |
msbuild
uses target build tools for build scriptsmsbuild
incorrectly uses target build tools for build scripts
The problem arises when running
cargo build
from within a VS project and targeting something other than the native arch (e.g., usingmsbuild.exe myproj.sln /p:Platform=otherarch
). When cargo builds a build script, it uses the target linker (added toPATH
by Visual Studio) instead of the host linker, which naturally fails.This is a problem as of Rust 1.83 due to the following fix: #1201. That PR also contains some discussion about this issue.
The text was updated successfully, but these errors were encountered: