public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Why -static-libgcc? (Or: Do we need a build-time libc.so linker script?)
@ 2021-11-24 22:16 Florian Weimer
  2021-11-24 23:19 ` Joseph Myers
  0 siblings, 1 reply; 6+ messages in thread
From: Florian Weimer @ 2021-11-24 22:16 UTC (permalink / raw)
  To: libc-alpha

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-19 11:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24 22:16 Why -static-libgcc? (Or: Do we need a build-time libc.so linker script?) Florian Weimer
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

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).