Skip to content

main entry missing if crate_type = "bin" and "lib" is both given #13337

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

Closed
klutzy opened this issue Apr 5, 2014 · 2 comments
Closed

main entry missing if crate_type = "bin" and "lib" is both given #13337

klutzy opened this issue Apr 5, 2014 · 2 comments

Comments

@klutzy
Copy link
Contributor

klutzy commented Apr 5, 2014

#![crate_type = "lib"]
#![crate_type = "bin"]

fn main() {
    println!("hello world");
}
error: linking with `cc` failed: exit code: 1
...
note: /usr/lib/gcc/i486-linux-gnu/4.7/../../../i386-linux-gnu/crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status

Reproduced on linux32 and win32.

@alexcrichton
Copy link
Member

This is mildly expected, and I would likely expect a compiler error to be generated rather than attempting to continue compilation.

Codegen is tweaked slightly depending on whether you're compiling an executable or a library.

@larsbergstrom
Copy link
Contributor

Aha, we've been running into this with our attempts to create an embedding version of Servo. Basically, we'd like to compile our main crate both into a binary and into a library that we can use for embedding hosts (e.g., Chromium). I guess we can do this as two steps instead.

CC @zmike

bors added a commit that referenced this issue May 5, 2014
This has long since not been too relevant since the introduction of many crate
type outputs. This commit removes the flag entirely, adjusting all logic to do
the most reasonable thing when building both a library and an executable.

Closes #13337
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

Successfully merging a pull request may close this issue.

3 participants