Hello, I want to deploy my Rust application on a group of identical EC2 servers. Do people typically build once on one of the machines and then trust that the binary works for all of them, or do you build on every machine individually to be safe? In general, does compiling to the same target triple always produce the same binary, regardless of the machine that compiles it?
#Deploying Rust on cloud servers: build once or on each machine?
8 messages · Page 1 of 1 (latest)
build once
unless you're running different distros/docker images (in which case, why?), you shouldn't worry about it
for amd64, rust by default outputs a binary that should work on the first amd64 proc from the beginning of the 2000s
does compiling to the same target triple always produce the same binary, regardless of the machine that compiles it?
that's a harder question than it sounds like. in an ideal world, that would be the case, but I think rust doesn't have enough flags to do that yet
but any binary it produces, it should work just the same
you can look here to see what makes rustc not yet deterministic
If you want to go further than this, look to your cloud provider for documentation on what micro-architectures they use. There should be docs for what microarchitectures you can get for any given machine type. So long as you compile with a minimum arch version to support that, you should be fine. (Though depending on the details you may want to have a different target arch)