Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptrans: Treat generics like regular functions, not like #[inline] function, during CGU partitioning #38944
Conversation
michaelwoerister
added some commits
Jan 6, 2017
rust-highfive
assigned
nikomatsakis
Jan 9, 2017
This comment has been minimized.
This comment has been minimized.
|
The first commit (Disambiguate generic instance symbol names by instantiating crate) is very unexpected to me. AFAIK, we currently use comdat linkage to resolve these collisions, which also allows the linker to combine identical instantiation from multiple crates. And except for the mingw linker limitations, I'm not aware of any problems with that. Yet this commit seems to be a complete departure from that strategy. Could you elaborate on the rationale for that change? |
This comment has been minimized.
This comment has been minimized.
Sure. We've actually used COMDAT sections/WeakODR linkage only for a brief period (between April and June, I think) and then switched to internal copies for all generic instances. Internal linkage has allowed us to use the same symbol names everywhere without getting naming conflicts. The main reason for switching was the MinGW issue but also that WeakODR functions would optimize a lot worse in LLVM. For some reason, LLVM doesn't seem to really trust the "one definition rule". I think it's a worthwhile goal to get by without COMDAT sections, just to avoid some complexity. |
This comment has been minimized.
This comment has been minimized.
|
Interesting! But I still wonder why the current strategy needs to change at all — is this in preparation of trying to reuse instantiations from upstream crates? |
This comment has been minimized.
This comment has been minimized.
|
No, it's primarily to make incremental compilation more effective. Cross-CGU inlining is very bad for re-usability. |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
eddyb
reviewed
Jan 10, 2017
| @@ -302,10 +302,13 @@ impl<'a> CrateLoader<'a> { | |||
| crate_root.def_path_table.decode(&metadata) | |||
| }); | |||
|
|
|||
| let exported_symbols = crate_root.exported_symbols.decode(&metadata).collect(); | |||
This comment has been minimized.
This comment has been minimized.
eddyb
Jan 10, 2017
Member
Huh, I thought I had removed this... At least it's by DefIndex not by symbol name.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 11, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
OS/X linker segfault cc #38878 |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 13, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 13, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors: retry
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 14, 2017
This comment has been minimized.
This comment has been minimized.
|
|
michaelwoerister commentedJan 9, 2017
This PR makes generics be treated just like regular functions during CGU partitioning:
#[inline]-- which causes a private copy of the function to be placed in every referencing codegen unit.This has the following effects:
This partitioning scheme is particularly good for incremental compilation as it drastically reduces the number of false positives during codegen unit invalidation.
I'd love to have a benchmark suite for estimating the effect on runtime performance for changes like this one.
r? @nikomatsakis
cc @rust-lang/compiler