Why are rust executable binaries obtained at different times different in the same compiler environment(linux system)

The main.rs

use actix_web::{web, App, Responder, HttpServer};

async fn index() -> impl Responder {
    "Hello world!"
}

#[actix_rt::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        App::new().service(
            web::scope("/app").route("/index.html", web::get().to(index)),
        )
    })
        .bind("127.0.0.1:8088")?
        .run()
        .await
}

Cargo.toml

[package]
name = "test1"
version = "0.1.0"
authors = [""]
edition = "2018"

[dependencies]
actix-web = {version = "=2.0.0", features=["rust-tls"] }
actix-rt = "=1.0.0"

The place that causes the binary executable file to be different may be the following code:

actix-server-1.0.2/src/service.rs

impl<F, Io> InternalServiceFactory for StreamNewService<F, Io>
where
    F: ServiceFactory<Io>,
    Io: FromStream + Send + 'static,
{
    fn name(&self, _: Token) -> &str {
        &self.name
    }

    fn clone_factory(&self) -> Box<dyn InternalServiceFactory> {
        Box::new(Self {
            name: self.name.clone(),
            inner: self.inner.clone(),
            token: self.token,
            addr: self.addr,
            _t: PhantomData,
        })
    }

    fn create(&self) -> LocalBoxFuture<'static, Result<Vec<(Token, BoxedServerService)>, ()>> {
        let token = self.token;
        self.inner
            .create()
            .new_service(())
            .map_err(|_| ())
            .map_ok(move |inner| {
                let service: BoxedServerService = Box::new(StreamService::new(inner));
                vec![(token, service)]
            })
            .boxed_local()
    }
}

This line let service: BoxedServerService = Box::new(StreamService::new(inner));,when i remove it,i got same binary executable file at the different time.

What do you mean by "got same file at different time"?

Complier the code twice,and compare the first executable file and second file by the "Beyond Compare",there has a difference.When i remove the line let service: BoxedServerService = Box::new(StreamService::new(inner));,the two executable file has no difference.

it's because Rust hasn't reproductible build yet. it's WIP though, needed for security audit and embedded (on phone so no link, sorry :))

Known bug:

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.