<?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>282275</bug_id>
          
          <creation_ts>2024-10-29 13:30:07 -0700</creation_ts>
          <short_desc>[CMake] C compiler flags improperly used when compiling libpas source files as C++</short_desc>
          <delta_ts>2024-10-30 07:20:17 -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>bmalloc</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>aperez</cc>
    
    <cc>berto</cc>
    
    <cc>ggaren</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2071363</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-10-29 13:30:07 -0700</bug_when>
    <thetext>Berto is complaining about this warning when compiling e.g. bmalloc_heap_config.c:

/usr/bin/cc -DBUILDING_GTK__=1 -DBUILDING_WEBKIT=1 -DBUILDING_WITH_CMAKE=1 -DBUILDING_bmalloc -DBWRAP_EXECUTABLE=\&quot;/usr/bin/bwrap\&quot; -DDBUS_PROXY_EXECUTABLE=\&quot;/usr/bin/xdg-dbus-proxy\&quot; -DGETTEXT_PACKAGE=\&quot;WebKitGTK-4.1\&quot; -DHAVE_CONFIG_H=1 -DJSC_GLIB_API_ENABLED -DPAS_BMALLOC=1 -D_GNU_SOURCE -I/tmp/webkit2gtk-2.47.1/Source/bmalloc -I/tmp/webkit2gtk-2.47.1/Source/bmalloc/bmalloc -I/tmp/webkit2gtk-2.47.1/Source/bmalloc/libpas/src/libpas -fdiagnostics-color=always -Wextra -Wall -pipe -fmax-errors=20 -Wno-expansion-to-defined -Wno-psabi -Wno-misleading-indentation -Wno-maybe-uninitialized -Wundef -Wpointer-arith -Wmissing-format-attribute -Wformat-security -Wcast-align -Wno-tautological-compare -g1 -O2 -Werror=implicit-function-declaration -ffile-prefix-map=/tmp/webkit2gtk-2.47.1=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -DNDEBUG -DG_DISABLE_CAST_CHECKS -fno-strict-aliasing -fno-exceptions -ffunction-sections -fdata-sections -fPIC -fvisibility=hidden -Wno-missing-field-initializers -Wno-cast-align -xc++ -std=c++2b -MD -MT Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/bmalloc_heap_config.c.o -MF Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/bmalloc_heap_config.c.o.d -o Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/bmalloc_heap_config.c.o -c /tmp/webkit2gtk-2.47.1/Source/bmalloc/libpas/src/libpas/bmalloc_heap_config.c
cc1plus: warning: ‘-Werror=’ argument ‘-Werror=implicit-function-declaration’ is not valid for C++

Problem is a few libpas files are manually compiled with -xc++ -std=c++2b, but CMake doesn&apos;t know about this so it uses CFLAGS and CMAKE_C_FLAGS rather than CXXFLAGS and CMAKE_CXX_FLAGS. We can simply tell CMake to change the programming language rather than attempt to change this by passing -xc++ to the C compiler. This works since CMake 3.20, which is conveniently the minimum version that we support. (And we already set CMAKE_CXX_STANDARD to 23, so no need for -std=c++2b anymore either.)

I wonder why C++ is used at all. It&apos;s quite unusual to compile C source files as C++ without some explanation in the code or build system for why this is done. The code clearly does not use any C++. But I assume there&apos;s some good reason for this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2071371</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-10-29 13:38:34 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/35892</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2071398</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2024-10-29 14:46:46 -0700</bug_when>
    <thetext>Mystery solved: those files really are C++ and won&apos;t build as C:

/app/webkit/Source/bmalloc/libpas/src/libpas/pas_bitfit_page_config_kind.c:74:5: error: initializer element is not constant
   74 |     (value).base.page_config_ptr,
      |     ^
/app/webkit/Source/bmalloc/libpas/src/libpas/pas_bitfit_page_config_kind.def:43:1: note: in expansion of macro ‘PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND’
   43 | PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/app/webkit/Source/bmalloc/libpas/src/libpas/pas_bitfit_page_config_kind.c:74:5: note: (near initialization for ‘pas_bitfit_page_config_kind_for_config_table[0]’)
   74 |     (value).base.page_config_ptr,
      |     ^
/app/webkit/Source/bmalloc/libpas/src/libpas/pas_bitfit_page_config_kind.def:43:1: note: in expansion of macro ‘PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND’
   43 | PAS_DEFINE_BITFIT_PAGE_CONFIG_KIND(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I guess the .c is there to discourage most other use of C++.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2071580</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-10-30 07:19:13 -0700</bug_when>
    <thetext>Committed 285901@main (6641652afa8a): &lt;https://commits.webkit.org/285901@main&gt;

Reviewed commits have been landed. Closing PR #35892 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2071581</commentid>
    <comment_count>4</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2024-10-30 07:20:17 -0700</bug_when>
    <thetext>&lt;rdar://problem/138916440&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>