For example, suppose we have libX target in third_party, with headers in third_party/libX/include/libX/header{A,B}.hheaderA.h:#include "libX/headerB.h"some chromium .cc file:#include "third_party/libX/include/libX/headerA.h"I'd like to rewrite the above to:headerA.h:#include "header_shims/libX/headerB.h"chromium .cc file:#include "header_shims/libX/headerA.h"What do you think?
Now here is an approach I was thinking about. You can call it brave, crazy, or something else. We wouldn't add anything inside third_party to include path. Instead, a code generator would be added to assist with creating shim headers. The shim headers would either simply forward to corresponding system headers when using system library (#include <...>) or be a copy of the bundled header, further rewritten to ensure all #includes have an appropriate prefix in them.
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
This has already been discussed several times in the list I believe, and the conclusion is that the Chromium sources/build should not have to care about distro builds.
In your specific case, all you need is to have shim headers named "third_party/libX/include/libX/headerA.h" that just #include <libX/headerA.h>, and place them in a directory that is custom to your build, and added to the include search path with -I before the Chromium project path.
I thought the purpose of the Chromium files using the full third_party/ path was to be consistent with other headers and compliant with the style guide, where we specify full paths (from the base of the checkout) when possible.
If the goal of your change is to prevent third_party headers from #including the wrong other headers, then I don't see why the Chromium (non-third_party) #includes need rewriting at all -- they work as-is.
And if you're rewriting the third_party files' #includes anyway, why not just rewrite them to look like the full path the Chromium .cc files use? This avoids the need for shim headers entirely.
Here's my concern with shim headers: I live on a operating system with file system performance that is, well, "sub-par" is a nice way to put it. Adding a bunch of additional headers that need to be read/timestamped is not going to help build times, at all.
We are using shim headers, we have options to build with various system libraries. How do you think we got them? They are not officially supported, but they are allowed to be there. Please avoid comments that seem to just mean "I'd rather ignore Linux distros".
If nobody is concerned about using system headers by mistake in that scheme (see my first e-mail for the scenario that makes it break), and there is strong opposition to my plan above (because I'm somewhat concerned about such header mix-up), I could do that.
Anyway, "should" allows justified exceptions I think.
If the goal of your change is to prevent third_party headers from #including the wrong other headers, then I don't see why the Chromium (non-third_party) #includes need rewriting at all -- they work as-is.It may seem they happen to work. However, I have presented a scenario in which that assumption can be broken, and in fact, we do miss third party gyp dependencies from time to time (I've done about 5 CLs fixing these problems myself).
It's quite surprising to me, that it seems there are more concerns about stylistic issues, i.e. how our #includes look like, than for correctness issue, i.e. possibility of building using headers that do not match code we link to.
And if you're rewriting the third_party files' #includes anyway, why not just rewrite them to look like the full path the Chromium .cc files use? This avoids the need for shim headers entirely.I think we still need shim headers to support using system headers as an option. Rewriting the checked-in headers would make updates in third_party more cumbersome, especially in cases when we pull directly (or mirror directly) from upstream repo.
Note that for most cases we already use shim headers. This thread is just about generating them automatically at build time and some additional changes, but it's not like something completely new.
On Wed, Dec 5, 2012 at 4:50 AM, David Turner <di...@chromium.org> wrote:
This has already been discussed several times in the list I believe, and the conclusion is that the Chromium sources/build should not have to care about distro builds.I'm not sure how you came to that conclusion. Yes, the topic does come up frequently. This thread is my attempt to satisfy all perceived requirements, so that we can solve the shim headers once and for all (this is currently not the case).We are using shim headers, we have options to build with various system libraries. How do you think we got them? They are not officially supported, but they are allowed to be there. Please avoid comments that seem to just mean "I'd rather ignore Linux distros".
In your specific case, all you need is to have shim headers named "third_party/libX/include/libX/headerA.h" that just #include <libX/headerA.h>, and place them in a directory that is custom to your build, and added to the include search path with -I before the Chromium project path.If nobody is concerned about using system headers by mistake in that scheme (see my first e-mail for the scenario that makes it break), and there is strong opposition to my plan above (because I'm somewhat concerned about such header mix-up), I could do that.
AFAICT, there are two points in this.
1) If we have anything in third_party/ which is not hermetic, we need
to fix it. Full stop, really no discussion necessary. If this is a
problem and you have a solution which is not terribly intrusive, I
think that could receive support.
2) Intentionally making the build not hermetic to use system
libraries. This is clearly a non-goal of the project, and I think
that if someone wants to support that use case, they need to try to
not make that support terribly intrusive.
I have a local POC that indicates possible problems.
Currently I can't solve one quirk with V8 headers
I've also spotted a possible problem that applies to our bundled libraries
Interestingly, I couldn't see much technical feedback in this thread.
(and that happens! I've fixed at least 5 problems of omission in the past)
I'm happy to adjust my proposal if needed. I'd like to see more constructive feedback
I have a local POC that indicates possible problems.Can you add a pointer to it (bugreport/not-for-submit-patch/whatever) to this thread?
Currently I can't solve one quirk with V8 headersWhat is that quirk?
I've also spotted a possible problem that applies to our bundled librariesWhat is this "possible problem"?
Interestingly, I couldn't see much technical feedback in this thread.That's because you've been very opaque about the problems being solved. Please be as explicit as you can about both the problems you see and the fixes you propose.
(and that happens! I've fixed at least 5 problems of omission in the past)Can you point to example bugs/patches to make concrete the problem you describe?
I'm happy to adjust my proposal if needed. I'd like to see more constructive feedbackI tried replying to your original email and deleted my draft when I realized Ia) wasn't sure what problems you're solving; andb) wasn't sure what solution you're proposing.Your original email stated that the (presumably only) benefit to Chrome is reducing the number of 3-p include dirs on the include path, but libX still shows up in your header_shims proposal, so I doubt this will be a big benefit. Can you quantify this benefit?
You imply that the header_shims solution will make it less likely that third_party .cc files accidentally #include system-provided .h's instead of the third_party version fo the same .h's (because of missing -I's). But unless you plan to translate all third_party .cc's to use your header_shim/ paths, I don't see how you in fact affect anything there.
Besides the previous two paragraphs, are there other benefits to (official) Chrome?
This demonstrates everything can be fine as long as you always remember to set the right include path. When you forget, system headers may be used. Now the failure mode in real scenario could be even worse: instead of a failed compile, you could have a successful compile with different object files using different headers for the same thing, which is obviously bad and recipe for mysterious problems.
You can look at third_party/re2/re2/re2.h for a very similar situation.
Currently I can't solve one quirk with V8 headersWhat is that quirk?See https://groups.google.com/a/chromium.org/d/msg/chromium-dev/7l-hHqUgMHA/zZArWi8kDk0J . That includes some offline discussions, but the idea is that I think the best way to solve problem from the cited thread is to create a unified solution for shim headers.
(and that happens! I've fixed at least 5 problems of omission in the past)Can you point to example bugs/patches to make concrete the problem you describe?Sure, just a few that I could find easily:
You imply that the header_shims solution will make it less likely that third_party .cc files accidentally #include system-provided .h's instead of the third_party version fo the same .h's (because of missing -I's). But unless you plan to translate all third_party .cc's to use your header_shim/ paths, I don't see how you in fact affect anything there.I wouldn't rewrite third party .cc files. They would still need include path set for their own headers. It's unlikely to make mistakes in the third_party gyp file since it has to be done just once. The problem I'm addressing is caused by changes in Chrome code that add more dependencies on third party libraries. Then it's much easier to miss an added dependency that seems to just work.
Besides the previous two paragraphs, are there other benefits to (official) Chrome?I think the biggest benefit is no doubt as to which headers get used, system vs. bundled. Again, Chrome build is affected by this, i.e. there is a chance we #include system headers on Linux by mistake even when using bundled libraries.
Thanks for iterating. I like the resulting edits to the .cc files in that CL!Some thoughts on the implementation:1) why write shims instead of building a symlink farm?2) (assuming you keep the idea of explicit shims) it seems unfortunate to me to include shim-building as part of the build, since the only time it needs to change is when the present headers change. What do you think of checking in these shims, instead?
1) why write shims instead of building a symlink farm?
2) (assuming you keep the idea of explicit shims) it seems unfortunate to me to include shim-building as part of the build, since the only time it needs to change is when the present headers change. What do you think of checking in these shims, instead? Seems like an equivalent amount of dev work (either edit a .gyp when a new .h shows up or re-run the shim generator for that .h) but with less compute work done at build-time.
3) IWBN to assert that shims are *not* being used for use_system_foo=0 builds, and, more importantly, for official builds.
As a middle ground, is it possible to do the shim-building during the runhooks phase so that it still happens locally, but only when updating?
3) IWBN to assert that shims are *not* being used for use_system_foo=0 builds, and, more importantly, for official builds.I've checked that. The shims are not used. They are not even generated in that case. Not even is the generator called at all to produce the list of inputs.
On Fri, Dec 7, 2012 at 5:16 PM, Greg Thompson <g...@chromium.org> wrote:As a middle ground, is it possible to do the shim-building during the runhooks phase so that it still happens locally, but only when updating?I'm not sure why you call that middle ground
As long as shim-generation is not triggered for the Chrome use-case, I'm fine with it.
3) IWBN to assert that shims are *not* being used for use_system_foo=0 builds, and, more importantly, for official builds.I've checked that. The shims are not used. They are not even generated in that case. Not even is the generator called at all to produce the list of inputs.By "assert" I meant the code, not its author :). E.g. add to the generated headers:#ifdef OFFICIAL_BUILD#error Shim headers must not be used in official builds!#endif