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 {
93
93
env_var ( "SOURCE_ROOT" ) . into ( )
94
94
}
95
95
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
+
96
107
/// Construct the static library name based on the platform.
97
108
pub fn static_lib_name ( name : & str ) -> String {
98
109
// See tools.mk (irrelevant lines omitted):
@@ -114,7 +125,11 @@ pub fn static_lib_name(name: &str) -> String {
114
125
// ```
115
126
assert ! ( !name. contains( char :: is_whitespace) , "static library name cannot contain whitespace" ) ;
116
127
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
+ }
118
133
}
119
134
120
135
/// Construct the dynamic library name based on the platform.
@@ -161,7 +176,11 @@ pub fn rust_lib_name(name: &str) -> String {
161
176
162
177
/// Construct the binary name based on platform.
163
178
pub 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
+ }
165
184
}
166
185
167
186
/// 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
228
228
run-make/symbol-mangling-hashed/Makefile
229
229
run-make/symbol-visibility/Makefile
230
230
run-make/symbols-include-type-name/Makefile
231
- run-make/symlinked-extern/Makefile
232
231
run-make/symlinked-libraries/Makefile
233
232
run-make/symlinked-rlib/Makefile
234
233
run-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