[cfe-dev] JumboSupport: making unity builds easier in Clang

Hans Wennborg via cfe-dev cfe-dev at lists.llvm.org
Tue May 22 05:04:04 PDT 2018


Hi Jens,

On Fri, May 18, 2018 at 9:17 AM, Jens Widell via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
> Hi all,
>
> I'd like to summarize this thread (so far) and try to agree on a way forward.
>
> First, we had an interesting discussion on unity building in general,
> or perhaps rather other, more "modern", ways to achieve the same or
> similar effects. In the short term, this discussion is mostly
> academic; the fact is that the Chromium project already has a unity
> build configuration as described at the start of this thread, and it's
> in "production" use. We're proposing these changes to Clang to reduce
> an existing maintenance cost.
>
> Second, we've had two principal proposed ways to support unity builds in Clang:
>
> 1) The "custom" but ultimately pretty trivial, in terms of changes to
> the core Clang code, way implemented by my proof-of-concept patch.
>
> 2) An thus-far nowhere implemented way built on top of Clang's support
> for C++ modules.
>
> I'm not qualified to tell how much work (2) would be, how big the
> changes to Clang would be, or how much of a maintenance burden this
> would be on the Clang project, but it sounds more complicated to me,
> so I'm inclined to think that (2) > (1) in all of those metrics.
>
> I will also not be able to implement (2), because of the inevitably
> limited nature of time.
>
> So, if I don't receive push-back here (e.g. someone committing to work
> on (2)), I'll proceed to submit patches for (1).

My concern is whether (1) would carry its own weight. Even though it's
fairly simple, would it be useful enough for projects besides Chromium
that it warrants the complexity of having it in the tree? Are there
other problems it would need to handle, like explicit template
instantiation declarations and definitions that weren't intended to
end up in the same translation unit.. I feel there could be lots of
problems.

But if it's possible to implement this in a very simple and clean way
(that also handles static functions and variables the same as
anonymous namespaces) that works well for many projects? If so it
seems hard to argue against it.

For Chromium, part of me hopes we could do something better though.
Maybe using proper modules, or maybe just by restructuring parts of
Blink.



More information about the cfe-dev mailing list