@@ -3117,53 +3117,63 @@ impl Step for Distcheck {
31173117 ///
31183118 /// FIXME(#136822): dist components are under-tested.
31193119 fn run ( self , builder : & Builder < ' _ > ) {
3120- builder. info ( "Distcheck" ) ;
3121- let dir = builder. tempdir ( ) . join ( "distcheck" ) ;
3122- let _ = fs:: remove_dir_all ( & dir) ;
3123- t ! ( fs:: create_dir_all( & dir) ) ;
3124-
3125- // Guarantee that these are built before we begin running.
3126- builder. ensure ( dist:: PlainSourceTarball ) ;
3127- builder. ensure ( dist:: Src ) ;
3120+ // Use a temporary directory completely outside the current checkout, to avoid reusing any
3121+ // local source code, built artifacts or configuration by accident
3122+ let root_dir = std:: env:: temp_dir ( ) . join ( "distcheck" ) ;
3123+
3124+ // Check that we can build some basic things from the plain source tarball
3125+ builder. info ( "Distcheck plain source tarball" ) ;
3126+ let plain_src_tarball = builder. ensure ( dist:: PlainSourceTarball ) ;
3127+ let plain_src_dir = root_dir. join ( "distcheck-plain-src" ) ;
3128+ builder. clear_dir ( & plain_src_dir) ;
3129+
3130+ let configure_args: Vec < String > = std:: env:: var ( "DISTCHECK_CONFIGURE_ARGS" )
3131+ . map ( |args| args. split ( " " ) . map ( |s| s. to_string ( ) ) . collect :: < Vec < String > > ( ) )
3132+ . unwrap_or_default ( ) ;
31283133
31293134 command ( "tar" )
31303135 . arg ( "-xf" )
3131- . arg ( builder . ensure ( dist :: PlainSourceTarball ) . tarball ( ) )
3136+ . arg ( plain_src_tarball . tarball ( ) )
31323137 . arg ( "--strip-components=1" )
3133- . current_dir ( & dir )
3138+ . current_dir ( & plain_src_dir )
31343139 . run ( builder) ;
31353140 command ( "./configure" )
3136- . args ( & builder. config . configure_args )
3141+ . arg ( "--set" )
3142+ . arg ( "rust.omit-git-hash=false" )
3143+ . args ( & configure_args)
31373144 . arg ( "--enable-vendor" )
3138- . current_dir ( & dir )
3145+ . current_dir ( & plain_src_dir )
31393146 . run ( builder) ;
31403147 command ( helpers:: make ( & builder. config . host_target . triple ) )
31413148 . arg ( "check" )
3142- . current_dir ( & dir)
3149+ // Do not run the build as if we were in CI, otherwise git would be assumed to be
3150+ // present, but we build from a tarball here
3151+ . env ( "GITHUB_ACTIONS" , "0" )
3152+ . current_dir ( & plain_src_dir)
31433153 . run ( builder) ;
31443154
31453155 // Now make sure that rust-src has all of libstd's dependencies
31463156 builder. info ( "Distcheck rust-src" ) ;
3147- let dir = builder. tempdir ( ) . join ( "distcheck-src" ) ;
3148- let _ = fs :: remove_dir_all ( & dir ) ;
3149- t ! ( fs :: create_dir_all ( & dir ) ) ;
3157+ let src_tarball = builder. ensure ( dist :: Src ) ;
3158+ let src_dir = root_dir . join ( "distcheck-src" ) ;
3159+ builder . clear_dir ( & src_dir ) ;
31503160
31513161 command ( "tar" )
31523162 . arg ( "-xf" )
3153- . arg ( builder . ensure ( dist :: Src ) . tarball ( ) )
3163+ . arg ( src_tarball . tarball ( ) )
31543164 . arg ( "--strip-components=1" )
3155- . current_dir ( & dir )
3165+ . current_dir ( & src_dir )
31563166 . run ( builder) ;
31573167
3158- let toml = dir . join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
3168+ let toml = src_dir . join ( "rust-src/lib/rustlib/src/rust/library/std/Cargo.toml" ) ;
31593169 command ( & builder. initial_cargo )
31603170 // Will read the libstd Cargo.toml
31613171 // which uses the unstable `public-dependency` feature.
31623172 . env ( "RUSTC_BOOTSTRAP" , "1" )
31633173 . arg ( "generate-lockfile" )
31643174 . arg ( "--manifest-path" )
31653175 . arg ( & toml)
3166- . current_dir ( & dir )
3176+ . current_dir ( & src_dir )
31673177 . run ( builder) ;
31683178 }
31693179}
0 commit comments