This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed
tests/run-make/symlinked-extern Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -93,6 +93,17 @@ pub fn source_root() -> PathBuf {
9393 env_var ( "SOURCE_ROOT" ) . into ( )
9494}
9595
96+ /// Creates a new symlink to a path on the filesystem, adjusting for Windows or Unix.
97+ pub fn create_symlink < P : AsRef < Path > , Q : AsRef < Path > > ( original : P , link : Q ) {
98+ if is_windows ( ) {
99+ use std:: os:: windows:: fs;
100+ fs:: symlink_file ( original, link) . unwrap ( ) ;
101+ } else {
102+ use std:: os:: unix:: fs;
103+ fs:: symlink ( original, link) . unwrap ( ) ;
104+ }
105+ }
106+
96107/// Construct the static library name based on the platform.
97108pub fn static_lib_name ( name : & str ) -> String {
98109 // See tools.mk (irrelevant lines omitted):
@@ -114,7 +125,11 @@ pub fn static_lib_name(name: &str) -> String {
114125 // ```
115126 assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
116127
117- if is_msvc ( ) { format ! ( "{name}.lib" ) } else { format ! ( "lib{name}.a" ) }
128+ if is_msvc ( ) {
129+ format ! ( "{name}.lib" )
130+ } else {
131+ format ! ( "lib{name}.a" )
132+ }
118133}
119134
120135/// Construct the dynamic library name based on the platform.
@@ -161,7 +176,11 @@ pub fn rust_lib_name(name: &str) -> String {
161176
162177/// Construct the binary name based on platform.
163178pub fn bin_name ( name : & str ) -> String {
164- if is_windows ( ) { format ! ( "{name}.exe" ) } else { name. to_string ( ) }
179+ if is_windows ( ) {
180+ format ! ( "{name}.exe" )
181+ } else {
182+ name. to_string ( )
183+ }
165184}
166185
167186/// Return the current working directory.
Original file line number Diff line number Diff line change @@ -228,7 +228,6 @@ run-make/std-core-cycle/Makefile
228228run-make/symbol-mangling-hashed/Makefile
229229run-make/symbol-visibility/Makefile
230230run-make/symbols-include-type-name/Makefile
231- run-make/symlinked-extern/Makefile
232231run-make/symlinked-libraries/Makefile
233232run-make/symlinked-rlib/Makefile
234233run-make/sysroot-crates-are-unstable/Makefile
Original file line number Diff line number Diff line change 1+ // Crates that are resolved normally have their path canonicalized and all
2+ // symlinks resolved. This did not happen for paths specified
3+ // using the --extern option to rustc, which could lead to rustc thinking
4+ // that it encountered two different versions of a crate, when it's
5+ // actually the same version found through different paths.
6+
7+ // This test checks that --extern and symlinks together
8+ // can result in successful compilation.
9+
10+ //@ ignore-cross-compile
11+
12+ use run_make_support:: { create_symlink, rustc, tmp_dir} ;
13+ use std:: fs;
14+
15+ fn main ( ) {
16+ rustc ( ) . input ( "foo.rs" ) . run ( ) ;
17+ fs:: create_dir_all ( tmp_dir ( ) . join ( "other" ) ) . unwrap ( ) ;
18+ create_symlink ( tmp_dir ( ) . join ( "libfoo.rlib" ) , tmp_dir ( ) . join ( "other" ) ) ;
19+ rustc ( ) . input ( "bar.rs" ) . library_search_path ( tmp_dir ( ) ) . run ( ) ;
20+ rustc ( )
21+ . input ( "baz.rs" )
22+ . extern_ ( "foo" , tmp_dir ( ) . join ( "other/libfoo.rlib" ) )
23+ . library_search_path ( tmp_dir ( ) )
24+ . run ( ) ;
25+ }
You can’t perform that action at this time.
0 commit comments