GithubHelp home page GithubHelp logo

foo's Introduction

More or less simple setup to reproduce Meson build-rpath difficulty.

This will install some files to /tmp/special/dir.

Steps:

  1. meson build
  2. ninja -C build install
  3. Set preparation to false in main meson.build file.
  4. Start from scratch: rm -Rf build && meson --pkg-config-path=/tmp/special/dir/pkgconfig build
  5. ninja -C build
  6. ldd build/tests/mytest
  7. readelf -d build/tests/mytest

Step 2 sets an additional library (libbar) up in the special directory also used by libfoo. Foo is the library we really want to build and test. All libraries in that special dir have appropriate rpath settings in their pkgconfig files.

Step 3 removes the preliminary steps in Meson to install libbar. The preparation is finished and we have two libraries installed in the special directory. Now this setup will only work on foo and use the previously installed bar.

Step 4 uses the previously installed pkgconfig files and libs in the special directory.

Step 5 builds a new foo, that we want to test. We do not know anything about bar anymore and want to fetch it as dependency. When we run the test executable, instead of using our new foo the old library from step 2 is found:

Step 6 + 7 output:

$ ldd build/tests/mytest
        linux-vdso.so.1 (0x00007fffbe78e000)
        libfoo.so.0.8.15 => /tmp/special/dir/libfoo.so.0.8.15 (0x00007f7d1c312000)
        libbar.so.47.11 => /tmp/special/dir/libbar.so.47.11 (0x00007f7d1c30d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7d1c101000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f7d1c31e000)

$ readelf -d build/tests/mytest | grep path
 0x000000000000001d (RUNPATH)            Library runpath: [/tmp/special/dir:$ORIGIN/../src]

This is because the pkgconfig options (i.e. -Wl,rpath=) are placed in front of the current building-rpath options generated by Meson, and are thus evaluated too late.

$ORIGIN/../src should come first to make sure the current build artifact is found first.

So what we really want to have but do not get is this:

$ ldd build/tests/mytest
        linux-vdso.so.1 (0x00007fffe0781000)
        libfoo.so.0.8.15 => /home/fini/git/foo/build/tests/../src/libfoo.so.0.8.15 (0x00007f730c687000)
        libbar.so.47.11 => /tmp/special/dir/libbar.so.47.11 (0x00007f730c682000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f730c476000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f730c693000)

$ readelf -d build/tests/mytest | grep path                                                                                                                                  master ✚ 2 
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../src:/tmp/special/dir]

foo's People

Contributors

finii avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.