Skip to content

Conversation

martinus
Copy link
Contributor

@martinus martinus commented Apr 3, 2023

Fixes #26916 by disabling the warning -Wgnu-zero-variadic-macro-arguments when clang is used as the compiler.

Also see the comments

@DrahtBot
Copy link
Contributor

DrahtBot commented Apr 3, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK hebasto, fanquake
Concept ACK 0xB10C, ajtowns

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@hebasto
Copy link
Member

hebasto commented Apr 4, 2023

Maybe add a check to configure.ac whether ignoring of -Wgnu-zero-variadic-macro-arguments is really required?

…e without warnings

Fixes bitcoin#26916 by disabling the warning `-Wgnu-zero-variadic-macro-arguments` when clang is used as the compiler.
@martinus martinus force-pushed the 2023-04-no-tracepoint-warnings branch from 240e513 to 5197660 Compare April 4, 2023 18:21
@martinus
Copy link
Contributor Author

martinus commented Apr 4, 2023

Maybe add a check to configure.ac whether ignoring of -Wgnu-zero-variadic-macro-arguments is #26916 (comment) required?

Sounds good, but I have no idea how to do this with configure.ac... But it's also possible to do this in code level, I've now added a __cplusplus < 202002L so disabling the warning only happens when compiling below c++20

@0xB10C
Copy link
Contributor

0xB10C commented Apr 11, 2023

Concept ACK and thank you for looking into this!

I would include this in #26593 (e.g. with #26593 (comment)) too. If #26916 is blocking something (e.g. switching to a newer clang) I think merging this PR here first should be preferred as #26593 is a bigger change that might take a bit longer.

@hebasto
Copy link
Member

hebasto commented Apr 13, 2023

Maybe add a check to configure.ac whether ignoring of -Wgnu-zero-variadic-macro-arguments is #26916 (comment) required?

Sounds good, but I have no idea how to do this with configure.ac...

Something like in this branch:

--- a/configure.ac
+++ b/configure.ac
@@ -470,6 +470,19 @@ if test "$CXXFLAGS_overridden" = "no"; then
   if test "$suppress_external_warnings" != "yes" ; then
     AX_CHECK_COMPILE_FLAG([-Wdeprecated-copy], [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-copy"], [], [$CXXFLAG_WERROR])
   fi
+
+  AX_CHECK_COMPILE_FLAG([-Wgnu-zero-variadic-macro-arguments],
+    [
+      TEMP_CXXFLAGS="$CXXFLAGS"
+      CXXFLAGS="-Wgnu-zero-variadic-macro-arguments $CXXFLAG_WERROR $CXXFLAGS"
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+          #define VARIADIC_MACRO(a, ...) f(__VA_ARGS__)
+          void f() {}
+          int main() { VARIADIC_MACRO(42); }
+        ]])], [],
+        [NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-gnu-zero-variadic-macro-arguments"])
+      CXXFLAGS="$TEMP_CXXFLAGS"
+    ], [], [$CXXFLAG_WERROR])
 fi
 
 dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 5197660, I've reconsidered my comment and I think the current localized approach is optimal.

@ajtowns
Copy link
Contributor

ajtowns commented Jul 1, 2023

utACK

Manually setting that flag by overriding CXXFLAGS disables a whole bunch of debugging warnings, so handling it directly seems very helpful.

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 5197660 - checked that this fixes the warnings under Clang.

@fanquake fanquake merged commit 97ba721 into bitcoin:master Aug 7, 2023
@martinus martinus deleted the 2023-04-no-tracepoint-warnings branch August 7, 2023 18:07
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 9, 2023
…-arguments` to compile without warnings

5197660 tracepoints: Disables `-Wgnu-zero-variadic-macro-arguments` to compile without warnings (Martin Leitner-Ankerl)

Pull request description:

  Fixes bitcoin#26916 by disabling the warning `-Wgnu-zero-variadic-macro-arguments` when clang is used as the compiler.

  Also see the comments
  * Proposed changes in the bug  bitcoin#26916 (comment)
  * Proposed changes when moving to a variadic maro: bitcoin#26593 (comment)

ACKs for top commit:
  hebasto:
    ACK 5197660, I've reconsidered my [comment](bitcoin#27401 (comment)) and I think the current localized approach is optimal.
  fanquake:
    ACK 5197660 - checked that this fixes the warnings under Clang.

Tree-SHA512: c3dda3bcbb2540af6283ffff65885a9937bfdaaef3b00dc7d60b9f9740031d5c36ac9cb3d3d8756dbadce4812201a9754f5b8770df0d5e0d5ee690ba8a7135d2
@bitcoin bitcoin locked and limited conversation to collaborators Aug 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tracepoints: gnu-zero-variadic-macro-arguments warnings
6 participants