This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ada/15102] New: Building shared libgnat may fail linking non-PIC object files


During a mainline bootstrap with ada included, I had to restart make
bootstrap to continue after a (non-ada related) problem.  Although libgnat
had been built successfully the first time (and there was really nothing to
do), the second build failed:

cd rts; ../../xgcc -B../../ -shared -fPIC \
	-o libgnat-3.4.so \
	a-caldel.o a-calend.o a-chahan.o a-charac.o a-chlat1.o a-chlat9.o a-colien.o a-colire.o a-comlin.o a-cwila1.o a-cwila9.o a-decima.o a-diocst.o a-direct.o a-direio.o a-dirval.o a-einuoc.o a-elchha.o a-except.o a-exctra.o a-filico.o a-finali.o a-flteio.o a-fwteio.o a-inteio.o a-ioexce.o a-iwteio.o a-lfteio.o a-lfwtio.o a-liteio.o a-liwtio.o a-llftio.o a-llfwti.o a-llitio.o a-lliwti.o a-ncelfu.o a-ngcefu.o a-ngcoty.o a-ngelfu.o a-nlcefu.o a-nlcoty.o a-nlelfu.o a-nllcef.o a-nllcty.o a-nllefu.o a-nscefu.o a-nscoty.o a-nselfu.o a-nucoty.o a-nudira.o a-nuelfu.o a-nuflra.o a-numaux.o a-numeri.o a-sequio.o a-sfteio.o a-sfwtio.o a-siocst.o a-siteio.o a-siwtio.o a-ssicst.o a-ssitio.o a-ssiwti.o a-stmaco.o a-storio.o a-strbou.o a-stream.o a-strfix.o a-string.o a-strmap.o a-strsea.o a-strsup.o a-strunb.o a-ststio.o a-stunau.o a-stwibo.o a-stwifi.o a-stwima.o a-stwise.o a-stwisu.o a-stwiun.o a-suteio.o a-swuwti.o a-swmwco.o a-tags.o a-teioed.o a-textio.o a-ticoau.o a-ticoio.o a-tideau.o !
 a-tideio.o a-tienau.o a-tienio.o a-tifiio.o a-tiflau.o a-tiflio.o a-tigeau.o a-tiinau.o a-tiinio.o a-timoau.o a-timoio.o a-tiocst.o a-titest.o a-unccon.o a-uncdea.o a-witeio.o a-wtcoau.o a-wtcoio.o a-wtcstr.o a-wtdeau.o a-wtdeio.o a-wtedit.o a-wtenau.o a-wtenio.o a-wtfiio.o a-wtflau.o a-wtflio.o a-wtgeau.o a-wtinau.o a-wtinio.o a-wtmoau.o a-wtmoio.o a-wttest.o ada.o calendar.o g-arrspl.o g-awk.o g-bubsor.o g-busora.o g-busorg.o g-calend.o g-casuti.o g-catiio.o g-cgi.o g-cgicoo.o g-cgideb.o g-comlin.o g-comver.o g-crc32.o g-ctrl_c.o g-curexc.o g-debuti.o g-debpoo.o g-diopit.o g-dirope.o g-dyntab.o g-except.o g-excact.o g-exctra.o g-expect.o g-flocon.o g-heasor.o g-hesora.o g-hesorg.o g-htable.o g-io.o g-io_aux.o g-locfil.o g-md5.o g-memdum.o g-moreex.o g-os_lib.o g-perhas.o g-pehage.o g-regexp.o g-regpat.o g-sestin.o g-soccon.o g-socket.o g-socthi.o g-soliop.o g-souinf.o g-speche.o g-spipat.o g-spitbo.o g-sptabo.o g-sptain.o g-sptavs.o g-string.o g-strspl.o g-table.o g-taslo!
 c.o g-traceb.o g-wistsp.o gnat.o i-c.o i-cexten.o i-cobol.o i-cpoint.o

 i-cpp.o i-cstrea.o i-cstrin.o i-fortra.o i-pacdec.o interfac.o ioexcept.o machcode.o s-addima.o s-arit64.o s-assert.o s-atacco.o s-auxdec.o s-bitops.o s-boarop.o s-carsi8.o s-carun8.o s-casi16.o s-casi32.o s-casi64.o s-casuti.o s-caun16.o s-caun32.o s-caun64.o s-chepoo.o s-crtl.o s-crc32.o s-direio.o s-errrep.o s-except.o s-exctab.o s-exnint.o s-exnllf.o s-exnlli.o s-expint.o s-explli.o s-expllu.o s-expmod.o s-expuns.o s-fatflt.o s-fatgen.o s-fatlfl.o s-fatllf.o s-fatsfl.o s-ficobl.o s-fileio.o s-finimp.o s-finroo.o s-fore.o s-geveop.o s-htable.o s-imgbiu.o s-imgboo.o s-imgcha.o s-imgdec.o s-imgenu.o s-imgint.o s-imgllb.o s-imglld.o s-imglli.o s-imgllu.o s-imgllw.o s-imgrea.o s-imguns.o s-imgwch.o s-imgwiu.o s-io.o s-gloloc.o s-maccod.o s-mantis.o s-mastop.o s-osprim.o s-pack03.o s-pack05.o s-pack06.o s-pack07.o s-pack09.o s-pack10.o s-pack11.o s-pack12.o s-pack13.o s-pack14.o s-pack15.o s-pack17.o s-pack18.o s-pack19.o s-pack20.o s-pack21.o s-pack22.o s-pack23.o s-pack24.o!
  s-pack25.o s-pack26.o s-pack27.o s-pack28.o s-pack29.o s-pack30.o s-pack31.o s-pack33.o s-pack34.o s-pack35.o s-pack36.o s-pack37.o s-pack38.o s-pack39.o s-pack40.o s-pack41.o s-pack42.o s-pack43.o s-pack44.o s-pack45.o s-pack46.o s-pack47.o s-pack48.o s-pack49.o s-pack50.o s-pack51.o s-pack52.o s-pack53.o s-pack54.o s-pack55.o s-pack56.o s-pack57.o s-pack58.o s-pack59.o s-pack60.o s-pack61.o s-pack62.o s-pack63.o s-parame.o s-parint.o s-pooglo.o s-pooloc.o s-poosiz.o s-powtab.o s-purexc.o s-restri.o s-rident.o s-rpc.o s-scaval.o s-secsta.o s-sequio.o s-shasto.o s-sopco3.o s-sopco4.o s-sopco5.o s-stache.o s-stchop.o s-stalib.o s-stoele.o s-stopoo.o s-stratt.o s-strops.o s-soflin.o s-memory.o s-memcop.o s-traceb.o s-traces.o s-traent.o s-unstyp.o s-vaflop.o s-valboo.o s-valcha.o s-valdec.o s-valenu.o s-valint.o s-vallld.o s-vallli.o s-valllu.o s-valrea.o s-valuns.o s-valuti.o s-valwch.o s-veboop.o s-vector.o s-vercon.o s-vmexta.o s-wchcnv.o s-wchcon.o s-wchjis.o s-wchstw.o !
 s-wchwts.o s-widboo.o s-widcha.o s-widenu.o s-widlli.o s-widllu.o s-wi

dwch.o s-wwdcha.o s-wwdenu.o s-wwdwch.o system.o text_io.o  adaint.o argv.o cio.o cstreams.o ctrl_c.o errno.o exit.o raise.o sysdep.o aux-io.o init.o cal.o final.o tracebak.o expect.o mkdir.o socket.o  \
	-Wl,-h,libgnat-3.4.so \
	-lposix4 -lnsl -lsocket -lm
Text relocation remains                 	referenced
    against symbol		    offset	in file
<unknown>                           0x1f58    	a-teioed.o

[43444 lines total omitted]

This happens for the following reason: on sparc-sun-solaris2.8 (and
i386-pc-solaris2.10, where I once observed the same problem), PIC and
non-PIC code is different and you usually cannot link non-PIC code into a
shared object since gcc -shared passes -z text to the linker.

On Solaris 2, gnatlib is built twice, once (via gnatlib-shared-default)
with TARGET_LIBGCC2_CFLAGS added to GNATLIBCFLAGS, and a second time (via
gnatlib) without that macro.  TARGET_LIBGCC2_CFLAGS is -fPIC on Solaris 2,
so the first round through, you get PIC objects and libgnat-3.4.so is built
without problems.  The second time through, all objects are rebuilt without
-fPIC to build libgnat.a.

If make gnatlib-shared-dual is invoked a second time (as happens during a
restarted bootstrap), the non-PIC object files still lying around are used
to build libgnat-3.4.so, which of course fails now.

It seems there are two problems here:

* PIC and non-PIC objects are usually created in the same directory and
  cannot be distinguished.  This must be fixed since on platforms where PIC
  code is not the default, using non-PIC objects to create a shared library
  fails as above.  One may use the libtool model as a guideline, where PIC
  objects are created in a .libs subdir, and non-PIC objects in the working
  directory.

* It seems that it cannot be guaranteed that the proper PIC flags are
  passed building PIC objects, but that they are picked up more or less by
  accident from TARGET_LIBGCC2_CFLAGS.  libada needs to deal with this
  properly.

Environment:
System: SunOS zeder 5.8 Generic_108528-23 sun4u sparc SUNW,Ultra-80
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: /vol/gnu/src/gcc/gcc-dist/configure --prefix=/vol/gcc --with-local-prefix=/vol/gcc --disable-nls

How-To-Repeat:
Restart a bootstrap as described above.

-- 
           Summary: Building shared libgnat may fail linking non-PIC object
                    files
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ro at techfak dot uni-bielefeld dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: sparc-sun-solaris2.8
  GCC host triplet: sparc-sun-solaris2.8
GCC target triplet: sparc-sun-solaris2.8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15102


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]