This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: AIX shared library support and GCC PIC libraries
- To: law at cygnus dot com
- Subject: Re: AIX shared library support and GCC PIC libraries
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Sat, 06 May 2000 01:47:03 -0400
- cc: gcc-patches at gcc dot gnu dot org, Geoff Keating <geoffk at cygnus dot com>
>>>>> Jeffrey A Law writes:
Jeff> The only potential problem area I see is that some systems (alpha?) also
Jeff> always generate PIC by default, but do require -fPIC to get code that is
Jeff> suitable for shared libraries. But those kinds of systems can just
Jeff> define PICFLAG, right?
Geoff mentioned something about this as well, but I understood
from him that Alpha/OSF did not require any special flag. OSF does not
seem to require any special flag for shared libraries, according to
libstdc++/config/dec-osf.ml. Alpha using ELF does require such a flag,
but PICFLAG is defined in config/mh-elfalphpic for that case.
This is exactly the type of platform dependency that I am worried
about, but it seems that everything already should be defined correctly if
correct shared libraries are being produced with the existing structure.
My entire proposed patch is appended. I hope that anyone who
knows about a GCC target with a subtle and/or obscure PIC dependency
reviews this.
With this patch, standard AIX shared libraries are produced. Note
that AIX shared libraries do not have the filenames that one encounters on
SVR4 platforms. The convention is the shared object is labeled shr.o (or
shrXXX.o where XXX is an interface revision number) and the object is
archived in a standard archive library, e.g. libstdc++.a.
A shared library may contain multiple shared objects as archive
members and backward compatible shared objects are hidden inside the
shared library (e.g., shr12.o inside libfoo.a, not libfoo.so.1.2). The
file extension ".so" does not appear. ".so" normally signifies a shared
object built with SVR4 semantics using AIX -brtl option, for example.
Thanks, David
* configure.in: Special case powerpc*-*-aix* as target.
* libiberty/Makefile.in, libio/config.shared,
libstdc++/Makefile.in: Change "pic" to depend on $(PICFLAG), not
on $(enable_shared).
* aix.ml: Build AIX-style shared library.
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/configure.in,v
retrieving revision 1.47
diff -c -p -r1.47 configure.in
*** configure.in 2000/04/06 06:48:16 1.47
--- configure.in 2000/05/06 05:12:28
*************** if [ x${shared} = xyes ]; then
*** 1018,1023 ****
--- 1018,1026 ----
i[3456]86-*)
target_makefile_frag="${target_makefile_frag} config/mt-x86pic"
;;
+ powerpc*-*-aix*)
+ # We don't want -fPIC on AIX.
+ ;;
powerpc*-*)
target_makefile_frag="${target_makefile_frag} config/mt-ppcpic"
;;
Index: libiberty/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libiberty/Makefile.in,v
retrieving revision 1.42
diff -c -p -r1.42 Makefile.in
*** Makefile.in 2000/04/29 14:25:12 1.42
--- Makefile.in 2000/05/06 05:12:28
*************** INCDIR=$(srcdir)/$(MULTISRCTOP)../includ
*** 108,115 ****
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiberty_warn_cflags@
.c.o:
! test x"$(enable_shared)" != xyes || \
! $(COMPILE.c) $(PICFLAG) $< -o pic/$@
$(COMPILE.c) $<
info: info-subdir
--- 108,116 ----
COMPILE.c = $(CC) -c @DEFS@ $(LIBCFLAGS) -I. -I$(INCDIR) $(HDEFINES) @ac_libiberty_warn_cflags@
.c.o:
! if [ x"$(PICFLAG)" != x ]; then \
! $(COMPILE.c) $(PICFLAG) $< -o pic/$@; \
! else true; fi
$(COMPILE.c) $<
info: info-subdir
*************** required-list: Makefile
*** 185,191 ****
echo $(REQUIRED_OFILES) > required-list
stamp-picdir:
! if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \
mkdir pic; \
else true; fi
touch stamp-picdir
--- 186,192 ----
echo $(REQUIRED_OFILES) > required-list
stamp-picdir:
! if [ x"$(PICFLAG)" != x ] && [ ! -d pic ]; then \
mkdir pic; \
else true; fi
touch stamp-picdir
Index: libio/config.shared
===================================================================
RCS file: /cvs/gcc/egcs/libio/config.shared,v
retrieving revision 1.18
diff -c -p -r1.18 config.shared
*** config.shared 1999/02/03 21:11:03 1.18
--- config.shared 2000/05/06 05:12:28
*************** echo >&2 '.SUFFIXES: .o .C .cc .c'
*** 267,289 ****
echo >&2 'COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES) $(MT_CFLAGS)'
echo >&2 '.c.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' test x"$(enable_shared)" != xyes ||\'
! echo >&2 ' $(COMPILE.c) $(PICFLAG) $< -o pic/$@'
fi
echo >&2 ' $(COMPILE.c) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
echo >&2 'COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES) $(MT_CFLAGS)'
echo >&2 '.C.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' test x"$(enable_shared)" != xyes ||\'
! echo >&2 ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@'
fi
echo >&2 ' $(COMPILE.cc) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
echo >&2 '.cc.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' test x"$(enable_shared)" != xyes || \'
! echo >&2 ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@'
fi
echo >&2 ' $(COMPILE.cc) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
--- 267,292 ----
echo >&2 'COMPILE.c = $(CC) -c $(XCFLAGS) $(CINCLUDES) $(MT_CFLAGS)'
echo >&2 '.c.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' if [ x"$(PICFLAG)" != x ]; then \'
! echo >&2 ' $(COMPILE.c) $(PICFLAG) $< -o pic/$@; \'
! echo >&2 ' else true; fi'
fi
echo >&2 ' $(COMPILE.c) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
echo >&2 'COMPILE.cc = $(CXX) -c $(XCXXFLAGS) $(CXXINCLUDES) $(MT_CFLAGS)'
echo >&2 '.C.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' if [ x"$(PICFLAG)" != x ]; then \'
! echo >&2 ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@; \'
! echo >&2 ' else true; fi'
fi
echo >&2 ' $(COMPILE.cc) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
echo >&2 '.cc.o:'
if [ "${LIBDIR}" = "yes" ]; then
! echo >&2 ' if [ x"$(PICFLAG)" != x ]; then \'
! echo >&2 ' $(COMPILE.cc) $(PICFLAG) $< -o pic/$@; \'
! echo >&2 ' else true; fi'
fi
echo >&2 ' $(COMPILE.cc) $<'
[ "${TOUCH_ON_COMPILE}" = "yes" ] && echo >&2 ' @touch stamp'
*************** fi
*** 299,305 ****
if [ "${LIBDIR}" = "yes" ]; then
echo >&2 ''
echo >&2 'stamp-picdir:'
! echo >&2 ' if [ x"$(enable_shared)" = xyes ] && [ ! -d pic ]; then \'
echo >&2 ' mkdir pic; \'
echo >&2 ' else true; fi'
echo >&2 ' touch stamp-picdir'
--- 302,308 ----
if [ "${LIBDIR}" = "yes" ]; then
echo >&2 ''
echo >&2 'stamp-picdir:'
! echo >&2 ' if [ x"$(PICFLAG)" != x ] && [ ! -d pic ]; then \'
echo >&2 ' mkdir pic; \'
echo >&2 ' else true; fi'
echo >&2 ' touch stamp-picdir'
Index: libstdc++/Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++/Makefile.in,v
retrieving revision 1.36
diff -c -p -r1.36 Makefile.in
*** Makefile.in 2000/04/24 17:31:57 1.36
--- Makefile.in 2000/05/06 05:12:29
*************** stdlist: $(IO_DIR)/iostream.list $(OBJS)
*** 84,90 ****
piclist: stdlist
-rm -f tlist
cp stdlist tlist
! if [ x"$(enable_shared)" = xyes ]; then \
sed 's,\([A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \
mv tlist2 tlist ; \
else true ; fi
--- 84,90 ----
piclist: stdlist
-rm -f tlist
cp stdlist tlist
! if [ x"$(PICFLAG)" != x ]; then \
sed 's,\([A-Za-z_]*\.o\),pic/\1,g' tlist > tlist2 ; \
mv tlist2 tlist ; \
else true ; fi
*************** stmp-string: ${srcdir}/sinst.cc ${srcdir
*** 143,149 ****
${srcdir}/std/bastring.cc ${srcdir}/std/straits.h
for name in $(STRFUNCS) $(STRIO); do \
echo c$${name}; \
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DC -D$${name} ${srcdir}/sinst.cc \
-o pic/c$${name}.o; \
else true ; fi; \
--- 143,149 ----
${srcdir}/std/bastring.cc ${srcdir}/std/straits.h
for name in $(STRFUNCS) $(STRIO); do \
echo c$${name}; \
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DC -D$${name} ${srcdir}/sinst.cc \
-o pic/c$${name}.o; \
else true ; fi; \
*************** stmp-string: ${srcdir}/sinst.cc ${srcdir
*** 156,162 ****
bigstmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \
${srcdir}/std/bastring.cc ${srcdir}/std/straits.h
echo cstring
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DC \
`for N in $(STRFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o pic/cstrmain.o; \
--- 156,162 ----
bigstmp-string: ${srcdir}/sinst.cc ${srcdir}/std/bastring.h \
${srcdir}/std/bastring.cc ${srcdir}/std/straits.h
echo cstring
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DC \
`for N in $(STRFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o pic/cstrmain.o; \
*************** bigstmp-string: ${srcdir}/sinst.cc ${src
*** 164,170 ****
$(COMPILE.cc) -DC `for N in $(STRFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o cstrmain.o
echo cstrio
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DC \
`for N in $(STRIO); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o pic/cstrio.o; \
--- 164,170 ----
$(COMPILE.cc) -DC `for N in $(STRFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o cstrmain.o
echo cstrio
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DC \
`for N in $(STRIO); do echo " -D$${N}"; done` \
$(srcdir)/sinst.cc -o pic/cstrio.o; \
*************** stmp-complx: ${srcdir}/cinst.cc ${srcdir
*** 183,189 ****
${srcdir}/std/ldcomplex.h
for N in $(COMFUNCS) $(COMIO); do \
echo f$${N}; \
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DF -D$${N} $(srcdir)/cinst.cc \
-o pic/f$${N}.o; \
else true ; fi; \
--- 183,189 ----
${srcdir}/std/ldcomplex.h
for N in $(COMFUNCS) $(COMIO); do \
echo f$${N}; \
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DF -D$${N} $(srcdir)/cinst.cc \
-o pic/f$${N}.o; \
else true ; fi; \
*************** stmp-complx: ${srcdir}/cinst.cc ${srcdir
*** 191,197 ****
$(COMPILE.cc) -DF -D$${N} ${srcdir}/cinst.cc -o f$${N}.o; \
if [ $$? -eq 0 ]; then true; else exit 1; fi; \
echo d$${N}; \
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DD -D$${N} $(srcdir)/cinst.cc \
-o pic/d$${N}.o; \
else true ; fi; \
--- 191,197 ----
$(COMPILE.cc) -DF -D$${N} ${srcdir}/cinst.cc -o f$${N}.o; \
if [ $$? -eq 0 ]; then true; else exit 1; fi; \
echo d$${N}; \
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DD -D$${N} $(srcdir)/cinst.cc \
-o pic/d$${N}.o; \
else true ; fi; \
*************** stmp-complx: ${srcdir}/cinst.cc ${srcdir
*** 199,205 ****
$(COMPILE.cc) -DD -D$${N} ${srcdir}/cinst.cc -o d$${N}.o; \
if [ $$? -eq 0 ]; then true; else exit 1; fi; \
echo ld$${N}; \
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD -D$${N} $(srcdir)/cinst.cc \
-o pic/ld$${N}.o; \
else true ; fi; \
--- 199,205 ----
$(COMPILE.cc) -DD -D$${N} ${srcdir}/cinst.cc -o d$${N}.o; \
if [ $$? -eq 0 ]; then true; else exit 1; fi; \
echo ld$${N}; \
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD -D$${N} $(srcdir)/cinst.cc \
-o pic/ld$${N}.o; \
else true ; fi; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 213,219 ****
${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \
${srcdir}/std/ldcomplex.h
echo fcomplex
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DF \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/fcomplex.o; \
--- 213,219 ----
${srcdir}/std/complext.cc ${srcdir}/std/dcomplex.h \
${srcdir}/std/ldcomplex.h
echo fcomplex
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DF \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/fcomplex.o; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 221,227 ****
$(COMPILE.cc) -DF `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o fcomplex.o
echo fcomio
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DF \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/fcomio.o; \
--- 221,227 ----
$(COMPILE.cc) -DF `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o fcomplex.o
echo fcomio
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DF \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/fcomio.o; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 229,235 ****
$(COMPILE.cc) -DF `for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o fcomio.o
echo dcomplex
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DD \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/dcomplex.o; \
--- 229,235 ----
$(COMPILE.cc) -DF `for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o fcomio.o
echo dcomplex
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DD \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/dcomplex.o; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 237,243 ****
$(COMPILE.cc) -DD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o dcomplex.o
echo dcomio
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DD \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/dcomio.o; \
--- 237,243 ----
$(COMPILE.cc) -DD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o dcomplex.o
echo dcomio
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DD \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/dcomio.o; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 245,251 ****
$(COMPILE.cc) -DD `for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o dcomio.o
echo ldcomplex
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/ldcomplex.o; \
--- 245,251 ----
$(COMPILE.cc) -DD `for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o dcomio.o
echo ldcomplex
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD \
`for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/ldcomplex.o; \
*************** bigstmp-complx: ${srcdir}/cinst.cc ${src
*** 253,259 ****
$(COMPILE.cc) -DLD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o ldcomplex.o
echo ldcomio
! if [ x"$(enable_shared)" = xyes ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/ldcomio.o; \
--- 253,259 ----
$(COMPILE.cc) -DLD `for N in $(COMFUNCS); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o ldcomplex.o
echo ldcomio
! if [ x"$(PICFLAG)" != x ]; then \
$(COMPILE.cc) $(PICFLAG) -DLD \
`for N in $(COMIO); do echo " -D$${N}"; done` \
$(srcdir)/cinst.cc -o pic/ldcomio.o; \
Index: libstdc++/config/aix.ml
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++/config/aix.ml,v
retrieving revision 1.2
diff -c -p -r1.2 aix.ml
*** aix.ml 1998/08/30 21:18:40 1.2
--- aix.ml 2000/05/06 05:12:29
***************
*** 1,9 ****
! # AIX has wierd shared/non-shared libraries.
! ARLIB = libstdc++-ar.a.$(VERSION)
! ARLINK = libstdc++-ar.a
! SHLINK = libstdc++.a
! LIBS = $(ARLIB) $(ARLINK) $(SHLIB) $(SHLINK)
! DEPLIBS = ../$(SHLIB)
SHDEPS = -lm
! SHFLAGS = -Wl,-unix
--- 1,30 ----
! # AIX has weird shared/non-shared libraries.
! ARLIB =
! ARLINK =
!
! # Build shared object with interface versioning in name.
! # Archive resulting shared object in a library.
! AIXLINK = libstdc++.a
! AIXLIB = libstdc++-$(VERSION).a
! AIXSHLIB = shr$(LIBSTDCXX_INTERFACE)$(CXX_INTERFACE).o
! SHFLAGS = -Wl,-bexpall
SHDEPS = -lm
! SHOPT = -shared
!
! LIBS = $(AIXLIB) $(AIXLINK)
!
! $(AIXSHLIB): stdlist
! $(CC) $(LIBCXXFLAGS) $(SHFLAGS) $(SHOPT) -o $(AIXSHLIB) `cat stdlist` $(SHDEPS)
!
! # Delete $(AIXSHLIB) so that it is not included in stdlist if rebuilding.
! $(AIXLIB): $(AIXSHLIB)
! -rm -f t$(AIXLIB)
! $(AR) $(AR_FLAGS) t$(AIXLIB) $(AIXSHLIB)
! mv t$(AIXLIB) $(AIXLIB)
! -rm -f $(AIXSHLIB)
!
! $(AIXLINK):
! -rm -f $(AIXLINK)
! $(LN_S) $(AIXLIB) $(AIXLINK) || cp $(AIXLIB) $(AIXLINK)
!