-
Notifications
You must be signed in to change notification settings - Fork 412
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
Supply crate metadata to rustc and uniqueify --extern'ed crates #47
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c948734
Unique-ify --extern crates by adding a path based hash
acmcarther b5eb022
Wip
acmcarther b2735ba
Hash differently
acmcarther 22682b6
Minor cleanups: add test, add comment
acmcarther 11160dc
Fix test (in a very unsatisfying way)
acmcarther 9ec8568
Fix the other test as well
acmcarther a5fa874
Final nit fixes
acmcarther 0fa23e1
use the same hash
acmcarther e74c5c4
More nits
acmcarther a0223ab
Move conflicting_deps into test
acmcarther de698c7
merge and fix
acmcarther 87b5407
Fix test
acmcarther 850310b
Remove unused fn
acmcarther File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"//rust:rust.bzl", | ||
"rust_library", | ||
"rust_test", | ||
) | ||
|
||
rust_library( | ||
name = "conflicting_deps", | ||
srcs = ["src/lib.rs"], | ||
deps = [ | ||
"//test/conflicting_deps/first_crate:example_name_conflict" | ||
], | ||
) | ||
|
||
rust_test( | ||
name = "conflicting_deps_test", | ||
deps = [ | ||
":conflicting_deps", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"//rust:rust.bzl", | ||
"rust_library", | ||
) | ||
|
||
rust_library( | ||
name = "example_name_conflict", | ||
srcs = ["src/lib.rs"], | ||
deps = [ | ||
"//test/conflicting_deps/first_crate/second_crate:example_name_conflict" | ||
], | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
load( | ||
"//rust:rust.bzl", | ||
"rust_library", | ||
) | ||
|
||
rust_library( | ||
name = "example_name_conflict", | ||
srcs = ["src/lib.rs"], | ||
deps = [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// This crate's name conflicts with its dependent but this should work OK. | ||
|
||
pub fn example_conflicting_symbol() -> String { | ||
"[from second_crate]".to_owned() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This crate's name conflicts with its dependency but this should work OK. | ||
|
||
extern crate example_name_conflict; | ||
|
||
pub fn example_conflicting_symbol() -> String { | ||
format!( | ||
"[from first_crate] -> {}", | ||
example_name_conflict::example_conflicting_symbol() | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
extern crate example_name_conflict; | ||
|
||
// This crate depends on a pair of dependencies (transitively) that have the same name. This should | ||
// work OK. | ||
|
||
pub fn example_conflicting_symbol() -> String { | ||
format!( | ||
"[from main lib] -> {}", | ||
example_name_conflict::example_conflicting_symbol() | ||
) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn symbols_all_resolve_correctly() { | ||
assert_eq!( | ||
::example_conflicting_symbol(), | ||
"[from main lib] -> [from first_crate] -> [from second_crate]".to_owned() | ||
); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfarrugi Can you take another look at this PR, specifically this line? I again changed the way the uniquifying hash is generated as the available information changed.
Before: hash output rlib name
Now: hash full lib.rs path (since the rlib name contains the hash in it)
Can you see any downsides in this approach or perhaps have a better thing to hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can think of the degenerate case where multiple targets use the same lib.rs, so maybe hash(name, lib.rs path) or Label? Though I don't recall what info is available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the name is useful as a component as a hash collision will only matter if the crate names are already the same...
I don't think changing this function later will be breaking or onerous, so I'll go ahead and get this submitted.