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

Two adjustments to rustc for cargo #15686

Merged
merged 2 commits into from
Jul 19, 2014
Merged

Conversation

alexcrichton
Copy link
Member

The first is to require that #[crate_name] and --crate-name always match (if both are specified). The second is to fix parallel compilation in cargo by mixing in -C extra-filename into the temporary outputs of the compiler.

let msg = format!("--crate-name and #[crate_name] \
are required to match, but `{}` \
!= `{}`", s, name);
sess.span_err(attr.span, msg.as_slice());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to update the comment a few lines above (lines 558-560), as it still claims that the crate name from the command-line is favored.

@lilyball
Copy link
Contributor

Travis failure says run-pass/crate-name-attr-used.rs failed, because rustc provided --crate-name crate-name-attr-used when compiling, which conflicted with the #![crate_name = "test"] attribute.

I'm also not really clear what the motivation is for requiring --crate-name and #[crate_name] to be in sync, though I assume you have one or you wouldn't have submitted this.

Anyway, r=me with the test fixed and the comment updated.

Part of the original discussions around the `--crate-name` flag brought up that
mass confusion can arise when the flag specifies a different name than is
contained in the crate.

The current primary use case of the `--crate-name` flag is through cargo and
not requiring a `#[crate_name]` attribute, but if the `#[crate_name]` attribute
is specified it will likely go awry when the two names deviate from one another.
This commit requires that if both are provided they both match to prevent this
confusion.
When invoking the compiler in parallel, the intermediate output of the object
files and bytecode can stomp over one another if two crates with the same name
are being compiled.

The output file is already being disambiguated with `-C extra-filename`, so this
commit alters the naming of the temporary files to also mix in the extra
filename to ensure that file names don't clash.
bors added a commit that referenced this pull request Jul 19, 2014
The first is to require that `#[crate_name]` and `--crate-name` always match (if both are specified). The second is to fix parallel compilation in cargo by mixing in `-C extra-filename` into the temporary outputs of the compiler.
@bors bors closed this Jul 19, 2014
@bors bors merged commit 82fb85a into rust-lang:master Jul 19, 2014
@alexcrichton alexcrichton deleted the same-crate-name branch July 22, 2014 15:13
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 13, 2023
Only run tests on linux in pull requests

There is little gain from running them on all platforms, they should almost never fail if the linux one pass and if they do, bors will catch it still.
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 this pull request may close these issues.

3 participants