Skip to content

Commit 0b0d5d8

Browse files
committed
target-spec compiletest: copy dylib loading from spirv-builder
1 parent ad05377 commit 0b0d5d8

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,
@@ -409,10 +409,14 @@ fn dylib_path_envvar() -> &'static str {
409409
}
410410

411411
fn dylib_path() -> Vec<PathBuf> {
412-
match env::var_os(dylib_path_envvar()) {
412+
let mut dylibs = match env::var_os(dylib_path_envvar()) {
413413
Some(var) => env::split_paths(&var).collect(),
414414
None => Vec::new(),
415+
};
416+
if let Ok(dir) = env::current_dir() {
417+
dylibs.push(dir);
415418
}
419+
dylibs
416420
}
417421

418422
fn find_rustc_codegen_spirv() -> PathBuf {
@@ -421,7 +425,8 @@ fn find_rustc_codegen_spirv() -> PathBuf {
421425
env::consts::DLL_PREFIX,
422426
env::consts::DLL_SUFFIX
423427
);
424-
for mut path in dylib_path() {
428+
let dylib_paths = dylib_path();
429+
for mut path in dylib_paths {
425430
path.push(&filename);
426431
if path.is_file() {
427432
return path;

0 commit comments

Comments
 (0)