-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #92933 - bjorn3:no_bin_lib_mixing, r=estebank
Deny mixing bin crate type with lib crate types The produced library would get a main shim too which conflicts with the main shim of the executable linking the library. ``` $ cat > main1.rs <<EOF fn main() {} pub fn bar() {} EOF $ cat > main2.rs <<EOF extern crate main1; fn main() { main1::bar(); } EOF $ rustc --crate-type bin --crate-type lib main1.rs $ rustc -L. main2.rs error: linking with `cc` failed: exit status: 1 [...] = note: /usr/bin/ld: /tmp/crate_bin_lib/libmain1.rlib(main1.main1.707747aa-cgu.0.rcgu.o): in function `main': main1.707747aa-cgu.0:(.text.main+0x0): multiple definition of `main'; main2.main2.02a148fe-cgu.0.rcgu.o:main2.02a148fe-cgu.0:(.text.main+0x0): first defined here collect2: error: ld returned 1 exit status ```
- Loading branch information
Showing
6 changed files
with
12 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) foo-bar.rs | ||
$(RUSTC) foo-bar.rs --crate-type bin | ||
[ -f $(TMPDIR)/$(call BIN,foo-bar) ] | ||
$(RUSTC) foo-bar.rs --crate-type lib | ||
[ -f $(TMPDIR)/libfoo_bar.rlib ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
#![crate_type = "lib"] | ||
#![crate_type = "bin"] | ||
|
||
fn main() {} |