bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Gavin Smith <gavinsmith0123@gmail.com>
To: "Arsen Arsenović" <arsen@aarsen.me>
Cc: Eli Zaretskii <eliz@gnu.org>, Bruno Haible <bruno@clisp.org>,
	sam@gentoo.org, bug-texinfo@gnu.org, bug-gnulib@gnu.org
Subject: Re: -Wlto-type-mismatch warning in error()
Date: Sat, 10 Dec 2022 01:48:22 +0000	[thread overview]
Message-ID: <Y5PlZvBWqepzXzs9@starmint> (raw)
In-Reply-To: <86fsdqi87x.fsf@aarsen.me>

On Thu, Dec 08, 2022 at 09:25:01AM +0100, Arsen Arsenović wrote:
> > Shouldn't we report this to the GCC folks?  It could be a bug in lto,
> > no?  I mean, 'error' is not a symbol that applications cannot use, and
> > if an application defines a function by that name, it should not be
> > imported from the standard library.  Right?
> 
> I believe this would make them part of the same program.  On top of
> that, Gnulib is pulling in error anyway:
> 
> $ nm ./gnulib/lib/libgnu.a | grep error
>                  U error
> $ nm install-info.o ../gnulib/lib/libgnu.a |& grep '\<error\>'
> 00000000 T error
>          U error
> 
> My guess is that libgnu_a-xalloc-die.o (the file emitting the U error
> symbol) includes gnulib/lib/error.h, GCC records that declaration
> (through it's use in xalloc_die), and then detects a mismatch with the
> one emitted by install-info.o (the T error symbol) and hence warns.
> 
> I imagine this would result is some very strange runtime failures if
> anyone ever observed install-info hit an xalloc_die condition.

Your analysis makes sense here.  I have committed a change to make it
static.  I have also cherry-picked this commit to the release/7.0
branch in case another release is made from this branch.

Unless there is some way in Gnulib to prefer the glibc symbols when
linking, this seems unavoidable.  Defining the Gnulib symbols as "weak"
wouldn't help; as Arsen has said, it is the definition in install-info.c
itself that shouldn't be used when resolving the reference to "error"
in libgnu.a.

Making the symbols provided by install-info.c weak might work,
so one idea is that when a program uses Gnulib, all of the global
symbols from the program (excluding Gnulib) should be marked as weak
in produced object files, so that Gnulib code preferentially uses
code from glibc or other libraries.  I have no idea what would be
needed to achieve this or what other implications there might be.
(This won't help if the symbol is weak in those libraries too, though.)

I consulted some documentation on the ELF format but there appears
only to be one type of "undefined" symbol - it wouldn't be possible
to make the undefined symbols in libgnu.a preferentially resolve to
glibc symbols rather than other files in the program.   I'm very ignorant
of these matters though so it possible I missed something.

Likewise something might also be possible with how the linker (ld) is run
but somebody would have to research this.

> Since I went through the process of making all the symbols in that file
> (besides main) local, here's the patch that does that

Thanks but no thanks.  install-info.c is a single-file program so there's
no point in adding the static keyword everywhere.


  parent reply	other threads:[~2022-12-10  1:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 20:57 -Wlto-type-mismatch warning in error() Sam James
2022-12-07 21:10 ` Arsen Arsenović
2022-12-07 21:37 ` Gavin Smith
2022-12-08  0:21   ` Bruno Haible
2022-12-08  6:16     ` Eli Zaretskii
2022-12-08  8:25       ` Arsen Arsenović via Gnulib discussion list
2022-12-08 10:55         ` Eli Zaretskii
2022-12-08 11:31           ` Arsen Arsenović
2022-12-08 19:00           ` namespacing issues with Gnulib Bruno Haible
2022-12-08 20:10             ` Eli Zaretskii
2022-12-08 20:19             ` Arsen Arsenović
2022-12-08 20:54               ` Paul Eggert
2022-12-10  1:48         ` Gavin Smith [this message]
2022-12-10  1:50           ` -Wlto-type-mismatch warning in error() Gavin Smith
2022-12-10 21:42           ` Paul Eggert
2022-12-11  4:24         ` Jeffrey Walton
2022-12-09 12:00     ` Florian Weimer

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=Y5PlZvBWqepzXzs9@starmint \
    --to=gavinsmith0123@gmail.com \
    --cc=arsen@aarsen.me \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=bug-texinfo@gnu.org \
    --cc=eliz@gnu.org \
    --cc=sam@gentoo.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).