Skip to content

Commit e85df7a

Browse files
committed
Add nothread and staticlink for remote-test-server
Basically using program arguments instead of conditional compilation. Signed-off-by: Ayush <ayushsingh1325@gmail.com>
1 parent 0bb8203 commit e85df7a

File tree

2 files changed

+52
-81
lines changed

2 files changed

+52
-81
lines changed

Cargo.lock

Lines changed: 29 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ dependencies = [
233233
"anyhow",
234234
"flate2",
235235
"hex 0.4.2",
236-
"num_cpus",
237236
"rayon",
238237
"serde",
239238
"serde_json",
@@ -1665,9 +1664,9 @@ dependencies = [
16651664
"log",
16661665
"pest",
16671666
"pest_derive",
1668-
"quick-error 2.0.0",
16691667
"serde",
16701668
"serde_json",
1669+
"thiserror",
16711670
]
16721671

16731672
[[package]]
@@ -1705,6 +1704,7 @@ checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7"
17051704
dependencies = [
17061705
"compiler_builtins",
17071706
"libc",
1707+
"rustc-std-workspace-alloc",
17081708
"rustc-std-workspace-core",
17091709
]
17101710

@@ -1766,7 +1766,7 @@ version = "1.3.0"
17661766
source = "registry+https://github.com/rust-lang/crates.io-index"
17671767
checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
17681768
dependencies = [
1769-
"quick-error 1.2.3",
1769+
"quick-error",
17701770
]
17711771

17721772
[[package]]
@@ -1884,8 +1884,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
18841884
checksum = "3ca8957e71f04a205cb162508f9326aea04676c8dfd0711220190d6b83664f3f"
18851885
dependencies = [
18861886
"bitmaps",
1887-
"rand_core 0.6.2",
1888-
"rand_xoshiro",
1887+
"rand_core 0.5.1",
1888+
"rand_xoshiro 0.4.0",
18891889
"sized-chunks",
18901890
"typenum",
18911891
"version_check",
@@ -2794,9 +2794,9 @@ dependencies = [
27942794

27952795
[[package]]
27962796
name = "pin-project-lite"
2797-
version = "0.2.8"
2797+
version = "0.2.9"
27982798
source = "registry+https://github.com/rust-lang/crates.io-index"
2799-
checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
2799+
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
28002800

28012801
[[package]]
28022802
name = "pin-utils"
@@ -2879,7 +2879,7 @@ version = "1.0.46"
28792879
source = "registry+https://github.com/rust-lang/crates.io-index"
28802880
checksum = "94e2ef8dbfc347b10c094890f778ee2e36ca9bb4262e86dc99cd217e35f3470b"
28812881
dependencies = [
2882-
"unicode-xid",
2882+
"unicode-ident",
28832883
]
28842884

28852885
[[package]]
@@ -2931,12 +2931,6 @@ version = "1.2.3"
29312931
source = "registry+https://github.com/rust-lang/crates.io-index"
29322932
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
29332933

2934-
[[package]]
2935-
name = "quick-error"
2936-
version = "2.0.0"
2937-
source = "registry+https://github.com/rust-lang/crates.io-index"
2938-
checksum = "3ac73b1112776fc109b2e61909bc46c7e1bf0d7f690ffb1676553acce16d5cda"
2939-
29402934
[[package]]
29412935
name = "quine-mc_cluskey"
29422936
version = "0.2.4"
@@ -2961,37 +2955,6 @@ dependencies = [
29612955
"rustc-std-workspace-core",
29622956
]
29632957

2964-
[[package]]
2965-
name = "racer"
2966-
version = "2.2.2"
2967-
dependencies = [
2968-
"bitflags",
2969-
"derive_more",
2970-
"env_logger 0.7.1",
2971-
"humantime 2.0.1",
2972-
"lazy_static",
2973-
"lazycell",
2974-
"log",
2975-
"racer-cargo-metadata",
2976-
"rls-span",
2977-
]
2978-
2979-
[[package]]
2980-
name = "racer-cargo-metadata"
2981-
version = "0.1.2"
2982-
dependencies = [
2983-
"racer-interner",
2984-
"serde",
2985-
"serde_json",
2986-
]
2987-
2988-
[[package]]
2989-
name = "racer-interner"
2990-
version = "0.1.0"
2991-
dependencies = [
2992-
"serde",
2993-
]
2994-
29952958
[[package]]
29962959
name = "rand"
29972960
version = "0.7.3"
@@ -5024,7 +4987,7 @@ checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
50244987
dependencies = [
50254988
"proc-macro2",
50264989
"quote",
5027-
"unicode-xid",
4990+
"unicode-ident",
50284991
]
50294992

50304993
[[package]]
@@ -5223,9 +5186,18 @@ dependencies = [
52235186

52245187
[[package]]
52255188
name = "tinyvec"
5226-
version = "0.3.4"
5189+
version = "1.6.0"
52275190
source = "registry+https://github.com/rust-lang/crates.io-index"
5228-
checksum = "238ce071d267c5710f9d31451efec16c5ee22de34df17cc05e56cbc92e967117"
5191+
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
5192+
dependencies = [
5193+
"tinyvec_macros",
5194+
]
5195+
5196+
[[package]]
5197+
name = "tinyvec_macros"
5198+
version = "0.1.0"
5199+
source = "registry+https://github.com/rust-lang/crates.io-index"
5200+
checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
52295201

52305202
[[package]]
52315203
name = "tokio"
@@ -5279,9 +5251,9 @@ checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"
52795251

52805252
[[package]]
52815253
name = "tracing"
5282-
version = "0.1.29"
5254+
version = "0.1.37"
52835255
source = "registry+https://github.com/rust-lang/crates.io-index"
5284-
checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105"
5256+
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
52855257
dependencies = [
52865258
"cfg-if 1.0.0",
52875259
"pin-project-lite",
@@ -5291,9 +5263,9 @@ dependencies = [
52915263

52925264
[[package]]
52935265
name = "tracing-attributes"
5294-
version = "0.1.22"
5266+
version = "0.1.23"
52955267
source = "registry+https://github.com/rust-lang/crates.io-index"
5296-
checksum = "11c75893af559bc8e10716548bdef5cb2b983f8e637db9d0e15126b61b484ee2"
5268+
checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a"
52975269
dependencies = [
52985270
"proc-macro2",
52995271
"quote",
@@ -5302,11 +5274,12 @@ dependencies = [
53025274

53035275
[[package]]
53045276
name = "tracing-core"
5305-
version = "0.1.21"
5277+
version = "0.1.30"
53065278
source = "registry+https://github.com/rust-lang/crates.io-index"
5307-
checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4"
5279+
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
53085280
dependencies = [
5309-
"lazy_static",
5281+
"once_cell",
5282+
"valuable",
53105283
]
53115284

53125285
[[package]]
@@ -5910,3 +5883,4 @@ dependencies = [
59105883
"syn",
59115884
"synstructure",
59125885
]
5886+

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

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ use std::process::{Command, ExitStatus, Stdio};
2727
use std::str;
2828
use std::sync::atomic::{AtomicUsize, Ordering};
2929
use std::sync::{Arc, Mutex};
30-
#[cfg(not(target_os = "uefi"))]
3130
use std::thread;
3231

3332
macro_rules! t {
@@ -48,6 +47,7 @@ struct Config {
4847
verbose: bool,
4948
sequential: bool,
5049
bind: SocketAddr,
50+
staticlink: bool,
5151
}
5252

5353
impl Config {
@@ -60,6 +60,7 @@ impl Config {
6060
} else {
6161
([10, 0, 2, 15], 12345).into()
6262
},
63+
staticlink: false
6364
}
6465
}
6566

@@ -81,6 +82,9 @@ impl Config {
8182
show_help();
8283
std::process::exit(0);
8384
}
85+
"--staticlink" => {
86+
config.staticlink = true;
87+
}
8488
arg => panic!("unknown argument: {}, use `--help` for known arguments", arg),
8589
}
8690
}
@@ -262,33 +266,25 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
262266
let exe = recv(&path, &mut reader);
263267
print_verbose(&format!("run {:#?}", exe), config);
264268

265-
// FIXME: Remove this in the future
266-
#[cfg(target_os = "uefi")]
267-
let exe = format!(
268-
"{}/\\{}",
269-
std::env::current_dir().unwrap().to_string_lossy(),
270-
exe.to_string_lossy()
271-
);
272-
273269
let mut cmd = Command::new(&exe);
274270
cmd.args(args);
275271
cmd.envs(env);
276272

277-
// On windows, libraries are just searched in the executable directory,
278-
// system directories, PWD, and PATH, in that order. PATH is the only one
279-
// we can change for this.
280-
let library_path = if cfg!(windows) { "PATH" } else { "LD_LIBRARY_PATH" };
281-
282273
// Support libraries were uploaded to `work` earlier, so make sure that's
283274
// in `LD_LIBRARY_PATH`. Also include our own current dir which may have
284275
// had some libs uploaded.
285276
let mut paths = vec![work.to_owned(), path.clone()];
286-
if let Some(library_path) = env::var_os(library_path) {
287-
paths.extend(env::split_paths(&library_path));
277+
278+
if !config.staticlink {
279+
// On windows, libraries are just searched in the executable directory,
280+
// system directories, PWD, and PATH, in that order. PATH is the only one
281+
// we can change for this.
282+
let library_path = if cfg!(windows) { "PATH" } else { "LD_LIBRARY_PATH" };
283+
if let Some(library_path) = env::var_os(library_path) {
284+
paths.extend(env::split_paths(&library_path));
285+
}
286+
cmd.env(library_path, env::join_paths(paths).unwrap());
288287
}
289-
// Dynamic Linking not present in UEFI
290-
#[cfg(not(target_os = "uefi"))]
291-
cmd.env(library_path, env::join_paths(paths).unwrap());
292288

293289
// Some tests assume RUST_TEST_TMPDIR exists
294290
cmd.env("RUST_TEST_TMPDIR", tmp.to_owned());
@@ -303,13 +299,14 @@ fn handle_run(socket: TcpStream, work: &Path, tmp: &Path, lock: &Mutex<()>, conf
303299
let mut stderr = child.stderr.take().unwrap();
304300
let socket = Arc::new(Mutex::new(reader.into_inner()));
305301
let socket2 = socket.clone();
306-
#[cfg(target_os = "uefi")]
307-
my_copy(&mut stdout, 0, &*socket2);
308-
#[cfg(not(target_os = "uefi"))]
309-
let thread = thread::spawn(move || my_copy(&mut stdout, 0, &*socket2));
310-
my_copy(&mut stderr, 1, &*socket);
311-
#[cfg(not(target_os = "uefi"))]
312-
thread.join().unwrap();
302+
if config.sequential {
303+
my_copy(&mut stdout, 0, &*socket2);
304+
my_copy(&mut stderr, 1, &*socket);
305+
} else {
306+
let thread = thread::spawn(move || my_copy(&mut stdout, 0, &*socket2));
307+
my_copy(&mut stderr, 1, &*socket);
308+
thread.join().unwrap();
309+
}
313310

314311
// Finally send over the exit status.
315312
let status = t!(child.wait());

0 commit comments

Comments
 (0)