Bug 172618

Summary: Building with GCC 7.1.x spews lots of “warning: this use of "defined" may not be portable [-Wexpansion-to-defined]“
Product: WebKit Reporter: Adrian Perez <aperez>
Component: Tools / TestsAssignee: Adrian Perez <aperez>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: achristensen, lforschler, mcatanzaro, ysuzuki
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Adrian Perez 2017-05-25 16:06:49 PDT
This happens for all the expansions of:

  - #if ENABLE(FOO)
  - #if PLATFORM(FOO)
  - #if CPU(FOO)
  - #if USE(FOO)
  - #if HAVE(FOO)
  - ...

For example:

  ../../Source/WTF/wtf/Platform.h:807:1: warning: this use of "defined" may not be portable [-Wexpansion-to-defined]
  #if (CPU(X86_64) || CPU(ARM64)) && HAVE(FAST_TLS)
     ^~~~~~~~~~~~~                          

It seems that the -Wexpansion-to-defined existed before in GCC, but the warning
is now enabled by default in version 7.1.x of the compiler. WebKit source code
makes extensive use of this kind of expansions, so probably it'd be better to
silence these warnings.
Comment 1 Adrian Perez 2017-05-25 16:10:42 PDT
Created attachment 311307 [details]
Patch
Comment 2 Michael Catanzaro 2017-05-25 19:57:32 PDT
I know you already have a patch here and normally I'd favor the bug with the patch, but there's good discussion in bug #167643 so please reattach it there.

My concern is that these macros are all undefined behavior, so we should consider eliminating them.

*** This bug has been marked as a duplicate of bug 167643 ***
Comment 3 Michael Catanzaro 2017-05-25 20:12:17 PDT
Comment on attachment 311307 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311307&action=review

> Source/cmake/OptionsCommon.cmake:78
> +   if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.1.0")
> +     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-expansion-to-defined")
> +   endif ()

No need to check compiler version, just enable it unconditionally. Look for wherever our other warning flags are used; we probably don't need to add a new line, just add it to wherever the other ones are.