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

Make -o do something reasonable or remove it #11056

Closed
brson opened this issue Dec 18, 2013 · 9 comments · Fixed by #12020
Closed

Make -o do something reasonable or remove it #11056

brson opened this issue Dec 18, 2013 · 9 comments · Fixed by #12020
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler
Milestone

Comments

@brson
Copy link
Contributor

brson commented Dec 18, 2013

For libraries we ignore the filename completely. This would seem to imply that the flag should just specify the output directory. Locking in this strange behavior for Rust 1.0 would be unfortunate. Nominating.

@metajack
Copy link
Contributor

We have --out-dir for libraries. Probably it would be could enough to fail the compile if --rlib, --dylib, or --lib appears along with -o.

@brson
Copy link
Contributor Author

brson commented Dec 18, 2013

Sometimes rustc doesn't know whether it's compiling an exe or library until it reads the source code, so simply looking at the command line flags would be insufficient. Sometimes rustc outputs multiple files. My inclination is to always make the naming of the output file up to rustc and remove -o completely.

@thestinger
Copy link
Contributor

Could we replace it with a --name switch to set the library or binary name?

@metajack
Copy link
Contributor

@thestinger Would this override the name part of the crate_id? Ie, binary output would be ${NAME}.exe but library output would be lib${NAME}-${HASH}-${VERSION}.dll?

@thestinger
Copy link
Contributor

Yes, in fact I thought that's already what -o did. It just needs the right switch name.

@brson
Copy link
Contributor Author

brson commented Jan 9, 2014

or maybe --crate_id

@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2014

Okay, so the task here is to remove -o and replace the one case where it currently works with some cmdline option for overriding the crate_id, as discussed above.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2014

Accepted for P-backcompat-libs (aka tools)

@Florob
Copy link
Contributor

Florob commented Feb 3, 2014

FWIW, I'd love to have an option to specify the actual file name for libraries. My particular use-case is for writing Lua modules, which need to be a shared libraries with the module name as basename (i.e. having a "lib" prefix, including the hash, and including a version is undesirable).

bors added a commit that referenced this issue Feb 6, 2014
This commit removes the -c, --emit-llvm, -s, --rlib, --dylib, --staticlib,
--lib, and --bin flags from rustc, adding the following flags:

* --emit=[asm,ir,bc,obj,link]
* --crate-type=[dylib,rlib,staticlib,bin,lib]

The -o option has also been redefined to be used for *all* flavors of outputs.
This means that we no longer ignore it for libraries. The --out-dir remains the
same as before.

The new logic for files that rustc emits is as follows:

1. Output types are dictated by the --emit flag. The default value is
   --emit=link, and this option can be passed multiple times and have all options
   stacked on one another.
2. Crate types are dictated by the --crate-type flag and the #[crate_type]
   attribute. The flags can be passed many times and stack with the crate
   attribute.
3. If the -o flag is specified, and only one output type is specified, the
   output will be emitted at this location. If more than one output type is
   specified, then the filename of -o is ignored, and all output goes in the
   directory that -o specifies. The -o option always ignores the --out-dir
   option.
4. If the --out-dir flag is specified, all output goes in this directory.
5. If -o and --out-dir are both not present, all output goes in the directory of
   the crate file.
6. When multiple output types are specified, the filestem of all output is the
   same as the name of the CrateId (derived from a crate attribute or from the
   filestem of the crate file).

Closes #7791
Closes #11056
Closes #11667
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 14, 2023
…llogiq

`let_and_return`: lint 'static lifetimes, don't lint borrows in closures

Fixes rust-lang#11056

Now also ignores functions returning `'static` lifetimes, since I noticed the `stdin.lock()` example was still being linted but doesn't need to be since rust-lang#93965

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-driver Area: rustc_driver that ties everything together into the `rustc` compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants