<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>233007</bug_id>
          
          <creation_ts>2021-11-11 11:45:48 -0800</creation_ts>
          <short_desc>ODR violations caused by ANGLE and WebCore&apos;s use of bison</short_desc>
          <delta_ts>2023-10-19 08:45:08 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>ANGLE</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=229867</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>220896</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>dino</cc>
    
    <cc>geofflang</cc>
    
    <cc>jonahr</cc>
    
    <cc>kbr</cc>
    
    <cc>kkinnunen</cc>
    
    <cc>kpiddington</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>sam</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1814143</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-11-11 11:45:48 -0800</bug_when>
    <thetext>In bug #229867 I propose disabling -Wodr, but it does catch some real bugs that we should try to fix:

[2044/2295] Linking CXX executable bin/TestWebKitAPI/TestWebCore
XPathGrammar.y:72: warning: type ‘union YYSTYPE’ violates the C++ One Definition Rule [-Wodr]
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab_autogen.h:243: note: a different type is defined in another translation unit
  243 | union YYSTYPE
      | 
XPathGrammar.y:58: note: the first difference of corresponding definitions is field ‘numericOpcode’
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab_autogen.h:257: note: a field with different name is defined in another translation unit
  257 |     } lex;
      | 
XPathGrammar.cpp:366: warning: type ‘union yyalloc’ violates the C++ One Definition Rule [-Wodr]
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab_autogen.cpp:645: note: a different type is defined in another translation unit
  645 | union yyalloc
      | 
XPathGrammar.cpp:368: note: the first difference of corresponding definitions is field ‘yyss’
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/translator/glslang_tab_autogen.cpp:647: note: a field with different name is defined in another translation unit
  647 |     yytype_int16 yyss_alloc;
      | 
glslang.l:982: warning: type ‘struct yyguts_t’ violates the C++ One Definition Rule [-Wodr]
preprocessor.l:777: note: a different type is defined in another translation unit
glslang.l:986: note: the first difference of corresponding definitions is field ‘yyextra_r’
preprocessor.l:781: note: a field of same name but different type is defined in another translation unit
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/translator/ParseContext.h:33: note: type name ‘sh::TParseContext’ should match type name ‘angle::pp::Tokenizer::Context’
   33 | class TParseContext : angle::NonCopyable
      | 
/home/mcatanzaro/Projects/WebKit/Source/ThirdParty/ANGLE/src/compiler/preprocessor/Tokenizer.h:25: note: the incompatible type is defined here
   25 |     struct Context
      | 
/home/mcatanzaro/Projects/WebKit/Source/WebCore/xml/XPathParser.h:45: warning: ‘lex’ violates the C++ One Definition Rule [-Wodr]
   45 |     int lex(YYSTYPE&amp;);
      | 
/home/mcatanzaro/Projects/WebKit/Source/WebCore/xml/XPathParser.cpp:404: note: type mismatch in parameter 1
  404 | int Parser::lex(YYSTYPE&amp; yylval)
      | 

These are real bugs, but they&apos;re not simple to avoid because fixing them probably requires a decent understanding of bison. I&apos;m not sure if we can rename YYSTYPE when using bison&apos;s standard C language skeleton. At first I thought ANGLE might need to switch to using bison&apos;s C++ support, but we actually cannot do that because it&apos;s probably not available in Apple&apos;s older version of bison (and if it is available, it will for sure be too buggy to rely on).

It might be possible to try naively enclosing bison stuff in C++ namespaces, but I&apos;m not sure about that either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1814160</commentid>
    <comment_count>1</comment_count>
    <who name="Kimmo Kinnunen">kkinnunen</who>
    <bug_when>2021-11-11 12:26:39 -0800</bug_when>
    <thetext>ANGLE generated files come from ANGLE reporsitory, generated by ANGLE versions upstream. 
Some of the clashes can be worked around by defining the bison and flex prefix.

rest of the clashes could in theory be perhaps worked around by #define trickery (e.g. preprocessor.l #define yyguts_t ppguts_t)

Sounds like a good -W, those are hard to catch all and argue for otherwise, as they typically don&apos;t affect anything...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1814171</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-11-11 13:00:15 -0800</bug_when>
    <thetext>&gt; Some of the clashes can be worked around by defining the bison and flex prefix.

Ah, I didn&apos;t know this was possible.

(In reply to Kimmo Kinnunen from comment #1)
&gt; Sounds like a good -W, those are hard to catch all and argue for otherwise,
&gt; as they typically don&apos;t affect anything...

Yes, but sadly the warnings it generates are non-suppressible, and we&apos;re hitting them in bug #229867.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1814306</commentid>
    <comment_count>3</comment_count>
    <who name="Kenneth Russell">kbr</who>
    <bug_when>2021-11-11 16:56:04 -0800</bug_when>
    <thetext>The ANGLE team would be glad to change how bison/flex are invoked upstream. If you can propose changes to how src/compiler/generate_parser_tools.py invokes them, we&apos;ll be glad to do so upstream. It would be most expedient to wait ~1 week  for the next ANGLE roll into WebKit to be ready in Bug 220896.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1814319</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2021-11-11 17:29:11 -0800</bug_when>
    <thetext>(In reply to Kimmo Kinnunen from comment #1)
&gt; Some of the clashes can be worked around by defining the bison and flex
&gt; prefix.

Found some documentation:

https://www.gnu.org/software/bison/manual/html_node/Multiple-Parsers.html

Unfortunately there was an incompatible syntax change, apparently the braces are required for modern bison but not allowed for older bison. Oh well.

Stack Overflow (one of the answers covers flex too):

https://stackoverflow.com/questions/1634704/multiple-flex-bison-parsers</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816537</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-11-18 11:46:26 -0800</bug_when>
    <thetext>&lt;rdar://problem/85561198&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1986157</commentid>
    <comment_count>6</comment_count>
    <who name="Sam James">sam</who>
    <bug_when>2023-10-19 08:45:08 -0700</bug_when>
    <thetext>gdb has worked around this with remapping, see https://sourceware.org/bugzilla/show_bug.cgi?id=30839 (some other examples in https://sourceware.org/bugzilla/show_bug.cgi?id=22395).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>