Ld_run_path

i just had something weird crop up when intalling ruby as root in a
non-standard place: compiling with LD_RUN_PATH=/non/standard/place/lib doesn’t
work since the linker doesn’t seem to take the env setting when user==root.
what else would be the preferred methods of encoding lib paths in ruby
extensions? DLDFLAGS?

-a

···

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================

Hi,

At Fri, 16 Apr 2004 16:04:19 +0900,
Ara.T.Howard wrote in [ruby-talk:97329]:

i just had something weird crop up when intalling ruby as root in a
non-standard place: compiling with LD_RUN_PATH=/non/standard/place/lib doesn’t
work since the linker doesn’t seem to take the env setting when user==root.
what else would be the preferred methods of encoding lib paths in ruby
extensions? DLDFLAGS?

XLDFLAGS is for linking main program.
But LD_RUN_PATH seems to be embedded.

$ LD_RUN_PATH=/runpath/ruby make ruby
gcc -ggdb -g3 -Os -fPIC -rdynamic -L. main.o -lruby-1.9 -ldl -lcrypt -lm -o ruby
$ strings ruby | grep runpath
/runpath/ruby
$ mv ruby ruby-with-runpath
$ sudo env LD_RUN_PATH=/runpath/ruby make ruby
gcc -ggdb -g3 -Os -fPIC -rdynamic -L. main.o -lruby-1.9 -ldl -lcrypt -lm -o ruby
$ strings ruby | grep runpath
/runpath/ruby
$ cmp ruby ruby-with-runpath

And, basically, do you really need to compile by root, not to
just install?

···


Nobu Nakada

By far the best way to do this, is to use RPATHs. That is, hardcode the
location into the extension binary. Although exactly how to do this
depends on your compiler OS combination.

If you’re using the typical gcc / gnu binutils combination, then you can
do this by adding -Wl,-R,/path/to/shlibs to the LDFLAGS variable (or
just manually add it to the linker command line).

···

On Fri, Apr 16, 2004 at 04:04:19PM +0900, Ara.T.Howard wrote:

i just had something weird crop up when intalling ruby as root in a
non-standard place: compiling with LD_RUN_PATH=/non/standard/place/lib doesn’t
work since the linker doesn’t seem to take the env setting when user==root.
what else would be the preferred methods of encoding lib paths in ruby
extensions? DLDFLAGS?


Ceri Storey cez@necrofish.org.uk

Hi,

At Fri, 16 Apr 2004 16:51:28 +0900,
nobu.nokada@softhome.net wrote in [ruby-talk:97330]:

$ sudo env LD_RUN_PATH=/runpath/ruby make ruby

$ make LD_RUN_PATH=/runpath/ruby ruby

also seems to work.

···


Nobu Nakada

isn’t this what setting LD_RUN_PATH does anyhow? seems safer to set the env
and let gcc figure out the flags…

-a

···

On Sat, 17 Apr 2004, Ceri Storey wrote:

On Fri, Apr 16, 2004 at 04:04:19PM +0900, Ara.T.Howard wrote:

i just had something weird crop up when intalling ruby as root in a
non-standard place: compiling with LD_RUN_PATH=/non/standard/place/lib doesn’t
work since the linker doesn’t seem to take the env setting when user==root.
what else would be the preferred methods of encoding lib paths in ruby
extensions? DLDFLAGS?

By far the best way to do this, is to use RPATHs. That is, hardcode the
location into the extension binary. Although exactly how to do this
depends on your compiler OS combination.

If you’re using the typical gcc / gnu binutils combination, then you can
do this by adding -Wl,-R,/path/to/shlibs to the LDFLAGS variable (or
just manually add it to the linker command line).

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================

neither do on our machine? very weird. i’ve found some things on google
about this - that env settings are ignored when linking if euid!=uid or
something like that - and people having similar probs… perhaps it is unique
to this os… what are you on?

-a

···

On Fri, 16 Apr 2004 nobu.nokada@softhome.net wrote:

Hi,

At Fri, 16 Apr 2004 16:51:28 +0900,
nobu.nokada@softhome.net wrote in [ruby-talk:97330]:

$ sudo env LD_RUN_PATH=/runpath/ruby make ruby

$ make LD_RUN_PATH=/runpath/ruby ruby

also seems to work.

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
URL :: Solar-Terrestrial Physics Data | NCEI
TRY :: for l in ruby perl;do $l -e “print "\x3a\x2d\x29\x0a"”;done
===============================================================================

Hi,

At Fri, 16 Apr 2004 22:54:17 +0900,
Ara.T.Howard wrote in [ruby-talk:97356]:

At Fri, 16 Apr 2004 16:51:28 +0900,
nobu.nokada@softhome.net wrote in [ruby-talk:97330]:

$ sudo env LD_RUN_PATH=/runpath/ruby make ruby

$ make LD_RUN_PATH=/runpath/ruby ruby

also seems to work.

neither do on our machine? very weird. i’ve found some things on google
about this - that env settings are ignored when linking if euid!=uid or
something like that - and people having similar probs… perhaps it is unique
to this os… what are you on?

Linux 2.4.20, and
$ LANG=C gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: …/configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
$ ld -v
GNU ld version 2.13.90.0.18 20030206

How are you doing? euid!=uid means that you use suid program?

Rather, why do you compile as root? Basically, you don’t need
to be root to compile/link.

···


Nobu Nakada