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

bootstrap: Link LLVM as a dylib with ThinLTO (take 2) #57286

Merged
merged 5 commits into from
Jan 6, 2019

Conversation

alexcrichton
Copy link
Member

When building a distributed compiler on Linux where we use ThinLTO to
create the LLVM shared object this commit switches the compiler to
dynamically linking that LLVM artifact instead of statically linking to
LLVM. The primary goal here is to reduce CI compile times, avoiding two+
ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll
reuse the one ThinLTO step done by LLVM's build itself.

Lots of discussion about this change can be found here and down. A
perf run will show whether this is worth it or not!


This PR previously landed in #56944, caused #57111, and was reverted in #57116. I've added one more commit here which should fix the breakage that we saw.

When building a distributed compiler on Linux where we use ThinLTO to
create the LLVM shared object this commit switches the compiler to
dynamically linking that LLVM artifact instead of statically linking to
LLVM. The primary goal here is to reduce CI compile times, avoiding two+
ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll
reuse the one ThinLTO step done by LLVM's build itself.

Lots of discussion about this change can be found [here] and down. A
perf run will show whether this is worth it or not!

[here]: rust-lang#53245 (comment)
It's only meant for rustc, so we should only install it once!
@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2019
@alexcrichton alexcrichton mentioned this pull request Jan 2, 2019
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 3, 2019

📌 Commit 71fed3a has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 3, 2019
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jan 3, 2019
…atsakis

bootstrap: Link LLVM as a dylib with ThinLTO (take 2)

When building a distributed compiler on Linux where we use ThinLTO to
create the LLVM shared object this commit switches the compiler to
dynamically linking that LLVM artifact instead of statically linking to
LLVM. The primary goal here is to reduce CI compile times, avoiding two+
ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll
reuse the one ThinLTO step done by LLVM's build itself.

Lots of discussion about this change can be found [here] and down. A
perf run will show whether this is worth it or not!

[here]: rust-lang#53245 (comment)

---

This PR previously landed in rust-lang#56944, caused rust-lang#57111, and was reverted in rust-lang#57116. I've added one more commit here which should fix the breakage that we saw.
@bors
Copy link
Contributor

bors commented Jan 6, 2019

⌛ Testing commit 71fed3a with merge 3ad234f...

bors added a commit that referenced this pull request Jan 6, 2019
bootstrap: Link LLVM as a dylib with ThinLTO (take 2)

When building a distributed compiler on Linux where we use ThinLTO to
create the LLVM shared object this commit switches the compiler to
dynamically linking that LLVM artifact instead of statically linking to
LLVM. The primary goal here is to reduce CI compile times, avoiding two+
ThinLTO builds of all of LLVM. By linking dynamically to LLVM we'll
reuse the one ThinLTO step done by LLVM's build itself.

Lots of discussion about this change can be found [here] and down. A
perf run will show whether this is worth it or not!

[here]: #53245 (comment)

---

This PR previously landed in #56944, caused #57111, and was reverted in #57116. I've added one more commit here which should fix the breakage that we saw.
@bors
Copy link
Contributor

bors commented Jan 6, 2019

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 3ad234f to master...

@bors bors merged commit 71fed3a into rust-lang:master Jan 6, 2019
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 7, 2019
This commit is intended on fixing a regression from rust-lang#57286 where the
distributed LLVM shared library unfortunately depends on a dynamic copy
of libstdc++, meaning we're no longer as binary compatible as we
thought! This tweaks the build of LLVM as out distribution is slightly
different now, and is hoped to fix the issue.

Closes rust-lang#57426
bors added a commit that referenced this pull request Jan 7, 2019
Build LLVM with -static-libstdc++ on dist builds

This commit is intended on fixing a regression from #57286 where the
distributed LLVM shared library unfortunately depends on a dynamic copy
of libstdc++, meaning we're no longer as binary compatible as we
thought! This tweaks the build of LLVM as out distribution is slightly
different now, and is hoped to fix the issue.

Closes #57426
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 8, 2019
This commit is intended on fixing a regression from rust-lang#57286 where the
distributed LLVM shared library unfortunately depends on a dynamic copy
of libstdc++, meaning we're no longer as binary compatible as we
thought! This tweaks the build of LLVM as out distribution is slightly
different now, and is hoped to fix the issue.

Closes rust-lang#57426
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Jan 8, 2019
This commit is intended on fixing a regression from rust-lang#57286 where the
distributed LLVM shared library unfortunately depends on a dynamic copy
of libstdc++, meaning we're no longer as binary compatible as we
thought! This tweaks the build of LLVM as out distribution is slightly
different now, and is hoped to fix the issue.

Closes rust-lang#57426
bors added a commit that referenced this pull request Jan 8, 2019
Build LLVM with -static-libstdc++ on dist builds

This commit is intended on fixing a regression from #57286 where the
distributed LLVM shared library unfortunately depends on a dynamic copy
of libstdc++, meaning we're no longer as binary compatible as we
thought! This tweaks the build of LLVM as out distribution is slightly
different now, and is hoped to fix the issue.

Closes #57426
@alexcrichton alexcrichton deleted the less-thin-2-2 branch March 12, 2019 20:26
@tmandry
Copy link
Member

tmandry commented Nov 27, 2019

@alexcrichton was there ever a perf run to see the impact on compiler performance?

I ask because we've seen as much as a 10-20% improvement from linking LLVM statically to clang. (cc @petrhosek)

I expect that something that large would have been noticed in the release perf run, but maybe there is a potential win here (at least, for someone who wants to build their own toolchain).

@petrhosek
Copy link
Contributor

Would it be possible to provide an option to statically link LLVM even when using ThinLTO? I understand that you may not want to do this because of your CI resource constraints, but in our case it's something we would always want to use since CI resources aren't a problem.

@alexcrichton
Copy link
Member Author

@tmandry hm this is long enough ago I don't quite remember, but might be good to check and see! The main motivation for this was CI time though, since statically linking LLVM to rustc means running all of LLVM through ThinLTO twice, once for it's own dylib and once for rustc, which can be extremely expensive on CI.

@petrhosek yeah definitely, we should definitely support this! We may already given various matrices of configuration options, but if not a PR to add one sounds great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants