File tree 13 files changed +78
-57
lines changed
src/tools/run-make-support/src
windows-binary-no-external-deps
13 files changed +78
-57
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ impl LlvmReadobj {
42
42
self
43
43
}
44
44
45
+ /// Pass `--coff-imports` to display the Windows DLL imports
46
+ pub fn coff_imports ( & mut self ) -> & mut Self {
47
+ self . cmd . arg ( "--coff-imports" ) ;
48
+ self
49
+ }
50
+
45
51
/// Get the [`Output`][::std::process::Output] of the finished process.
46
52
#[ track_caller]
47
53
pub fn command_output ( & mut self ) -> :: std:: process:: Output {
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //@ only-windows
2
+
3
+ // Ensure that we aren't relying on any non-system DLLs when compiling and running
4
+ // a "hello world" application by setting `PATH` to `C:\Windows\System32`.
5
+
6
+ use run_make_support:: { run, rustc} ;
7
+ use std:: env;
8
+ use std:: path:: PathBuf ;
9
+
10
+ fn main ( ) {
11
+ let windows_dir = env:: var ( "SystemRoot" ) . unwrap ( ) ;
12
+ let system32: PathBuf = [ & windows_dir, "System32" ] . iter ( ) . collect ( ) ;
13
+ rustc ( ) . input ( "hello.rs" ) . env ( "PATH" , system32) . run ( ) ;
14
+ run ( "hello" ) ;
15
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //@ only-windows
2
+ //@ needs-rust-lld
3
+
4
+ use run_make_support:: rustc;
5
+
6
+ fn main ( ) {
7
+ // Ensure that LLD can link when an .rlib contains a synthetic object
8
+ // file referencing exported or used symbols.
9
+ rustc ( ) . input ( "foo.rs" ) . arg ( "-Clinker=rust-lld" ) . run ( ) ;
10
+
11
+ // Ensure that LLD can link when /WHOLEARCHIVE: is used with an .rlib.
12
+ // Previously, lib.rmeta was not marked as (trivially) SAFESEH-aware.
13
+ rustc ( ) . input ( "baz.rs" ) . run ( ) ;
14
+ rustc ( ) . input ( "bar.rs" ) . arg ( "-Clinker=rust-lld" ) . link_arg ( "/WHOLEARCHIVE:libbaz.rlib" ) . run ( ) ;
15
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //@ only-windows
2
+
3
+ use run_make_support:: { run, rustc, tmp_dir} ;
4
+
5
+ // On Windows `Command` uses `CreateProcessW` to run a new process.
6
+ // However, in the past std used to not pass in the application name, leaving
7
+ // `CreateProcessW` to use heuristics to guess the intended name from the
8
+ // command line string. Sometimes this could go very wrong.
9
+ // E.g. in Rust 1.0 `Command::new("foo").arg("bar").spawn()` will try to launch
10
+ // `foo bar.exe` if foo.exe does not exist. Which is clearly not desired.
11
+
12
+ fn main ( ) {
13
+ let out_dir = tmp_dir ( ) ;
14
+ rustc ( ) . input ( "hello.rs" ) . output ( out_dir. join ( "hopefullydoesntexist bar.exe" ) ) . run ( ) ;
15
+ rustc ( ) . input ( "spawn.rs" ) . run ( ) ;
16
+ run ( "spawn" ) ;
17
+ }
Original file line number Diff line number Diff line change @@ -3,10 +3,8 @@ use std::process::Command;
3
3
4
4
fn main ( ) {
5
5
// Make sure it doesn't try to run "hopefullydoesntexist bar.exe".
6
- assert_eq ! ( Command :: new( "hopefullydoesntexist" )
7
- . arg( "bar" )
8
- . spawn( )
9
- . unwrap_err( )
10
- . kind( ) ,
11
- ErrorKind :: NotFound ) ;
6
+ assert_eq ! (
7
+ Command :: new( "hopefullydoesntexist" ) . arg( "bar" ) . spawn( ) . unwrap_err( ) . kind( ) ,
8
+ ErrorKind :: NotFound
9
+ )
12
10
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ //@ ignore-cross-compile
2
+
3
+ use run_make_support:: rustc;
4
+
5
+ fn main ( ) {
6
+ rustc ( ) . input ( "windows.rs" ) . run ( ) ;
7
+ rustc ( ) . input ( "console.rs" ) . run ( ) ;
8
+ }
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ //@ only-msvc
2
+
3
+ // Tests that WS2_32.dll is not unnecessarily linked, see issue #85441
4
+
5
+ use run_make_support:: { llvm_readobj, rustc, tmp_dir} ;
6
+
7
+ fn main ( ) {
8
+ rustc ( ) . input ( "empty.rs" ) . run ( ) ;
9
+ let empty = tmp_dir ( ) . join ( "empty.exe" ) ;
10
+ let output = llvm_readobj ( ) . input ( empty) . coff_imports ( ) . run ( ) ;
11
+ let output = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
12
+ assert ! ( !output. to_ascii_uppercase( ) . contains( "WS2_32.DLL" ) ) ;
13
+ }
You can’t perform that action at this time.
0 commit comments