@@ -60,6 +60,7 @@ impl WorkspaceBuildScripts {
6060 fn build_command (
6161 config : & CargoConfig ,
6262 allowed_features : & FxHashSet < String > ,
63+ workspace_root : & AbsPathBuf ,
6364 ) -> io:: Result < Command > {
6465 let mut cmd = match config. run_build_script_command . as_deref ( ) {
6566 Some ( [ program, args @ ..] ) => {
@@ -73,6 +74,9 @@ impl WorkspaceBuildScripts {
7374 cmd. args ( [ "check" , "--quiet" , "--workspace" , "--message-format=json" ] ) ;
7475 cmd. args ( & config. extra_args ) ;
7576
77+ cmd. arg ( "--manifest-path" ) ;
78+ cmd. arg ( workspace_root. join ( "Cargo.toml" ) . as_os_str ( ) ) ;
79+
7680 if let Some ( target_dir) = & config. target_dir {
7781 cmd. arg ( "--target-dir" ) . arg ( target_dir) ;
7882 }
@@ -143,7 +147,11 @@ impl WorkspaceBuildScripts {
143147 let allowed_features = workspace. workspace_features ( ) ;
144148
145149 match Self :: run_per_ws (
146- Self :: build_command ( config, & allowed_features) ?,
150+ Self :: build_command (
151+ config,
152+ & allowed_features,
153+ & workspace. workspace_root ( ) . to_path_buf ( ) ,
154+ ) ?,
147155 workspace,
148156 current_dir,
149157 progress,
@@ -153,7 +161,11 @@ impl WorkspaceBuildScripts {
153161 {
154162 // building build scripts failed, attempt to build with --keep-going so
155163 // that we potentially get more build data
156- let mut cmd = Self :: build_command ( config, & allowed_features) ?;
164+ let mut cmd = Self :: build_command (
165+ config,
166+ & allowed_features,
167+ & workspace. workspace_root ( ) . to_path_buf ( ) ,
168+ ) ?;
157169 cmd. args ( [ "-Z" , "unstable-options" , "--keep-going" ] ) . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
158170 let mut res = Self :: run_per_ws ( cmd, workspace, current_dir, progress) ?;
159171 res. error = Some ( error) ;
@@ -169,6 +181,7 @@ impl WorkspaceBuildScripts {
169181 config : & CargoConfig ,
170182 workspaces : & [ & CargoWorkspace ] ,
171183 progress : & dyn Fn ( String ) ,
184+ workspace_root : & AbsPathBuf ,
172185 ) -> io:: Result < Vec < WorkspaceBuildScripts > > {
173186 assert_eq ! ( config. invocation_strategy, InvocationStrategy :: Once ) ;
174187
@@ -181,7 +194,7 @@ impl WorkspaceBuildScripts {
181194 ) )
182195 }
183196 } ;
184- let cmd = Self :: build_command ( config, & Default :: default ( ) ) ?;
197+ let cmd = Self :: build_command ( config, & Default :: default ( ) , workspace_root ) ?;
185198 // NB: Cargo.toml could have been modified between `cargo metadata` and
186199 // `cargo check`. We shouldn't assume that package ids we see here are
187200 // exactly those from `config`.
0 commit comments