mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.6k stars 1.63k forks source link

Meson doesn't link to Boost correctly on NetBSD #4464

Open nomis opened 6 years ago

nomis commented 6 years ago

On NetBSD 8.0, Meson doesn't link executables to Boost correctly because it's not possible to execute them without a custom LD_LIBRARY_PATH:

$ echo $BOOST_ROOT
/usr/pkg
$ meson --version
0.48.1
$ ninja --version
1.8.2
$ g++ --version
g++ (nb2 20180327) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ ld --version
GNU ld (NetBSD Binutils nb1) 2.27
Copyright (C) 2016 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ git clone https://github.com/nomis/dtee
$ cd dtee
$ meson --buildtype=release build/release/
$ ninja -C build/release/
$ ldd build/release/dtee
build/release/dtee:
        -lboost_filesystem.1.67.0 => not found
        -lboost_program_options.1.67.0 => not found
        -lboost_system.1.67.0 => not found
        -lstdc++.8 => /usr/lib/libstdc++.so.8
        -lm.0 => /usr/lib/libm.so.0
        -lc.12 => /usr/lib/libc.so.12
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
$ LD_LIBRARY_PATH=/usr/pkg/lib ldd build/release/dtee
build/release/dtee:
        -lboost_filesystem.1.67.0 => /usr/pkg/lib/libboost_filesystem.so.1.67.0
        -lboost_system.1.67.0 => /usr/pkg/lib/libboost_system.so.1.67.0
        -lstdc++.8 => /usr/lib/libstdc++.so.8
        -lm.0 => /usr/lib/libm.so.0
        -lc.12 => /usr/lib/libc.so.12
        -lgcc_s.1 => /usr/lib/libgcc_s.so.1
        -lpthread.1 => /usr/lib/libpthread.so.1
        -lboost_program_options.1.67.0 => /usr/pkg/lib/libboost_program_options.so.1.67.0
dcbaker commented 6 years ago

Netbsd may need the rpath workaround some other BSDs do.

On November 3, 2018 2:04:10 PM PDT, Simon Arlott notifications@github.com wrote:

On NetBSD 8.0, Meson doesn't link executables to Boost correctly because it's not possible to execute them without a custom LD_LIBRARY_PATH:

$ echo $BOOST_ROOT
/usr/pkg
$ meson --version
0.48.1
$ ninja --version
1.8.2
$ g++ --version
g++ (nb2 20180327) 5.5.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ ld --version
GNU ld (NetBSD Binutils nb1) 2.27
Copyright (C) 2016 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms
of
the GNU General Public License version 3 or (at your option) a later
version.
This program has absolutely no warranty.
$ git clone https://github.com/nomis/dtee
$ cd dtee
$ meson --buildtype=release build/release/
$ ninja -C build/release/
$ ldd build/release/dtee
build/release/dtee:
       -lboost_filesystem.1.67.0 => not found
       -lboost_program_options.1.67.0 => not found
       -lboost_system.1.67.0 => not found
       -lstdc++.8 => /usr/lib/libstdc++.so.8
       -lm.0 => /usr/lib/libm.so.0
       -lc.12 => /usr/lib/libc.so.12
       -lgcc_s.1 => /usr/lib/libgcc_s.so.1
$ LD_LIBRARY_PATH=/usr/pkg/lib ldd build/release/dtee
build/release/dtee:
-lboost_filesystem.1.67.0 => /usr/pkg/lib/libboost_filesystem.so.1.67.0
       -lboost_system.1.67.0 => /usr/pkg/lib/libboost_system.so.1.67.0
       -lstdc++.8 => /usr/lib/libstdc++.so.8
       -lm.0 => /usr/lib/libm.so.0
       -lc.12 => /usr/lib/libc.so.12
       -lgcc_s.1 => /usr/lib/libgcc_s.so.1
       -lpthread.1 => /usr/lib/libpthread.so.1
-lboost_program_options.1.67.0 =>
/usr/pkg/lib/libboost_program_options.so.1.67.0

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/mesonbuild/meson/issues/4464

nomis commented 6 years ago

This doesn't happen on FreeBSD/OpenBSD/DragonFlyBSD, I'm able to build and run the application on all of those systems (with b_lundef/b_asneeded disabled on OpenBSD).

What rpath workaround do I need to specify with Meson?

jpakkane commented 6 years ago

It would appear that /usr/pkg/lib is not in the default library search path on NetBSD. Is there official documentation on how programs that use libraries installed in that directory should work? Is it like /usr/local/lib on Linux where the end user is expected to set LD_LIBRARY_PATH or are build systems expected to add the appropriate rpath entry pointing to /usr/pkg/lib whenever compiling code that uses those libraries?

dcbaker commented 6 years ago

I guess we should go introduce ourselves to the various BSDs and start asking songs of these questions. I guess I'll go do that tonight or Monday unless someone beats me to it.

On November 3, 2018 3:35:32 PM PDT, Jussi Pakkanen notifications@github.com wrote:

It would appear that /usr/pkg/lib is not in the default library search path on NetBSD. Is there official documentation on how programs that use libraries installed in that directory should work? Is it like /usr/local/lib on Linux where the end user is expected to set LD_LIBRARY_PATH or are build systems expected to add the appropriate rpath entry pointing to /usr/pkg/lib whenever compiling code that uses those libraries?

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/mesonbuild/meson/issues/4464#issuecomment-435626200

nomis commented 6 years ago

This is documented at http://www.netbsd.org/docs/elf.html:

The primary directory locating mechanism is the ``rpath'' search list contained within the executable image.