Reputation: 841
I am compiling a rust application that will be statically linked and then placed on an external server. What settings, config, or table should I look up to find the correct compile target? For most modern windows server and computers, x86_64-pc-windows-msvc should work just fine, but I wanted to know if there was a more concrete way of figuring this out.
Here the rustup docs mention windows installation and considerations, but not how to figure out the target.
Upvotes: 2
Views: 1272
Reputation: 8980
Try going to the system you are building for and run echo %PROCESSOR_ARCHITECTURE%
. This will give us information about the CPU architecture that can help us decide.
According to the win32 documentation, it will be a value of AMD64
, IA64
, ARM64
, or x86
. Conveniently these line up with the available windows rust targets. I can find all of the rust targets by running rustup target list
and looking for ones with windows in the name. Here is that output on my machine:
$ rustup target list | grep windows
aarch64-pc-windows-msvc
i586-pc-windows-msvc
i686-pc-windows-gnu
i686-pc-windows-msvc
x86_64-pc-windows-gnu
x86_64-pc-windows-msvc
For the values of PROCESSOR_ARCHITECTURE
, we can more or less approximate which is which by just googling them.
AMD64
: This is just another name for x86_64
so we need to use either x86_64-pc-windows-msvc
or x86_64-pc-windows-gnu
.IA64
: ¯\(ツ)/¯ Rust is built on top of LLVM. IA64
has reached its end of life and not much hardware uses it so LLVM decided not to support this architecture. I think gcc
probably does support it, but we're already out of luck when it comes to using Rust.ARM64
: This corresponds to the aarch64
architecture so we should use aarch64-pc-windows-msvc
.x86
: This actually means we are running in 32bit mode so we need to choose either i686-pc-windows-msvc
or i686-pc-windows-gnu
.As for i586-pc-windows-msvc
, it refers to the older I5 Pentium architecture. It should be compatible with the newer i686
and x86_64
architectures, but may or may not be as performant. I would avoid it unless you are working with older hardware and need compatibility. I am also assuming it will not be compatible with windows 11 due to the new 64bit requirement.
As for the difference between msvc
and gnu
, you get to pick. I imagine msvc
will be easier to work with, but I have not tried to use the gnu
version.
Upvotes: 3