[adtools] -use-dynld - Why was it added?

  • From: Trevor Scroggins <trevor.scroggins@xxxxxxxxx>
  • To: adtools@xxxxxxxxxxxxx
  • Date: Wed, 4 Aug 2010 14:20:42 -0700

I've been toying with the gcc/g++ specs and reading the list archives,
and I can't find a justification for the -use-dynld switch. As an
experiment, I removed -use-dynld and REAL_LIBGCC_SPEC completely,
renamed libgcc.so back to libgcc_s.so (a symbolic link from libgcc.so
to libgcc_s.so satisfies legacy users), and made the following changes
to LINK_SPEC and LINK_SHLIB:

#define LINK_SPEC "\
--defsym __amigaos4__=1 \
%{static: -Bstatic} %{!static: -Bdynamic} \
-q -d %{h*} %{v:-V} %{G*} \
%{Wl,*:%*} %{YP,*} %{R*} \
%{Qy:} %{!Qn:-Qy} \
%(link_shlib) %(link_text) \
%{mbaserel: %{msdata|msdata=default|msdata=sysv: %e-mbaserel and
-msdata options are incompatible}} \
%{mcrt=clib2|mcrt=clib2-ts: %(link_clib2); \
mcrt=ixemul: %(link_ixemul); \
mcrt=libnix: %(link_libnix); \
mcrt=newlib: %(link_newlib); \
mcrt=default|!mcrt=*: %(link_amiga_default); \
: %eInvalid C runtime library} \
-L%(base_sdk)local/common/lib%(lib_subdir_type) \
%{newlib: %e-newlib is obsolete, use -mcrt=newlib instead}"

#define LINK_SHLIB "\
%{shared:-shared --defsym __dynld_version__=1}"

I'm using -Bdynamic instead of -dy for consistency with -Bstatic.
Using these specs, linking to shared libraries is preferred over
static libraries except in the case of libgcc, which requires
-shared-libgcc. (Note, Linux compilers define USE_LD_AS_NEEDED to get
-lgcc_s automatically, but that overrides LINK_EH_SPEC.)

The original LINK_SHLIB spec mandated dynamic linking of dependencies
in shared libraries. Is this really required? We can still use 'gcc
-shared -o foo.so foo.o -Wl,-Bstatic -lbar -Wl,-Bdynamic' or 'gcc
-shared -o foo.so foo.o libbar.a' to override the current behavior,
but if dynamic linking is required, is either of those "supported?"

The SDK says, "The newlib library can only be used as a shared library
and supports the new shared objects." If that is true, why do we have
libc.a, and why isn't dynamic linking the default?

I haven't looked at ld in detail, but at first glance, it looks like
dynamic linking is the default behavior when neither -Bstatic/-dn nor
-Bdynamic/-dy is passed.

Incidentally, these changes also fix automatic libstdc++ linking
behavior in g++.

The point of this and some of my other posts is: Why doesn't our gcc
behave like (almost) everyone else's gcc? :-)

Trev
-- 
______________________________________________________________________________
Amiga Development tools ML - //www.freelists.org/list/adtools
Homepage...................: http://www.sourceforge.net/projects/adtools
Listserver help............: mailto:adtools-request@xxxxxxxxxxxxx?Subject=HELP

Other related posts: