Skip to content

Commit 2cc747c

Browse files
authored
Rollup merge of rust-lang#81456 - Amanieu:remote-test-server, r=Amanieu
Make remote-test-server easier to use with new targets While testing rust-lang#81455 I encountered 2 issues with `remote-test-server`: - It is built with the stage 0 toolchain, which does not support a newly added target. - It overwrites `LD_LIBRARY_PATH` instead of appending to it, which prevents the use of a custom sysroot for target libraries.
2 parents 47dd875 + b5482a8 commit 2cc747c

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/bootstrap/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1880,8 +1880,7 @@ impl Step for RemoteCopyLibs {
18801880
builder.info(&format!("REMOTE copy libs to emulator ({})", target));
18811881
t!(fs::create_dir_all(builder.out.join("tmp")));
18821882

1883-
let server =
1884-
builder.ensure(tool::RemoteTestServer { compiler: compiler.with_stage(0), target });
1883+
let server = builder.ensure(tool::RemoteTestServer { compiler, target });
18851884

18861885
// Spawn the emulator and wait for it to come online
18871886
let tool = builder.tool_exe(Tool::RemoteTestClient);

src/tools/remote-test-server/src/main.rs

+9-15
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)