-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #128245 - Oneirical:total-linkage-ownage, r=jieyouxu
Migrate `cdylib-dylib-linkage` `run-make` test to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). ~~Those sysroot tests are always fun. I'm getting local errors that don't make a lot of sense about my own sysroot not existing, so I am trying this in CI to see what happens.~~ ~~EDIT: I am getting the same error here. The strange thing is, when I try to navigate to `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib` on my personal computer, the directory does exist, but the error message is that the directory does not.~~ EDIT 2: The sysroot path just needed to be trimmed! Please try: // try-job: x86_64-msvc // passed previously try-job: x86_64-mingw try-job: x86_64-gnu-llvm-18 try-job: i686-msvc try-job: aarch64-apple
- Loading branch information
Showing
6 changed files
with
63 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Previously, rustc mandated that cdylibs could only link against rlibs as dependencies, | ||
// making linkage between cdylibs and dylibs impossible. After this was changed in #68448, | ||
// this test attempts to link both `foo` (a cdylib) and `bar` (a dylib) and checks that | ||
// both compilation and execution are successful. | ||
// See https://github.com/rust-lang/rust/pull/68448 | ||
|
||
//@ ignore-cross-compile | ||
// Reason: the compiled binary is executed | ||
|
||
use run_make_support::{ | ||
bin_name, cc, dynamic_lib_extension, dynamic_lib_name, filename_contains, has_extension, | ||
has_prefix, has_suffix, is_msvc, msvc_import_dynamic_lib_name, path, run, rustc, | ||
shallow_find_files, target, | ||
}; | ||
|
||
fn main() { | ||
rustc().arg("-Cprefer-dynamic").input("bar.rs").run(); | ||
rustc().input("foo.rs").run(); | ||
let sysroot = rustc().print("sysroot").run().stdout_utf8(); | ||
let sysroot = sysroot.trim(); | ||
let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib"); | ||
if is_msvc() { | ||
let mut libs = shallow_find_files(&target_sysroot, |path| { | ||
has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib") | ||
}); | ||
libs.push(path(msvc_import_dynamic_lib_name("foo"))); | ||
libs.push(path(msvc_import_dynamic_lib_name("bar"))); | ||
cc().input("foo.c").args(&libs).out_exe("foo").run(); | ||
} else { | ||
let stdlibs = shallow_find_files(&target_sysroot, |path| { | ||
has_extension(path, dynamic_lib_extension()) && filename_contains(path, "std") | ||
}); | ||
cc().input("foo.c") | ||
.args(&[dynamic_lib_name("foo"), dynamic_lib_name("bar")]) | ||
.arg(stdlibs.get(0).unwrap()) | ||
.library_search_path(&target_sysroot) | ||
.output(bin_name("foo")) | ||
.run(); | ||
} | ||
run("foo"); | ||
} |