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

--shared should be a crate directive #360

Closed
pcwalton opened this issue May 11, 2011 · 5 comments
Closed

--shared should be a crate directive #360

pcwalton opened this issue May 11, 2011 · 5 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@pcwalton
Copy link
Contributor

--shared violates the design because every crate is either shared or isn't. This should be a crate directive.

@marijnh
Copy link
Contributor

marijnh commented May 11, 2011

Really? Is there a reason for this? Last time I tried, simply adding a metadata name to rustc made it loadable as a library. I think this is a great property to have -- allow people to include little main procs in their libraries for running them as stand-alone programs.

@marijnh marijnh closed this as completed May 11, 2011
@marijnh marijnh reopened this May 11, 2011
@marijnh
Copy link
Contributor

marijnh commented May 11, 2011

Err. Didn't mean to close.

@pcwalton
Copy link
Contributor Author

Hmm, you have a good point. It would be nice to be able to specify that a crate is default-shared or default-executable in the .rc file however, so that you don't have to remember to include --shared all the time.

@espindola
Copy link

I was thinking of implementing by just checking for main. If it exists, it is a program, if not, it is a library.
Can you expand on what is the use case of having main in a library?

@ghost ghost assigned espindola Jun 21, 2011
@espindola
Copy link

OK, looks like we are already doing the right thing. The use case is:

*) There is a nice stand alone program that does something you would like to have as part of your program.
*) You compile that program with --shared, that produces a library where:
*) the rust main function is mangled as any other function
*) the C main is not linked it
*) In your program you can now call that main function.

keeperofdakeys pushed a commit to keeperofdakeys/rust that referenced this issue Dec 12, 2017
dlrobertson pushed a commit to dlrobertson/rust that referenced this issue Nov 29, 2018
…y-and-privacy

Fix grammar in the "Visibility and Privacy" section
Aaron1011 pushed a commit to Aaron1011/rust that referenced this issue Oct 26, 2020
…2529c0

Bump gimli from `8f47f31` to `e2529c0`
ZuseZ4 pushed a commit to EnzymeAD/rust that referenced this issue Mar 7, 2023
* Handle LLVM 13 release

* Bump for LLVM 14
calebzulawski added a commit to calebzulawski/rust that referenced this issue Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants