diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-10 08:41:44 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-10 08:41:44 -0800 |
| commit | 712874ef11b644e9fbba63a149b38ceadf1e34c7 (patch) | |
| tree | 71f14be4c00fe181012a90ff85465dd41ff593db | |
| parent | 91fc9f3f0e36cf8d8d16dd44b302babf03f82f47 (diff) | |
| parent | 61b4823b77ffaf39e0825314d749eac3a115764d (diff) | |
| download | rust-712874ef11b644e9fbba63a149b38ceadf1e34c7.tar.gz rust-712874ef11b644e9fbba63a149b38ceadf1e34c7.zip | |
rollup merge of #22051: nagisa/main-emission
Fixes #21813
| -rw-r--r-- | src/librustc/middle/entry.rs | 5 | ||||
| -rw-r--r-- | src/librustc/session/config.rs | 2 | ||||
| -rw-r--r-- | src/test/run-make/empty-file/Makefile | 5 | ||||
| -rw-r--r-- | src/test/run-make/empty-file/empty.rs | 0 |
4 files changed, 10 insertions, 2 deletions
diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 0ce9db1c80f..b5904f23ef3 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -50,7 +50,10 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) { let any_exe = session.crate_types.borrow().iter().any(|ty| { *ty == config::CrateTypeExecutable }); - if !any_exe { + let emit_link = session.opts.output_types.iter().any(|ty| { + *ty == config::OutputTypeExe + }); + if !any_exe || !emit_link { // No need to find a main function return } diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index cd664b7388c..7ee8401655c 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -83,7 +83,7 @@ pub struct Options { pub debuginfo: DebugInfoLevel, pub lint_opts: Vec<(String, lint::Level)>, pub describe_lints: bool, - pub output_types: Vec<OutputType> , + pub output_types: Vec<OutputType>, // This was mutable for rustpkg, which updates search paths based on the // parsed code. It remains mutable in case its replacements wants to use // this. diff --git a/src/test/run-make/empty-file/Makefile b/src/test/run-make/empty-file/Makefile new file mode 100644 index 00000000000..f55a2cc3bb1 --- /dev/null +++ b/src/test/run-make/empty-file/Makefile @@ -0,0 +1,5 @@ +-include ../tools.mk + +all: + $(RUSTC) --emit=asm,llvm-bc,llvm-ir,obj,dep-info empty.rs + $(RUSTC) --emit=link --crate-type=rlib,dylib,staticlib empty.rs diff --git a/src/test/run-make/empty-file/empty.rs b/src/test/run-make/empty-file/empty.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/src/test/run-make/empty-file/empty.rs |
