mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: undefined reference to `raise' with musl static toolchain
Date: Fri, 11 May 2018 12:05:44 -0400	[thread overview]
Message-ID: <20180511160544.GT1392@brightrain.aerifal.cx> (raw)
In-Reply-To: <20180511175901.7f17085a@windsurf.home>

On Fri, May 11, 2018 at 05:59:01PM +0200, Thomas Petazzoni wrote:
> Hello,
> 
> Thanks for your feedback.
> 
> On Wed, 9 May 2018 17:24:37 +0200, Szabolcs Nagy wrote:
> 
> > there can be many reasons.. 
> > 
> > e.g. if mktime in uclibc-ng happens to reference raise then it
> > would get linked in independently of libgcc.
> 
> In the static binary linked against uClibc, there are two references to
> __GI_raise:
> 
> 	__GI_abort
> 	__aeabi_idiv0
> 
> __GI_abort is reference from _start, so I guess this means that
> __GI_abort is always pulled in, therefore __GI_raise is always pulled
> in, and __aeabi_idiv0 is happy.
> 
> Now my question remains: do you consider it normal that -static is
> required, or do you consider it a bug of the musl/gcc integration that
> -static is required even when the only variant available of the library
> is the static one ?

I don't think gcc is intended to work right in configurations where it
supports dynamic linking but the only libc available is static, unless
you pass -static, and I don't see a good way to make it work in that
case. You've only hit the tip of the iceberg; there's more stuff that
could break subtly when gcc is passing ld options that were intended
for dynamic linking, but ld actually ends up performing static
linking. It "working" with uClibc is just "getting lucky" (or
"unlucky" depending on your perspective about ignoring vs catching
unsafe things).

If gcc doesn't have any option to tell it you're building a
static-only toolchain and make static linking the default, I see that
as something of an omission, and maybe we should try to get that added
to gcc.

Rich


  reply	other threads:[~2018-05-11 16:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 12:44 Thomas Petazzoni
2018-05-08 13:28 ` Alexander Monakov
2018-05-08 16:22 ` Markus Wichmann
2018-05-08 16:34   ` Rich Felker
2018-05-09  9:29     ` Thomas Petazzoni
2018-05-09 13:44       ` Thomas Petazzoni
2018-05-09 15:24         ` Szabolcs Nagy
2018-05-09 17:28           ` Rich Felker
2018-05-11 15:59           ` Thomas Petazzoni
2018-05-11 16:05             ` Rich Felker [this message]
2018-05-11 21:28               ` Thomas Petazzoni

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

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

  git send-email \
    --in-reply-to=20180511160544.GT1392@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).