bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Missing extern "C" in count-one-bits.h?


From: Simon Marchi
Subject: Missing extern "C" in count-one-bits.h?
Date: Thu, 20 Feb 2020 15:15:03 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

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 via email to

[Prev in Thread] Current Thread [Next in Thread]