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

Fix Issue 18362 - Try to enable lto for all dmd builds #492

Merged
merged 1 commit into from Jan 13, 2022

Conversation

maxhaton
Copy link
Member

LTO isn't always plain sailing but let's try it.

image

A box & whisker plot of phobos test suite build times vs. flags

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @maxhaton!

Bugzilla references

Auto-close Bugzilla Severity Description
18362 enhancement Build dmd with LTO and PGO

@thewilsonator thewilsonator merged commit 8f9bd83 into dlang:master Jan 13, 2022
@@ -371,6 +371,8 @@ void buildAll(Bits bits, string branch, bool dmdOnly=false)
}
auto hostDMDEnv = " HOST_DC="~hostDMD~" HOST_DMD="~hostDMD;
auto isRelease = " ENABLE_RELEASE=1";
//Enable lto for everything.
auto ltoOption = " ENABLE_LTO=1";
Copy link
Contributor

Choose a reason for hiding this comment

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

@maxhaton: Are you sure this actually works? I don't see ENABLE_LTO being forwarded to build.din https://github.com/dlang/dmd/blob/master/src/posix.mak#L100.

Copy link
Contributor

Choose a reason for hiding this comment

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

GNU make sets ENABLE_LTO=1 as an environment variable which is read by build.d.
So make -f posix.mak ENABLE_LTO=1 works as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm okay, but what about Windows with DigitalMars make? IIRC, there's a difference, and that's why all (?) other vars are forwarded explicitly. No ENABLE_LTO forwarding in https://github.com/dlang/dmd/blob/master/src/win32.mak#L75 either.

Copy link
Contributor

Choose a reason for hiding this comment

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

DM make doesn't seem to forward command line variables. So it needs to be explicitly forwarded in win32.mak

Copy link
Contributor

Choose a reason for hiding this comment

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

@maxhaton
Copy link
Member Author

maxhaton commented Jan 13, 2022 via email

@kinke
Copy link
Contributor

kinke commented Jan 13, 2022

since it makes the build extremely slow

Another way of achieving the same optimization results (more or less) but probably way faster would be to simply compile all of DMD to a single object file, instead of the 3 separate lexer/frontend/backend object files.

@carun
Copy link

carun commented Feb 19, 2022

Hey @maxhaton, how did you generate and plot the graph? Do you use D for that as well? It would be interesting if you could capture the process.

@maxhaton
Copy link
Member Author

Hey @maxhaton, how did you generate and plot the graph? Do you use D for that as well? It would be interesting if you could capture the process.

It was generated with mathematica, the data was collected with my own grubby mitts on the keyboard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants