Skip to content

Commit 712874e

Browse files
committed
rollup merge of #22051: nagisa/main-emission
Fixes #21813
2 parents 91fc9f3 + 61b4823 commit 712874e

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/librustc/middle/entry.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ pub fn find_entry_point(session: &Session, ast_map: &ast_map::Map) {
5050
let any_exe = session.crate_types.borrow().iter().any(|ty| {
5151
*ty == config::CrateTypeExecutable
5252
});
53-
if !any_exe {
53+
let emit_link = session.opts.output_types.iter().any(|ty| {
54+
*ty == config::OutputTypeExe
55+
});
56+
if !any_exe || !emit_link {
5457
// No need to find a main function
5558
return
5659
}

src/librustc/session/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub struct Options {
8383
pub debuginfo: DebugInfoLevel,
8484
pub lint_opts: Vec<(String, lint::Level)>,
8585
pub describe_lints: bool,
86-
pub output_types: Vec<OutputType> ,
86+
pub output_types: Vec<OutputType>,
8787
// This was mutable for rustpkg, which updates search paths based on the
8888
// parsed code. It remains mutable in case its replacements wants to use
8989
// this.

src/test/run-make/empty-file/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-include ../tools.mk
2+
3+
all:
4+
$(RUSTC) --emit=asm,llvm-bc,llvm-ir,obj,dep-info empty.rs
5+
$(RUSTC) --emit=link --crate-type=rlib,dylib,staticlib empty.rs

src/test/run-make/empty-file/empty.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)