Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc injects main in all outputs when specifying “bin” crate type #37947

Closed
jethrogb opened this issue Nov 23, 2016 · 1 comment
Closed

Comments

@jethrogb
Copy link
Contributor

jethrogb commented Nov 23, 2016

See source code for a.rs & b.rs at the end of this issue.

expected behavior

I'd expect this:

$ rustc --crate-type=bin a.rs
$ rustc --crate-type=rlib a.rs

to generate the same output as:

$ rustc --crate-type=bin,rlib a.rs

actual behavior

But it does not:

$ rustc --crate-type=rlib a.rs
$ rustc b.rs --extern a=liba.rlib

is all peachy, versus:

$ rustc --crate-type=bin,rlib a.rs
$ rustc b.rs --extern a=liba.rlib
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" ...
  = note: /tmp/rlibtest/liba.rlib(a.0.o): In function `main':
a.cgu-0.rs:(.text.main+0x0): multiple definition of `main'
b.0.o:b.cgu-0.rs:(.text.main+0x0): first defined here
collect2: error: ld returned 1 exit status


error: aborting due to previous error

source files

// a.rs
pub fn a_fn() {
	panic!("a_fn")
}

fn main() {
	a_fn()
}
// b.rs
extern crate a;

fn main() {
	a::a_fn()
}
@jethrogb jethrogb changed the title rustc injects main in all outputs when specifying bin crate type rustc injects main in all outputs when specifying “bin” crate type Nov 23, 2016
@Mark-Simulacrum
Copy link
Member

Closing in favor of #22183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants