bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Simon Marchi via Gnulib discussion list <bug-gnulib@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: bug-gnulib@gnu.org
Subject: Re: Missing extern "C" in count-one-bits.h?
Date: Fri, 21 Feb 2020 17:47:19 -0500	[thread overview]
Message-ID: <dc294ba4-584f-99ab-d6fe-684a3d4b0469@polymtl.ca> (raw)
In-Reply-To: <314f76bd-3892-b81d-9e7f-ea8865a5ac13@cs.ucla.edu>

On 2020-02-21 3:59 p.m., Paul Eggert wrote:
> On 2/20/20 12:15 PM, Simon Marchi wrote:
>> 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?
> 
> Thanks, I'll take your word for it. (I don't use C++.) I installed the attached patch into Gnulib. Apparently these modules have been used by C code only, until now.

Thanks, that does the job.

I'll try to provide a minimal reproducer next time, I just haven't learned yet
how to use gnulib in a standalone way (outside of what GDB uses).

>> 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?
> 
> It's a compiler's choice whether a function is inlined. When I call count_one_bits in C, gcc -O2 doesn't create a function for count_one_bits in the calling module; it simply issues the popcnt insn, or calls the appropriate GCC library function on platforms that don't have a popcnt insn. Perhaps you were compiling with some other level of optimization, or perhaps C++ does this differently; but regardless of how the compiler does it the resulting code is supposed to work of course.

I indeed build without optimizations, to be able to debug, it's likely that
clang with optimizations would also reduce that to just popcnt.

Anyway, thanks for the help, I'll go work on updating GDB's gnulib import!

Simon


      reply	other threads:[~2020-02-21 22:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=dc294ba4-584f-99ab-d6fe-684a3d4b0469@polymtl.ca \
    --to=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=simon.marchi@polymtl.ca \
    /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).