Bug 229337 - GLContextGLX.cpp may sometimes fail build because of X11 include files
Summary: GLContextGLX.cpp may sometimes fail build because of X11 include files
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-08-20 08:22 PDT by Daniel Kolesa
Modified: 2022-01-07 08:23 PST (History)
4 users (show)

See Also:


Attachments
patch (1.25 KB, patch)
2021-08-20 08:23 PDT, Daniel Kolesa
pnormand: review+
Details | Formatted Diff | Diff
patch (1.18 KB, patch)
2021-10-26 08:15 PDT, Daniel Kolesa
dkolesa: review?
dkolesa: commit-queue?
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Kolesa 2021-08-20 08:22:36 PDT
The file should probably be marked @no-unify.
Comment 1 Daniel Kolesa 2021-08-20 08:23:34 PDT
Created attachment 435989 [details]
patch
Comment 2 Radar WebKit Bug Importer 2021-08-27 08:23:21 PDT
<rdar://problem/82439830>
Comment 3 Daniel Kolesa 2021-10-26 08:15:23 PDT
Created attachment 442489 [details]
patch

updated patch
Comment 4 Fujii Hironori 2021-10-26 18:35:45 PDT
WebKit has a lot of #undef in WTF and WebCore layer for this issue, for example "#undef True" and "#undef None".
Does this change make it possible to remove it?
For example, https://github.com/WebKit/WebKit/blob/bb27304754d0bb686fc3ddfccc42fb8ec1f14d62/Source/WTF/wtf/Threading.h#L64,L68
Comment 5 Fujii Hironori 2021-10-26 18:39:23 PDT
Maybe, No. Because it can't compile if both X11 header and undef-ing headers are included.
I think we should take #undef-ing approach.
Comment 6 Fujii Hironori 2021-10-26 18:57:37 PDT
WebKit has ANGLEHeaders.h to include ANGLE headers.
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/platform/graphics/angle/ANGLEHeaders.h

I think we should add X11Headers.h to include X11 headers.
WDYT?
Comment 7 Daniel Kolesa 2021-10-27 04:48:15 PDT
possibly, I marked the file no-unify since in practice other OpenGL files do the same thing (there's a bunch of others in the same file) and I think it's the cleanest way to get around it (it should work unconditionally regardless of what the X11 headers do)

but I'm fine either way
Comment 8 Fujii Hironori 2021-10-27 12:50:53 PDT
In my understanding, @no-unify approach can't solve the issue completely because #include order is ruled by WebKit coding style.
If a header defining None or True are included after X11 header, it can't compile.
Is my understanding right?
Comment 9 Daniel Kolesa 2021-10-28 03:49:15 PDT
if the build for the file is non-unified, it solves the issue because the file is compiled on its own - and therefore we get control over *which* headers are included and can make sure they are non-conflicting
Comment 10 Fujii Hironori 2021-10-28 13:04:43 PDT
Then, we no longer need the #undef. could you remove all #undef for the issue in the patch?
Comment 11 Daniel Kolesa 2021-10-29 05:46:06 PDT
you mean for the ANGLE bits?
Comment 12 Fujii Hironori 2021-10-29 13:53:17 PDT
WebKit has a lot of #undef in WTF and WebCore layer for this issue
For example, https://github.com/WebKit/WebKit/blob/bb27304754d0bb686fc3ddfccc42fb8ec1f14d62/Source/WTF/wtf/Threading.h#L64,L68
If you can solve the issue completely by @no-unify approach, we no longer need the #undef.

I think @no-unify approach can't solve the issue completely  because #include order is ruled by WebKit coding style.
If a header defining None or True are included after X11 header, it can't compile. We need #undef. @no-unify approach isn't a good idea.
I think we should add X11Headers.h to include all X11 headers we need.
Comment 13 Daniel Kolesa 2021-10-31 18:54:20 PDT
(In reply to Fujii Hironori from comment #12)
> WebKit has a lot of #undef in WTF and WebCore layer for this issue
> For example,
> https://github.com/WebKit/WebKit/blob/
> bb27304754d0bb686fc3ddfccc42fb8ec1f14d62/Source/WTF/wtf/Threading.h#L64,L68
> If you can solve the issue completely by @no-unify approach, we no longer
> need the #undef.
> 
> I think @no-unify approach can't solve the issue completely  because
> #include order is ruled by WebKit coding style.
> If a header defining None or True are included after X11 header, it can't
> compile. We need #undef. @no-unify approach isn't a good idea.
> I think we should add X11Headers.h to include all X11 headers we need.

this is never really a problem for the problematic file in this case, because the X11 headers are included last, and it's a source file - which was my point all along, if you eliminate it being unified with another source file, there should be no problem anymore (your concern would only be a problem if the file itself was a header, or if we didn't control the include order of headers)
Comment 14 Fujii Hironori 2021-10-31 19:24:23 PDT
Sonny, but I don't understand.
Can we remove all #undef?
For example, https://github.com/WebKit/WebKit/blob/bb27304754d0bb686fc3ddfccc42fb8ec1f14d62/Source/WTF/wtf/Threading.h#L64,L68
If so, please do it.
If not, please give up the @no-unify approach, that don't solve the issue.
Comment 15 Daniel Kolesa 2021-11-01 09:25:51 PDT
(In reply to Fujii Hironori from comment #14)
> Sonny, but I don't understand.
> Can we remove all #undef?
> For example,
> https://github.com/WebKit/WebKit/blob/
> bb27304754d0bb686fc3ddfccc42fb8ec1f14d62/Source/WTF/wtf/Threading.h#L64,L68
> If so, please do it.
> If not, please give up the @no-unify approach, that don't solve the issue.

it does not fix that because that's a header; this patch is specifically for the one failing file
Comment 16 Michael Catanzaro 2022-01-07 08:23:56 PST
I agree with Fujii that #undef is preferable to @no-unify.

Don't hesitate to use @no-unify if you really need to, but I don't see why #undef couldn't do the job here.