Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Add unity build support for some targets #9125

Merged
merged 4 commits into from
Jun 1, 2020
Merged

Conversation

huangminghuang
Copy link
Contributor

Change Description

This PR add support to enable cmake unity build for certain targets. Enabling unity build can significantly improve the build time for the project. However, it's not possible enable it globally with CMAKE_UNITY_BUILD because some of the libraries/submodules requires modification to make it work. This PR uses ENABLE_UNITY_BUILD flag to enable unity build for the targets don't have problem with it.

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

@heifner
Copy link
Contributor

heifner commented May 21, 2020

@spoonincode do you see any issues with providing this option?

Up until cmake version 3.17.*,  The unity build support by cmake does not work well in combination with the production of compile_commands.json.
This commit allows the  short-term workaround: running cmake twice: once with ENABLE_UNITY_BUILD=OFF to generate compile_commands.json
for LSP servers, clang-tidy / clangd, etc, and then again with ENABLE_UNITY_BUILD=ON to build the project.
@spoonincode
Copy link
Contributor

I played with it some and I guess not. It does feel a little hokey needing to sprinkle these all through various cmakefiles. Unless someone is actively using the feature it risks becoming wrong/broken like a handful of other cmake stuff we have sprinkled about still.

@huangminghuang
Copy link
Contributor Author

I played with it some and I guess not. It does feel a little hokey needing to sprinkle these all through various cmakefiles. Unless someone is actively using the feature it risks becoming wrong/broken like a handful of other cmake stuff we have sprinkled about still.

IMO, the option should be enabled by default for CI build. This is build times I got from comparing the CI build with the ENABLE_UNITY_BUILD ON and OFF.

ENABLE_UNITY_BUILD=OFF ENABLE_UNITY_BUILD=ON
Amazon Linux 26.35 18.15
CentOS 28.03 17.34
macOS. 23.14 18.34
Ubuntu 16.04 27.58 17.10
Ubuntu 18.04 24.38 15.19
Docker 21.59 16.45

Personally, I don't use build script in the EOS repo. I prefer to supply the cmake options I need and use ninja. Without unity build, using "ninja" for clean build without limiting jobs would freeze my Mac with 32 GB ram, I need to explicit limit the jobs to 4 to avoid it. With unity build, I don't need to specify the number of jobs and it also compiles a lot faster. I can even go as far as 18 jobs on my 8-core machine without any issues.

@@ -118,7 +118,7 @@ namespace fc { namespace crypto {
if (which == 0) {
using default_type = storage_type::template type_at<0>;
return to_wif(_storage.template get<default_type>(), yield);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

stray space at end of line

@spoonincode
Copy link
Contributor

Should we be keeping CI & build script in parity?

@huangminghuang huangminghuang merged commit a8c169f into develop Jun 1, 2020
@huangminghuang huangminghuang deleted the unity-build branch June 3, 2020 19:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants