Skip to content

Origin-based install using -R,'$$ORIGIN/../lib' #17534

@noloader

Description

@noloader

Description
I'm building Perl 5.30.1 from the release tarball. My LDFLAGS include -L<prefix>/lib -Wl,-R,'$$ORIGIN/../lib' -Wl,-R,<prefix>/lib -Wl,--enable-new-dtags. They are passed to Configure using -Aldflags.

The $$ORIGIN is used to safely pass the dollar sign through a makefile. The double dollar sign is the way to escape the dollar sign in make.

It appears Perl munges the origin-based runpath. When I inspect the resulting binary:

$ objdump -x ./perl | grep -i -E 'RPATH|RUNPATH'
  RUNPATH              15530ORIGIN/../lib:/home/jwalton/tmp/build-test/lib

If I use a single dollar sign, -L<prefix>/lib -Wl,-R,'$ORIGIN/../lib' -Wl,-R,<prefix>/lib -Wl,--enable-new-dtags, then it looks like $ORIGIN gets lopped off:

$ objdump -x ./perl | grep -i -E 'RPATH|RUNPATH'
  RUNPATH              /../lib:/home/jwalton/tmp/build-test/lib

Steps to Reproduce

./Configure \
     -Dprefix="/tmp/ok_to_delete" \
     -Dlibdir="/tmp/ok_to_delete/lib" \
    -Aldflags="-L/tmp/ok_to_delete/lib -Wl,-R,'$$ORIGIN/../lib' -Wl,-R,/tmp/ok_to_delete/lib -Wl,--enable-new-dtags"

Expected behavior
The runpath should look something like:

$ objdump -x /home/jwalton/tmp/ok_to_delete/bin/bzip2 | grep -i -E 'RPATH|RUNPATH'
  RUNPATH              $ORIGIN/../lib:/home/jwalton/tmp/ok_to_delete/lib

And to be clear... If invoking GCC directly, then use -Wl,-R,'$ORIGIN/../lib'. If using a makefile, then use -Wl,-R,'$$ORIGIN/../lib' to escape the dollar sign in the makefile.

Perl configuration

$ PERL5LIB=lib:$PERL5LIB ./perl -V
Summary of my perl5 (revision 5 version 30 subversion 1) configuration:
   
  Platform:
    osname=linux
    osvers=4.19.80-0-vanilla
    archname=x86_64-linux
    uname='linux alpine3-x64 4.19.80-0-vanilla #1-alpine smp fri oct 18 11:27:53 utc 2019 x86_64 linux '
    config_args='-des -Dprefix=/usr/local -Dlibdir=/usr/local/lib -Dpkgconfig=/usr/local/lib/pkgconfig -Dcc=gcc -Acppflags=-I/usr/local/include -DNDEBUG -Accflags=-g2 -O2 -march=native -fPIC -pthread -Aldflags=-L/usr/local/lib -Wl,-R,'$$ORIGIN/../lib' -Wl,-R,/usr/local/lib -Wl,--enable-new-dtags -Dextras=Text::Template Test::More'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-g2 -O2 -march=native -fPIC -pthread -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    optimize='-O2'
    cppflags='-I/usr/local/include -DNDEBUG -g2 -O2 -march=native -fPIC -pthread -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='gcc'
    ldflags =' -L/usr/local/lib -Wl,-R,11928ORIGIN/../lib -Wl,-R,/usr/local/lib -Wl,--enable-new-dtags -fstack-protector-strong'
    libpth=/usr/local/lib /usr/lib /lib/../lib /usr/lib/../lib /lib
    libs=-lpthread -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/usr/lib/libc.a
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -Wl,-R,11928ORIGIN/../lib -Wl,-R,/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at Feb  4 2020 10:32:16
  %ENV:
    PERL5LIB="lib:"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.30.1/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.30.1
    /usr/local/lib/perl5/5.30.1/x86_64-linux
    /usr/local/lib/perl5/5.30.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions