From: Florian Weimer <fweimer@redhat.com>
To: libc-alpha@sourceware.org
Subject: Why -static-libgcc? (Or: Do we need a build-time libc.so linker script?)
Date: Wed, 24 Nov 2021 23:16:15 +0100 [thread overview]
Message-ID: <87y25dmc7k.fsf@oldenburg.str.redhat.com> (raw)
We have:
define build-shlib-helper
$(LINK.o) -shared -static-libgcc -Wl,-O1 $(sysdep-LDFLAGS) \
$(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) $(rtld-LDFLAGS) \
$(extra-B-$(@F:lib%.so=%).so) -B$(csu-objpfx) \
$(extra-B-$(@F:lib%.so=%).so) $(load-map-file) \
-Wl,-soname=lib$(libprefix)$(@F:lib%.so=%).so$($(@F)-version) \
$(LDFLAGS.so) $(LDFLAGS-lib.so) $(LDFLAGS-$(@F:lib%.so=%).so) \
-L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
endef
And:
define build-module-helper
$(LINK.o) -shared -static-libgcc $(sysdep-LDFLAGS) $(rtld-LDFLAGS) \
$(if $($(@F)-no-z-defs)$(no-z-defs),,-Wl,-z,defs) \
-B$(csu-objpfx) $(load-map-file) \
$(LDFLAGS.so) $(LDFLAGS-$(@F:%.so=%).so) \
-L$(subst :, -L,$(rpath-link)) -Wl,-rpath-link=$(rpath-link)
endef
Why do we use -static-libgcc? Doesn't this invalidate some of our
tests, because users do not generally build with -static-libgcc?
Background:
I'm dealing with an issue caused by a symbol reference from libgcc_eh.a
to ld.so. We do not link test modules against a libc.so linker script,
instead we use:
link-libc-args = -Wl,--start-group \
$(libc-for-link) \
$(common-objpfx)libc_nonshared.a \
-Wl,--as-needed $(elf-objpfx)ld.so -Wl,--no-as-needed \
-Wl,--end-group
I believe this is the reason why libgcc_eh.a can't reference ld.so: The
initial ld.so gets droped due to --as-needed, and the -lc after
libgcc_eh.a does not supply a second copy because it ends up linking
against the in-tree libc.so, which just the ELF object.
Dropping -static-libgcc seems to make this work.
An alternative would be to use a libc.so linker script during the glibc
as build (not just after installtion). This should bring back the ld.so
reference with -lc after libgcc_eh.a.
Thanks,
Florian
next reply other threads:[~2021-11-24 22:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-24 22:16 Florian Weimer [this message]
2021-11-24 23:19 ` Joseph Myers
2022-01-10 13:00 ` Florian Weimer
2022-01-10 13:26 ` Adhemerval Zanella
2022-01-11 0:58 ` Joseph Myers
2022-04-19 11:57 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y25dmc7k.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=libc-alpha@sourceware.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).