public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* How to build an RPATH into gcc?
@ 2004-05-02 12:56 Adrian Bunk
  2004-05-02 23:35 ` llewelly
  2004-05-05  2:26 ` Ian Lance Taylor
  0 siblings, 2 replies; 14+ messages in thread
From: Adrian Bunk @ 2004-05-02 12:56 UTC (permalink / raw)
  To: gcc-help

Hi,

if the following problem is a RTFM, I'd be glad if someone could give me
a pointer to the corresponting "M"....

I have the following problem when building gcc 3.3.3 or 3.4.0 on a 
sparc-unknown-netbsdelf1.5 system:

The build works fine, using
  ../configure
  make bootstrap
but the binary doesn't run:

<--  snip  -->

$ ./gcc
Shared object "libintl.so.5" not found
$ objdump -p gcc
...
Dynamic Section:
  NEEDED      libintl.so.5
  NEEDED      libiconv.so.4
  NEEDED      libc.so.12
  INIT        0x10de0
...

<--  snip  -->

libintl and libiconv are in /usr/local/lib.

  LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
didn't work

  LD_LIBRARY_PATH=/usr/local/lib ./gcc
works but isn't optimal.

It might be very simple, but I don't find the solution myself...

TIA
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-02 12:56 How to build an RPATH into gcc? Adrian Bunk
@ 2004-05-02 23:35 ` llewelly
  2004-05-02 23:42   ` Adrian Bunk
  2004-05-05  2:26 ` Ian Lance Taylor
  1 sibling, 1 reply; 14+ messages in thread
From: llewelly @ 2004-05-02 23:35 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

> Hi,
> 
> if the following problem is a RTFM, I'd be glad if someone could give me
> a pointer to the corresponting "M"....
> 
> I have the following problem when building gcc 3.3.3 or 3.4.0 on a 
> sparc-unknown-netbsdelf1.5 system:
> 
> The build works fine, using
>   ../configure
>   make bootstrap
> but the binary doesn't run:
> 
> <--  snip  -->
> 
> $ ./gcc
> Shared object "libintl.so.5" not found
> $ objdump -p gcc
> ...
> Dynamic Section:
>   NEEDED      libintl.so.5
>   NEEDED      libiconv.so.4
>   NEEDED      libc.so.12
>   INIT        0x10de0
> ...
> 
> <--  snip  -->
> 
> libintl and libiconv are in /usr/local/lib.
> 
>   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> didn't work
> 
>   LD_LIBRARY_PATH=/usr/local/lib ./gcc
> works but isn't optimal.
> 
> It might be very simple, but I don't find the solution myself...
[snip]

You have 3 alternatives;

    (0) build gcc staticly linked,
    (1) use LD_LIBRARY_PATH,
    (2) Read the netbsd docs looking for some equivalent of ldconfig. 

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

* Re: How to build an RPATH into gcc?
  2004-05-02 23:35 ` llewelly
@ 2004-05-02 23:42   ` Adrian Bunk
  2004-05-03  4:18     ` llewelly
  0 siblings, 1 reply; 14+ messages in thread
From: Adrian Bunk @ 2004-05-02 23:42 UTC (permalink / raw)
  To: llewelly; +Cc: gcc-help

On Sun, May 02, 2004 at 05:35:28PM -0600, llewelly@xmission.com wrote:
> Adrian Bunk <bunk@fs.tum.de> writes:
> 
> > Hi,
> > 
> > if the following problem is a RTFM, I'd be glad if someone could give me
> > a pointer to the corresponting "M"....
> > 
> > I have the following problem when building gcc 3.3.3 or 3.4.0 on a 
> > sparc-unknown-netbsdelf1.5 system:
> > 
> > The build works fine, using
> >   ../configure
> >   make bootstrap
> > but the binary doesn't run:
> > 
> > <--  snip  -->
> > 
> > $ ./gcc
> > Shared object "libintl.so.5" not found
> > $ objdump -p gcc
> > ...
> > Dynamic Section:
> >   NEEDED      libintl.so.5
> >   NEEDED      libiconv.so.4
> >   NEEDED      libc.so.12
> >   INIT        0x10de0
> > ...
> > 
> > <--  snip  -->
> > 
> > libintl and libiconv are in /usr/local/lib.
> > 
> >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > didn't work
> > 
> >   LD_LIBRARY_PATH=/usr/local/lib ./gcc
> > works but isn't optimal.
> > 
> > It might be very simple, but I don't find the solution myself...
> [snip]
> 
> You have 3 alternatives;
> 
>     (0) build gcc staticly linked,

Can I link only libintl and libiconv (but not libc) statically?
If yes, how?

>     (1) use LD_LIBRARY_PATH,

That's what I want to avoid, e.g. because this sometimes makes it 
non-trivial to compile other software.

>     (2) Read the netbsd docs looking for some equivalent of ldconfig. 

This would require root privileges I don't have on the machines in 
question.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-02 23:42   ` Adrian Bunk
@ 2004-05-03  4:18     ` llewelly
  2004-05-03 11:46       ` Adrian Bunk
  0 siblings, 1 reply; 14+ messages in thread
From: llewelly @ 2004-05-03  4:18 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

> On Sun, May 02, 2004 at 05:35:28PM -0600, llewelly@xmission.com wrote:
> > Adrian Bunk <bunk@fs.tum.de> writes:
> > 
> > > Hi,
> > > 
> > > if the following problem is a RTFM, I'd be glad if someone could give me
> > > a pointer to the corresponting "M"....
> > > 
> > > I have the following problem when building gcc 3.3.3 or 3.4.0 on a 
> > > sparc-unknown-netbsdelf1.5 system:
> > > 
> > > The build works fine, using
> > >   ../configure
> > >   make bootstrap
> > > but the binary doesn't run:
> > > 
> > > <--  snip  -->
> > > 
> > > $ ./gcc
> > > Shared object "libintl.so.5" not found
> > > $ objdump -p gcc
> > > ...
> > > Dynamic Section:
> > >   NEEDED      libintl.so.5
> > >   NEEDED      libiconv.so.4
> > >   NEEDED      libc.so.12
> > >   INIT        0x10de0
> > > ...
> > > 
> > > <--  snip  -->
> > > 
> > > libintl and libiconv are in /usr/local/lib.
> > > 
> > >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > > didn't work
> > > 
> > >   LD_LIBRARY_PATH=/usr/local/lib ./gcc
> > > works but isn't optimal.
> > > 
> > > It might be very simple, but I don't find the solution myself...
> > [snip]
> > 
> > You have 3 alternatives;
> > 
> >     (0) build gcc staticly linked,
> 
> Can I link only libintl and libiconv (but not libc) statically?
> If yes, how?

I don't think this can be done without serious hacking of the gcc
    configure and build system.

You might try setting LDFLAGS to 
    '/usr/local/libintl.a /usr/local/libiconv.a' before running
    configure, but I don't think that will work.

> 
> >     (1) use LD_LIBRARY_PATH,
> 
> That's what I want to avoid, e.g. because this sometimes makes it 
> non-trivial to compile other software.

I forgot to mention that you could also use LD_PRELOAD, but that has
    a similar disadvantage. But LD_PRELOAD allows you to list only
    specific libraries, instead of whole directories.

Maybe a wrapper script using LD_PRELOAD or LD_LIBRARY_PATH would be
    appropriate. 

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

* Re: How to build an RPATH into gcc?
  2004-05-03  4:18     ` llewelly
@ 2004-05-03 11:46       ` Adrian Bunk
  0 siblings, 0 replies; 14+ messages in thread
From: Adrian Bunk @ 2004-05-03 11:46 UTC (permalink / raw)
  To: llewelly; +Cc: gcc-help

On Sun, May 02, 2004 at 10:18:46PM -0600, llewelly@xmission.com wrote:
> Adrian Bunk <bunk@fs.tum.de> writes:
>...
> > > You have 3 alternatives;
> > > 
> > >     (0) build gcc staticly linked,
> > 
> > Can I link only libintl and libiconv (but not libc) statically?
> > If yes, how?
> 
> I don't think this can be done without serious hacking of the gcc
>     configure and build system.
> 
> You might try setting LDFLAGS to 
>     '/usr/local/libintl.a /usr/local/libiconv.a' before running
>     configure, but I don't think that will work.

If a -R/usr/local/lib (as tried first) in LDFLAGS would have worked,
there was no problem.

> > 
> > >     (1) use LD_LIBRARY_PATH,
> > 
> > That's what I want to avoid, e.g. because this sometimes makes it 
> > non-trivial to compile other software.
> 
> I forgot to mention that you could also use LD_PRELOAD, but that has
>     a similar disadvantage. But LD_PRELOAD allows you to list only
>     specific libraries, instead of whole directories.
>...

LD_PRELOAD can't help with my problem.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-02 12:56 How to build an RPATH into gcc? Adrian Bunk
  2004-05-02 23:35 ` llewelly
@ 2004-05-05  2:26 ` Ian Lance Taylor
  2004-05-06  0:17   ` Adrian Bunk
  1 sibling, 1 reply; 14+ messages in thread
From: Ian Lance Taylor @ 2004-05-05  2:26 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

>   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> didn't work

Why didn't this work?  Does the sparc-netbsdelf1.5 linker support the
-R option?  If it does not support -R, does it support --rpath?  Was
the -R option actually used when linking gcc?

Ian

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

* Re: How to build an RPATH into gcc?
  2004-05-05  2:26 ` Ian Lance Taylor
@ 2004-05-06  0:17   ` Adrian Bunk
  2004-05-06  0:36     ` Ian Lance Taylor
  2004-05-06 12:10     ` bug - pointer to false Eljay Love-Jensen
  0 siblings, 2 replies; 14+ messages in thread
From: Adrian Bunk @ 2004-05-06  0:17 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

On Tue, May 04, 2004 at 10:26:31PM -0400, Ian Lance Taylor wrote:
> Adrian Bunk <bunk@fs.tum.de> writes:
> 
> >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > didn't work
> 
> Why didn't this work?  Does the sparc-netbsdelf1.5 linker support the
> -R option?  If it does not support -R, does it support --rpath?  Was

-R is not an option for ld, it's an option for gcc.

> the -R option actually used when linking gcc?

Obviously were the LDFLAGS not used...

> Ian

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-06  0:17   ` Adrian Bunk
@ 2004-05-06  0:36     ` Ian Lance Taylor
  2004-05-06  1:03       ` Adrian Bunk
  2004-05-06 12:10     ` bug - pointer to false Eljay Love-Jensen
  1 sibling, 1 reply; 14+ messages in thread
From: Ian Lance Taylor @ 2004-05-06  0:36 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

> > >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > > didn't work
> > 
> > Why didn't this work?  Does the sparc-netbsdelf1.5 linker support the
> > -R option?  If it does not support -R, does it support --rpath?  Was
> 
> -R is not an option for ld, it's an option for gcc.

That turns out not to be the case.  Insofar as gcc supports the -R
option, it supports it by passing it on to the linker.

In fact, the gcc documentation does not even document -R.  The GNU
linker documentation does document -R.

On my i386 GNU/Linux system (Fedora Core 1) I get this:

gossamer> gcc -R/tmp -o hello hello.o
gcc: unrecognized option `-R/tmp'
gossamer> gcc -Wl,-R/tmp -o hello hello.o
gossamer> objdump -p hello | grep RPATH
  RPATH       /tmp

> > the -R option actually used when linking gcc?
> 
> Obviously were the LDFLAGS not used...

The obvious case is that things work correctly.  When things fail to
work, you must look at what actually happened, not at what is obvious.

It might possibly be worth trying
    LDFLAGS="-Wl,-R/usr/local/lib" ../configure
Hard to say.

Ian

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

* Re: How to build an RPATH into gcc?
  2004-05-06  0:36     ` Ian Lance Taylor
@ 2004-05-06  1:03       ` Adrian Bunk
  2004-05-06  1:10         ` Ian Lance Taylor
  0 siblings, 1 reply; 14+ messages in thread
From: Adrian Bunk @ 2004-05-06  1:03 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

On Wed, May 05, 2004 at 08:36:03PM -0400, Ian Lance Taylor wrote:
> Adrian Bunk <bunk@fs.tum.de> writes:
> 
> > > >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > > > didn't work
> > > 
> > > Why didn't this work?  Does the sparc-netbsdelf1.5 linker support the
> > > -R option?  If it does not support -R, does it support --rpath?  Was
> > 
> > -R is not an option for ld, it's an option for gcc.
> 
> That turns out not to be the case.  Insofar as gcc supports the -R
> option, it supports it by passing it on to the linker.
> 
> In fact, the gcc documentation does not even document -R.  The GNU
> linker documentation does document -R.
> 
> On my i386 GNU/Linux system (Fedora Core 1) I get this:
> 
> gossamer> gcc -R/tmp -o hello hello.o
> gcc: unrecognized option `-R/tmp'
> gossamer> gcc -Wl,-R/tmp -o hello hello.o
> gossamer> objdump -p hello | grep RPATH
>   RPATH       /tmp

Yes, you are on Linux.

On NetBSD, it's available (see gcc/config/netbsd-elf.h).

> > > the -R option actually used when linking gcc?
> > 
> > Obviously were the LDFLAGS not used...
> 
> The obvious case is that things work correctly.  When things fail to
> work, you must look at what actually happened, not at what is obvious.
> 
> It might possibly be worth trying
>     LDFLAGS="-Wl,-R/usr/local/lib" ../configure
> Hard to say.

This wouldn't make any difference:
- the -R option works fine on my platform
- if LDFLAGS were used and -R wouldn't work, I should have gotten an 
  error while bootstrapping gcc

> Ian

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-06  1:03       ` Adrian Bunk
@ 2004-05-06  1:10         ` Ian Lance Taylor
  2004-05-06 13:48           ` Adrian Bunk
  0 siblings, 1 reply; 14+ messages in thread
From: Ian Lance Taylor @ 2004-05-06  1:10 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

> > > > >   LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../configure
> > > > > didn't work
> > > > 
> > > > Why didn't this work?  Does the sparc-netbsdelf1.5 linker support the
> > > > -R option?  If it does not support -R, does it support --rpath?  Was
> > > 
> > > -R is not an option for ld, it's an option for gcc.
> > 
> > That turns out not to be the case.  Insofar as gcc supports the -R
> > option, it supports it by passing it on to the linker.
> > 
> > In fact, the gcc documentation does not even document -R.  The GNU
> > linker documentation does document -R.
> > 
> > On my i386 GNU/Linux system (Fedora Core 1) I get this:
> > 
> > gossamer> gcc -R/tmp -o hello hello.o
> > gcc: unrecognized option `-R/tmp'
> > gossamer> gcc -Wl,-R/tmp -o hello hello.o
> > gossamer> objdump -p hello | grep RPATH
> >   RPATH       /tmp
> 
> Yes, you are on Linux.
> 
> On NetBSD, it's available (see gcc/config/netbsd-elf.h).

True.  And note, in that file, how gcc implements -R by simply passing
it directly to the linker.

> > > > the -R option actually used when linking gcc?
> > > 
> > > Obviously were the LDFLAGS not used...
> > 
> > The obvious case is that things work correctly.  When things fail to
> > work, you must look at what actually happened, not at what is obvious.
> > 
> > It might possibly be worth trying
> >     LDFLAGS="-Wl,-R/usr/local/lib" ../configure
> > Hard to say.
> 
> This wouldn't make any difference:
> - the -R option works fine on my platform

Good to hear.  That answers my initial question.

> - if LDFLAGS were used and -R wouldn't work, I should have gotten an 
>   error while bootstrapping gcc

That is not necessarily the case, as when the gcc driver sees an
unrecognized option, it will issue a warning but will still exit with
a successful status (I think this is a bug and in fact I just filed a
PR about it, but it is true nonetheless).

Have you tried
    make LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
?

Ian

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

* bug - pointer to false
  2004-05-06  0:17   ` Adrian Bunk
  2004-05-06  0:36     ` Ian Lance Taylor
@ 2004-05-06 12:10     ` Eljay Love-Jensen
  2004-05-06 12:12       ` Eljay Love-Jensen
  1 sibling, 1 reply; 14+ messages in thread
From: Eljay Love-Jensen @ 2004-05-06 12:10 UTC (permalink / raw)
  To: gcc-help

Using GCC 3.3.1 I ran into this bug:

// g++ -pedantic -W -Wall foo.cpp
int main()
{
     int* p = 0;

     // 0 is okay.
     p = 0;

     // false should cause a compile error,
     // "error: cannot convert `bool' to `int*' in assignment"
     // but it did not!
     // (Keep in mind "false" is typed to bool.)
     p = false;
}

Has this bug been fixed in a later version, GCC 3.3.2+ or GCC 3.4.x?

Or did I miss a compile flag to enable this error?

Thanks,
--Eljay

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

* Re: bug - pointer to false
  2004-05-06 12:10     ` bug - pointer to false Eljay Love-Jensen
@ 2004-05-06 12:12       ` Eljay Love-Jensen
  0 siblings, 0 replies; 14+ messages in thread
From: Eljay Love-Jensen @ 2004-05-06 12:12 UTC (permalink / raw)
  To: gcc-help

Ooops, my bad.  Nevermind.

    A null pointer constant is an integral constant expression (5.19)
    rvalue of integer type that evaluates to zero. A null pointer
    constant can be converted to a pointer type; the result is the
    null pointer value of that type and is distinguishable from every
    other value of pointer to object or pointer to function type...

--Eljay

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

* Re: How to build an RPATH into gcc?
  2004-05-06  1:10         ` Ian Lance Taylor
@ 2004-05-06 13:48           ` Adrian Bunk
  2004-05-06 13:59             ` Ian Lance Taylor
  0 siblings, 1 reply; 14+ messages in thread
From: Adrian Bunk @ 2004-05-06 13:48 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: gcc-help

On Wed, May 05, 2004 at 09:10:13PM -0400, Ian Lance Taylor wrote:
>...
> Have you tried
>     make LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
> ?

Yes, it doesn't work.

> Ian

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

* Re: How to build an RPATH into gcc?
  2004-05-06 13:48           ` Adrian Bunk
@ 2004-05-06 13:59             ` Ian Lance Taylor
  0 siblings, 0 replies; 14+ messages in thread
From: Ian Lance Taylor @ 2004-05-06 13:59 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: gcc-help

Adrian Bunk <bunk@fs.tum.de> writes:

> On Wed, May 05, 2004 at 09:10:13PM -0400, Ian Lance Taylor wrote:
> >...
> > Have you tried
> >     make LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
> > ?
> 
> Yes, it doesn't work.

Works for me, on mainline.

Ian

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

end of thread, other threads:[~2004-05-06 13:59 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-02 12:56 How to build an RPATH into gcc? Adrian Bunk
2004-05-02 23:35 ` llewelly
2004-05-02 23:42   ` Adrian Bunk
2004-05-03  4:18     ` llewelly
2004-05-03 11:46       ` Adrian Bunk
2004-05-05  2:26 ` Ian Lance Taylor
2004-05-06  0:17   ` Adrian Bunk
2004-05-06  0:36     ` Ian Lance Taylor
2004-05-06  1:03       ` Adrian Bunk
2004-05-06  1:10         ` Ian Lance Taylor
2004-05-06 13:48           ` Adrian Bunk
2004-05-06 13:59             ` Ian Lance Taylor
2004-05-06 12:10     ` bug - pointer to false Eljay Love-Jensen
2004-05-06 12:12       ` Eljay Love-Jensen

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