Skip to content

Commit c290339

Browse files
committed
target-spec compiletest: copy dylib loading from spirv-builder
1 parent 038c889 commit c290339

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tests/compiletests/src/main.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ impl DepKind {
5454
fn main() {
5555
let opt = Opt::parse();
5656

57+
// Pull in rustc_codegen_spirv as a dynamic library in the same way
58+
// spirv-builder does.
59+
let codegen_backend_path = find_rustc_codegen_spirv();
60+
5761
let tests_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
5862
let workspace_root = tests_dir.parent().unwrap().parent().unwrap();
5963
let original_target_dir = workspace_root.join("target");
@@ -67,10 +71,6 @@ fn main() {
6771
std::env::set_current_dir(tests_dir).unwrap();
6872
let tests_dir = PathBuf::from("");
6973

70-
// Pull in rustc_codegen_spirv as a dynamic library in the same way
71-
// spirv-builder does.
72-
let codegen_backend_path = find_rustc_codegen_spirv();
73-
7474
let runner = Runner {
7575
opt,
7676
tests_dir,
@@ -407,10 +407,14 @@ fn dylib_path_envvar() -> &'static str {
407407
}
408408

409409
fn dylib_path() -> Vec<PathBuf> {
410-
match env::var_os(dylib_path_envvar()) {
410+
let mut dylibs = match env::var_os(dylib_path_envvar()) {
411411
Some(var) => env::split_paths(&var).collect(),
412412
None => Vec::new(),
413+
};
414+
if let Ok(dir) = env::current_dir() {
415+
dylibs.push(dir);
413416
}
417+
dylibs
414418
}
415419

416420
fn find_rustc_codegen_spirv() -> PathBuf {
@@ -419,7 +423,8 @@ fn find_rustc_codegen_spirv() -> PathBuf {
419423
env::consts::DLL_PREFIX,
420424
env::consts::DLL_SUFFIX
421425
);
422-
for mut path in dylib_path() {
426+
let dylib_paths = dylib_path();
427+
for mut path in dylib_paths {
423428
path.push(&filename);
424429
if path.is_file() {
425430
return path;

0 commit comments

Comments
 (0)