Bug 172618 - Building with GCC 7.1.x spews lots of “warning: this use of "defined" may not be portable [-Wexpansion-to-defined]“
Summary: Building with GCC 7.1.x spews lots of “warning: this use of "defined" may not...
Status: RESOLVED DUPLICATE of bug 167643
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adrian Perez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-05-25 16:06 PDT by Adrian Perez
Modified: 2017-05-25 20:12 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.88 KB, patch)
2017-05-25 16:10 PDT, Adrian Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.