bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* Missing extern "C" in count-one-bits.h?
@ 2020-02-20 20:15 Simon Marchi
  2020-02-21 20:59 ` Paul Eggert
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2020-02-20 20:15 UTC (permalink / raw)
  To: bug-gnulib

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-21 22:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 20:15 Missing extern "C" in count-one-bits.h? Simon Marchi
2020-02-21 20:59 ` Paul Eggert
2020-02-21 22:47   ` Simon Marchi via Gnulib discussion list

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).