@@ -218,25 +218,19 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
218218 cmd. args ( args) ;
219219 cmd. envs ( env) ;
220220
221+ // On windows, libraries are just searched in the executable directory,
222+ // system directories, PWD, and PATH, in that order. PATH is the only one
223+ // we can change for this.
224+ let library_path = if cfg ! ( windows) { "PATH" } else { "LD_LIBRARY_PATH" } ;
225+
221226 // Support libraries were uploaded to `work` earlier, so make sure that's
222227 // in `LD_LIBRARY_PATH`. Also include our own current dir which may have
223228 // had some libs uploaded.
224- if cfg ! ( windows) {
225- // On windows, libraries are just searched in the executable directory,
226- // system directories, PWD, and PATH, in that order. PATH is the only one
227- // we can change for this.
228- cmd. env (
229- "PATH" ,
230- env:: join_paths (
231- std:: iter:: once ( work. to_owned ( ) )
232- . chain ( std:: iter:: once ( path. clone ( ) ) )
233- . chain ( env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap ( ) ) ) ,
234- )
235- . unwrap ( ) ,
236- ) ;
237- } else {
238- cmd. env ( "LD_LIBRARY_PATH" , format ! ( "{}:{}" , work. display( ) , path. display( ) ) ) ;
229+ let mut paths = vec ! [ work. to_owned( ) , path. clone( ) ] ;
230+ if let Some ( library_path) = env:: var_os ( library_path) {
231+ paths. extend ( env:: split_paths ( & library_path) ) ;
239232 }
233+ cmd. env ( library_path, env:: join_paths ( paths) . unwrap ( ) ) ;
240234
241235 // Some tests assume RUST_TEST_TMPDIR exists
242236 cmd. env ( "RUST_TEST_TMPDIR" , tmp. to_owned ( ) ) ;
0 commit comments