Bug 25859 - gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open
Summary: gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-19 15:46 UTC by John David Anglin
Modified: 2006-01-25 23:05 UTC (History)
3 users (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2006-01-25 22:58:34


Attachments
Makefile.in.d (345 bytes, text/plain)
2006-01-20 15:08 UTC, dave
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2006-01-19 15:46:27 UTC
# gnattools2
make -C ../gcc/ada/tools -f ../Makefile \
          "CC=../../xgcc -B../../" "CFLAGS=-g -O2" "ADAFLAGS=-gnatpg -gnata" "IN
CLUDES=-I. -I.. -I../.. -I/home/dave/gcc-4.1/gcc/gcc/ada -I/home/dave/gcc-4.1/gc
c/gcc/ada/../config -I/home/dave/gcc-4.1/gcc/gcc/ada/../../include -I/home/dave/
gcc-4.1/gcc/gcc/ada/.." "ADA_INCLUDES=-I../rts -I. -I/home/dave/gcc-4.1/gcc/gcc/
ada" "exeext=" "fsrcdir=/home/dave/gcc-4.1/gcc/gcc/ada" "srcdir=/home/dave/gcc-4
.1/gcc/gcc/ada" "GNATMAKE=../../gnatmake" "GNATLINK=../../gnatlink" "GNATBIND=..
/../gnatbind" "TOOLSCASE=native" \
          ../../gnatchop ../../gnat ../../gnatkr ../../gnatls ../../gnatprep ../
../gnatxref ../../gnatfind ../../gnatname ../../gnatclean ../../gprmake
make[4]: Entering directory `/home/dave/gcc-4.1/objdir/gcc/ada/tools'
../../gnatmake -c -I../rts -I. -I/home/dave/gcc-4.1/gcc/gcc/ada gnatchop --GCC="
../../xgcc -B../../ -g -O2      -gnatpg -gnata"
../../gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open
 shared object file: No such file or directory
make[4]: *** [../../gnatchop] Error 127

This is a result of a change yesterday which bumped the libgcc_s
version.  Obviously, the GCC build machinary doesn't set LD_LIBRARY_PATH
so that the newly built tools use the new version of libgcc_s.

This doesn't happen on the trunk.
Comment 1 charlet@adacore.com 2006-01-19 15:53:35 UTC
Subject: Re:   New: gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> This doesn't happen on the trunk.

The following from ada/Makefile.in is supposed to take care of that:

GCC_LINK="$(CC) -static-libgcc $(ADA_INCLUDES)"

(and uses of $(GCC_LINK) elsewhere in the tools).

Basically we certainly do *not* want to link with libgcc_s, in particular
to avoid this kind of nightmare.

This was fixed as part of:

2005-02-09  Arnaud Charlet  <charlet@adacore.com>

        PR ada/16592

        * Makefile.in: Link all gnat tools with -static-libgcc, since
        -shared-libgcc is now used by default on some systems (e.g. linux with
        recent binutils).

I am surprised that there's a regression between 4.1 and trunk here.

Arno
Comment 2 dave 2006-01-19 15:53:47 UTC
Subject: Re:   New: gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> ../../gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot
> open
>  shared object file: No such file or directory

A work around is to export an appropriate LD_LIBRARY_PATH in the build
script, or add it to the environment variables passed to make.

Dave
Comment 3 dave 2006-01-19 16:10:32 UTC
Subject: Re:  gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> ------- Comment #1 from charlet at adacore dot com  2006-01-19 15:53 -------
> Subject: Re:   New: gnatmake: error while loading shared libraries:
> libgcc_s.so.4: cannot open
> 
> > This doesn't happen on the trunk.
> 
> The following from ada/Makefile.in is supposed to take care of that:
> 
> GCC_LINK="$(CC) -static-libgcc $(ADA_INCLUDES)"
> 
> (and uses of $(GCC_LINK) elsewhere in the tools).

For some reason, the above doesn't seem to have been used in linking gnatmake:

../../xgcc -B../../ -DIN_GCC   `echo -g -O2 -W -Wall -Wwrite-strings -Wstrict-pr
ototypes -Wmissing-prototypes  |sed -e 's/-pedantic//g' -e 's/-Wtraditional//g'` -o ../../gnatmake b_gnatm.o a-except.o ctrl_c.o ali.o ali-util.o s-casuti.o alloc.o atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o prj-proc.o prj-strt.o prj-tree.o prj-util.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o scans.o scng.o sdefault.o sfn_scan.o s-purexc.o s-htable.o sinfo.o sinput.o sinput-c.o sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o uintp.o  uname.o urealp.o usage.o widechar.!
 o  \
		  ../rts/libgnat.a  ../../prefix.o ../../version.o link.o ../../../libiberty/libiberty.a

Possibly, this is the reason:

# Likewise for the tools
../../gnatmake$(exeext): $(P) b_gnatm.o link.o $(GNATMAKE_OBJS)
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) \
	      $(TOOLS_LIBS)

Dave
Comment 4 charlet@adacore.com 2006-01-19 16:19:41 UTC
Subject: Re:  gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> For some reason, the above doesn't seem to have been used in linking gnatmake:

Indeed, gnatmake has to be handled specially.

So I guess the gnatmake rule needs to use $(GCC_LINK)
one way or another (although there should be no difference between
trubk and 4.1 in that respect).

Same for gnatlink.

Arno
Comment 5 dave 2006-01-19 16:41:13 UTC
Subject: Re:  gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> So I guess the gnatmake rule needs to use $(GCC_LINK)

I'll try the above change

> one way or another (although there should be no difference between
> trubk and 4.1 in that respect).

In the trunk, I see the following in the build log:

 export GMPINC; LD_LIBRARY_PATH=`echo "$r/hppa-linux/libstdc++-v3/.libs:$r/hppa-linux/libmudflap/.libs:$r/hppa-linux/libssp/.libs:$r/./gcc:$r/./prev-gcc:$LD_LIBRARY_PATH" | sed 's,::*,:,g;s,^:*,,;s,:*$,,'`; export LD_LIBRARY_PATH; LD_LIBRARY_PATH=`echo "$LD_LIBRARY_PATH" | sed 's,::*,:,g;s,^:*,,;s,:*$,,'`; export LD_LIBRARY_PATH; \
	 echo Configuring stage 1 in ./gcc ; \

Dave
Comment 6 dave 2006-01-20 15:08:02 UTC
Subject: Re:  gnatmake: error while loading shared libraries: libgcc_s.so.4: cannot open

> Indeed, gnatmake has to be handled specially.
> 
> So I guess the gnatmake rule needs to use $(GCC_LINK)
> one way or another (although there should be no difference between
> trubk and 4.1 in that respect).

It's not possible to use $(GCC_LINK) directly because of the quotes
in the define of GCC_LINK.  It might be best to remove them and modify
each use as necessary.  However, the following change is less invasive
and fixes the problem.

Thoughts.

Dave
Comment 7 dave 2006-01-20 15:08:03 UTC
Created attachment 10686 [details]
Makefile.in.d
Comment 8 Eric Botcazou 2006-01-25 23:02:59 UTC
Subject: Bug 25859

Author: ebotcazou
Date: Wed Jan 25 23:02:55 2006
New Revision: 110229

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110229
Log:
	PR bootstrap/25859
	* Makefile.in (GCC_LINK): Remove quotes.
	(tools targets): Link with either $(GNATLINK) --GCC="$(GCC_LINK)"
	or $(GCC_LINK).

	(powerpc-darwin): Pass -shared-libgcc when building shared library.


Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/Makefile.in

Comment 9 Eric Botcazou 2006-01-25 23:04:02 UTC
Subject: Bug 25859

Author: ebotcazou
Date: Wed Jan 25 23:03:55 2006
New Revision: 110230

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110230
Log:
	PR bootstrap/25859
	* Makefile.in (GCC_LINK): Remove quotes.
	(tools targets): Link with either $(GNATLINK) --GCC="$(GCC_LINK)"
	or $(GCC_LINK).

	(powerpc-darwin): Pass -shared-libgcc when building shared library.


Modified:
    branches/gcc-4_1-branch/gcc/ada/ChangeLog
    branches/gcc-4_1-branch/gcc/ada/Makefile.in

Comment 10 Eric Botcazou 2006-01-25 23:05:09 UTC
Should be fixed now.