bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: bug-gnulib@gnu.org
Subject: Missing extern "C" in count-one-bits.h?
Date: Thu, 20 Feb 2020 15:15:03 -0500	[thread overview]
Message-ID: <a546f1a8-d142-77ae-214a-ef72dd596cc0@polymtl.ca> (raw)

Hi,

I recently imported the count-one-bits module in GDB.  I just noticed this while trying
to build gdb with clang++-9:

  arch/arm-get-next-pcs.o:arm-get-next-pcs.c:function thumb_get_next_pcs_raw(arm_get_next_pcs*): error: undefined reference to 'count_one_bits(unsigned int)'

Everything works fine when building with gcc-9.

This is in the gcc build:

$ readelf --syms gnulib/import/count-one-bits.o | grep count_one_bits
   164: 0000000000000000    24 FUNC    GLOBAL DEFAULT   50 count_one_bits
$ readelf --syms gdb/arch/arm-get-next-pcs.o | grep count_one_bits
   770: 0000000000000000    24 FUNC    WEAK   DEFAULT  281 _Z14count_one_bitsj

This is in the clang build:

$ readelf --syms gnulib/import/count-one-bits.o | grep count_one_bits
     6: 0000000000000000    64 FUNC    GLOBAL DEFAULT    2 count_one_bits
$ readelf --syms gdb/arch/arm-get-next-pcs.o | grep count_one_bits
   109: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Z14count_one_bitsj

The disagreement between the symbol names between count-one-bits.o and arm-get-next-pcs.o
seems to show that there is a missing `extern "C"` in the count-one-bits.h header?

And apparently, gcc decided to compile the definition in the header and include
it in arm-get-next-pcs.o, while clang did not.  Is that the compiler's choice,
or is it because the macros and preprocessor conditionals in count-one-bits.h
evaluated to something different for the two compilers?

Simon


             reply	other threads:[~2020-02-20 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-20 20:15 Simon Marchi [this message]
2020-02-21 20:59 ` Missing extern "C" in count-one-bits.h? Paul Eggert
2020-02-21 22:47   ` Simon Marchi via Gnulib discussion list

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=a546f1a8-d142-77ae-214a-ef72dd596cc0@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=bug-gnulib@gnu.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).