public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Ilya Leoshkevich <iii@linux.ibm.com>
To: Mark Wielaard <mark@klomp.org>
Cc: elfutils-devel@sourceware.org, Ilya Leoshkevich <iii@linux.ibm.com>
Subject: [PATCH v2 2/7] printversion: Fix unused variable
Date: Wed,  8 Feb 2023 20:52:21 +0100	[thread overview]
Message-ID: <20230208195226.144143-3-iii@linux.ibm.com> (raw)
In-Reply-To: <20230208195226.144143-1-iii@linux.ibm.com>

clang complains:

    debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable]
    ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT;
    ^
    ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF'
      const char *const apba__ __asm ("argp_program_bug_address")
                        ^

This is as expected: it's used by argp via the
"argp_program_bug_address" name, which is not visible on the C level.
Add __attribute__ ((used)) to make sure that the compiler emits it.

While at it, fix debuginfod not printing the bug report address.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 lib/printversion.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/printversion.h b/lib/printversion.h
index a9e059ff..37adff7e 100644
--- a/lib/printversion.h
+++ b/lib/printversion.h
@@ -39,11 +39,14 @@ void print_version (FILE *stream, struct argp_state *state);
    argp_program_bug_address, in all programs.  argp.h declares these
    variables as non-const (which is correct in general).  But we can
    do better, it is not going to change.  So we want to move them into
-   the .rodata section.  Define macros to do the trick.  */
+   the .rodata section.  Define macros to do the trick.  The default
+   linkage for consts in C++ is internal, so declare them extern.  */
 #define ARGP_PROGRAM_VERSION_HOOK_DEF \
   void (*const apvh) (FILE *, struct argp_state *) \
    __asm ("argp_program_version_hook")
 #define ARGP_PROGRAM_BUG_ADDRESS_DEF \
-  const char *const apba__ __asm ("argp_program_bug_address")
+  extern const char *const apba__; \
+  const char *const apba__ __asm ("argp_program_bug_address") \
+  __attribute__ ((used))
 
 #endif // PRINTVERSION_H
-- 
2.39.1


  parent reply	other threads:[~2023-02-08 19:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 19:52 [PATCH v2 0/7] Add Memory Sanitizer support Ilya Leoshkevich
2023-02-08 19:52 ` [PATCH v2 1/7] libasm: Fix xdefault_pattern initialization Ilya Leoshkevich
2023-02-09 13:14   ` Mark Wielaard
2023-02-08 19:52 ` Ilya Leoshkevich [this message]
2023-02-08 19:52 ` [PATCH v2 3/7] readelf: Fix set but not used parameter Ilya Leoshkevich
2023-02-09 13:17   ` Mark Wielaard
2023-02-08 19:52 ` [PATCH v2 4/7] x86_64_return_value_location: Support lvalue and rvalue references Ilya Leoshkevich
2023-02-09 13:45   ` Mark Wielaard
2023-02-10  1:20     ` Ilya Leoshkevich
2023-02-10 16:22       ` Frank Ch. Eigler
2023-02-08 19:52 ` [PATCH v2 5/7] configure: Use -fno-addrsig if possible Ilya Leoshkevich
2023-02-09 13:28   ` Mark Wielaard
2023-02-08 19:52 ` [PATCH v2 6/7] configure: Add --disable-demangler Ilya Leoshkevich
2023-02-09 13:40   ` Mark Wielaard
2023-02-08 19:52 ` [PATCH v2 7/7] configure: Add --enable-sanitize-memory Ilya Leoshkevich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230208195226.144143-3-iii@linux.ibm.com \
    --to=iii@linux.ibm.com \
    --cc=elfutils-devel@sourceware.org \
    --cc=mark@klomp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).