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

--dep-info doesn't reflect real output filename when using -c or --emit-llvm #11667

Closed
yuriks opened this issue Jan 19, 2014 · 2 comments · Fixed by #12020
Closed

--dep-info doesn't reflect real output filename when using -c or --emit-llvm #11667

yuriks opened this issue Jan 19, 2014 · 2 comments · Fixed by #12020

Comments

@yuriks
Copy link
Contributor

yuriks commented Jan 19, 2014

Usually, --dep-info would be used to generate dependency information to be included in a Makefile. However, when using the -c or --emit-llvm flags, along with --out-dir, the generated info doesn't have the correct names for the output files. When -c is used to compile foo.rs, it's output as foo.o, and when --emit-llvm is used, as foo.bc. On both cases the dependency info lists the full library name as it would've been output if none of the option were given. For example:

rustc --emit-llvm --staticlib --out-dir obj/ -L obj/ --dep-info obj/main.d src/main.rs

Outputs obj/main.bc, but obj/main.d has the following contents:

obj/libmain-66af34bf-0.0.a: src/main.rs src/efi.rs

The dependency info should be change to reflect the name of the files actually being output by the compiler for the given command.

EDIT: Realized it also doesn't track any external modules used by the crate as dependencies. (In this case libcore-2e829c2f-0.0.rlib and libextensions-d5bbcef2-0.0.so.) This might be on purpose, but doesn't seem ideal to me.

@alexcrichton
Copy link
Member

I imagine that the restructuring of #7791 will address much of this. Right now dep-info doesn't track any dependencies, and I think that's more of a job for a package manager rather than rustc itself. I don't know what the makefile target dependency would be named. In theory it could be libstd-...rlib, but that doesn't actually correspond to anything because you'd then have to make a target saying that that points to (and things go on...)

@SiegeLord
Copy link
Contributor

I don't know what the makefile target dependency would be named. In theory it could be libstd-...rlib, but that doesn't actually correspond to anything because you'd then have to make a target saying that that points to (and things go on...)

This also doesn't work if the dependency is also built as part of the build process. E.g. a library might have some examples which depend on the library being built. --dep-info will not be able to return that dependency because the library wasn't built yet and therefore the file doesn't exist yet.

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
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