<?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>245176</bug_id>
          
          <creation_ts>2022-09-14 05:06:30 -0700</creation_ts>
          <short_desc>[CMake] Clang warnings about C code being built in C++ mode</short_desc>
          <delta_ts>2022-11-13 20:26:20 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=247064</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Minor</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Perez">aperez</reporter>
          <assigned_to name="Lauro Moura">lmoura</assigned_to>
          <cc>fujii</cc>
    
    <cc>stephan.szabo</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1898438</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-09-14 05:06:30 -0700</bug_when>
    <thetext>I haven&apos;t researched the root cause yet, but it looks like either the build is using “clang++”
to compile plain C files, or passing “-x c++” to the “clang” driver (less likely): 

  [3/30/6151|2.0/s|  0%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/bmalloc_heap.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/31/6151|2.0/s|  0%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/bmalloc_heap_config.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/39/6151|2.5/s|  0%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/jit_heap.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/40/6151|2.5/s|  0%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/jit_heap_config.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/57/6151|3.4/s|  0%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_bitfit_page_config_kind.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/95/6151|5.3/s|  1%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_fast_megapage_cache.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/101/6151|5.5/s|  1%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_heap_config_kind.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/152/6151|7.7/s|  2%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_segregated_page_config_kind.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/167/6151|8.3/s|  2%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_thread_local_cache.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]
  [3/172/6151|8.5/s|  2%] Building CXX object Source/bmalloc/CMakeFiles/bmalloc.dir/libpas/src/libpas/pas_utility_heap_config.c.o
  clang-14: warning: treating &apos;c&apos; input as &apos;c++&apos; when in C++ mode, this behavior is deprecated [-Wdeprecated]

...unless this is intentional and some of the libpas files are expected to be built with a C++
compiler for some reason even if their suffix is “.c” (not very likely, I suppose).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898439</commentid>
    <comment_count>1</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-09-14 05:07:35 -0700</bug_when>
    <thetext>This is easily reproducible with:

  CC=clang CXX=clang++ cmake -S. -Bbuild -DPORT=GTK -GNinja
  ninja -Cbuild</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898524</commentid>
    <comment_count>2</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2022-09-14 13:16:41 -0700</bug_when>
    <thetext>What about adding enable_language(C)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898527</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-09-14 13:35:42 -0700</bug_when>
    <thetext>This is intentional since these files cannot be compiled as C in GCC probably because GCC lacks some constant propagation feature, which requires this explicit C++ handling.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898528</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-09-14 13:36:14 -0700</bug_when>
    <thetext>So, I think, if we are using clang, then we do not need to mark them as C++.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898534</commentid>
    <comment_count>5</comment_count>
    <who name="Stephan Szabo">stephan.szabo</who>
    <bug_when>2022-09-14 14:12:54 -0700</bug_when>
    <thetext>We&apos;d noticed something similar in the past, but we thought it was something specific to our downstream compilers, so in our case we ended up forcing a -xc++ into the build in our toolchain.

It feels like this should work from the CMake side (setting the language to CXX for a file that has .c extension), so if it&apos;s more general and happens in a test project, I wonder if it&apos;s something that should get handled inside the CMake code (well the modules for the compiler).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1898729</commentid>
    <comment_count>6</comment_count>
    <who name="Stephan Szabo">stephan.szabo</who>
    <bug_when>2022-09-15 09:42:31 -0700</bug_when>
    <thetext>From discussion on CMake discourse, with a minimum 3.20 or policy CMP0119 set to NEW, we&apos;d get the -xc++ automatically when setting the language, but that won&apos;t help us for older versions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1908414</commentid>
    <comment_count>7</comment_count>
    <who name="Lauro Moura">lmoura</who>
    <bug_when>2022-10-26 06:49:36 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/5814</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912154</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-11-13 20:25:31 -0800</bug_when>
    <thetext>Committed 256626@main (e071c895f5fc): &lt;https://commits.webkit.org/256626@main&gt;

Reviewed commits have been landed. Closing PR #5814 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1912156</commentid>
    <comment_count>9</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-11-13 20:26:20 -0800</bug_when>
    <thetext>&lt;rdar://problem/102302395&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>