@@ -112,16 +112,42 @@ impl Step for Gcc {
112112 return true ;
113113 }
114114
115- command ( root. join ( "contrib/download_prerequisites" ) ) . current_dir ( & root) . run ( builder) ;
116- command ( root. join ( "configure" ) )
115+ let deps_dir = out_dir. join ( "deps" ) ;
116+ t ! ( fs:: create_dir_all( & deps_dir) ) ;
117+
118+ // Download dependencies into the build directory, to avoid modifying the source dir
119+ // The configure script should automatically find them in the build directory
120+ command ( root. join ( "contrib/download_prerequisites" ) )
121+ . current_dir ( & root)
122+ . arg ( "--directory" )
123+ . arg ( deps_dir)
124+ . run ( builder) ;
125+
126+ let mut configure_cmd = command ( root. join ( "configure" ) ) ;
127+ configure_cmd
117128 . current_dir ( & out_dir)
118129 . arg ( "--enable-host-shared" )
119130 . arg ( "--enable-languages=jit" )
120131 . arg ( "--enable-checking=release" )
121132 . arg ( "--disable-bootstrap" )
122133 . arg ( "--disable-multilib" )
123- . arg ( format ! ( "--prefix={}" , install_dir. display( ) ) )
124- . run ( builder) ;
134+ . arg ( format ! ( "--prefix={}" , install_dir. display( ) ) ) ;
135+ let mut cc = builder. build . cc ( target) . display ( ) . to_string ( ) ;
136+ if let Some ( ref ccache) = builder. build . config . ccache {
137+ cc = format ! ( "{ccache} {cc}" ) ;
138+ }
139+ configure_cmd. env ( "CC" , cc) ;
140+
141+ if let Ok ( ref cxx) = builder. build . cxx ( target) {
142+ let mut cxx = cxx. display ( ) . to_string ( ) ;
143+ if let Some ( ref ccache) = builder. build . config . ccache {
144+ cxx = format ! ( "{ccache} {cxx}" ) ;
145+ }
146+ configure_cmd. env ( "CXX" , cxx) ;
147+ }
148+
149+ configure_cmd. run ( builder) ;
150+
125151 command ( "make" ) . current_dir ( & out_dir) . arg ( format ! ( "-j{}" , builder. jobs( ) ) ) . run ( builder) ;
126152 command ( "make" ) . current_dir ( & out_dir) . arg ( "install" ) . run ( builder) ;
127153
0 commit comments