Finii / foo

A test case for Meson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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]

About

A test case for Meson

License:The Unlicense


Languages

Language:Meson 85.8%Language:C++ 14.2%