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

msvc: rustc produces invalid .exe (Windows XP) #34407

Closed
liigo opened this issue Jun 22, 2016 · 4 comments
Closed

msvc: rustc produces invalid .exe (Windows XP) #34407

liigo opened this issue Jun 22, 2016 · 4 comments

Comments

@liigo
Copy link
Contributor

liigo commented Jun 22, 2016

I use latest toolchain stable-i686-pc-windows-msvc and VC-2015 on Windows 10, compile a helloworld.exe (which is valid on Windows 10), and try to run it in XP, but the OS tells me that it's an invalid executable.

Maybe we should have an option to use Windows Kit (SDK) 7.1 (v140_xp toolset etc.)?

I known firefox is using some rust components, which I don't known how they are compiled for XP.

cc rust-lang/rfcs#1061 #25350 #30233 #26601

Refs:
https://msdn.microsoft.com/en-us/library/jj851139.aspx
http://stackoverflow.com/questions/33188600/how-to-set-v140-xp-toolset-in-command-prompt-for-build-with-nmake

@Aatch
Copy link
Contributor

Aatch commented Jun 22, 2016

Well it sounds like you're not compiling for the correct target. If the problem is that you can't compile for the correct, that's the issue, but from the description it doesn't seem like rustc is producing an invalid .exe.

@liigo
Copy link
Contributor Author

liigo commented Jun 22, 2016

@Aatch
rustc produces a valide .exe (32bit) on Windows 10, but this .exe is invalid on Windows XP.
I didn't use cross compile. If I must cross compile, which target I should select to create a valid .exe for XP? (I'm using stable-i686-pc-windows-msvc toolchain on Windows 10.)

@alexcrichton
Copy link
Member

Yes i686-pc-windows-msvc is the right target, but you have to pass a special linker flag to produce an executable that runs on XP. I think it's something like /subsystem:windows,5.01 or related. I don't think this is a bug with the compiler per se, so I'm going to close, but feel free to ask me if it doesn't work out!

@liigo
Copy link
Contributor Author

liigo commented Jun 23, 2016

Thank you! It works! @alexcrichton
FWIW, my full command line is: rustc main.rs -C link-args="/subsystem:console,5.01"
(I did try /subsystem:console,6.01 (which not work))

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

No branches or pull requests

3 participants