Bug 245176
| Summary: | [CMake] Clang warnings about C code being built in C++ mode | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Adrian Perez <aperez> |
| Component: | Tools / Tests | Assignee: | Lauro Moura <lmoura> |
| Status: | RESOLVED FIXED | ||
| Severity: | Minor | CC: | fujii.hironori, stephan.szabo, webkit-bug-importer, ysuzuki |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=247064 | ||
Adrian Perez
I haven'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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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 'c' input as 'c++' 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).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Adrian Perez
This is easily reproducible with:
CC=clang CXX=clang++ cmake -S. -Bbuild -DPORT=GTK -GNinja
ninja -Cbuild
Fujii Hironori
What about adding enable_language(C)?
Yusuke Suzuki
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.
Yusuke Suzuki
So, I think, if we are using clang, then we do not need to mark them as C++.
Stephan Szabo
We'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's more general and happens in a test project, I wonder if it's something that should get handled inside the CMake code (well the modules for the compiler).
Stephan Szabo
From discussion on CMake discourse, with a minimum 3.20 or policy CMP0119 set to NEW, we'd get the -xc++ automatically when setting the language, but that won't help us for older versions.
Lauro Moura
Pull request: https://github.com/WebKit/WebKit/pull/5814
EWS
Committed 256626@main (e071c895f5fc): <https://commits.webkit.org/256626@main>
Reviewed commits have been landed. Closing PR #5814 and removing active labels.
Radar WebKit Bug Importer
<rdar://problem/102302395>