Skip to content

if --with_boost is specified, search *only* the specified directory h… #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

djerius
Copy link
Contributor

@djerius djerius commented Jan 27, 2016

if --with_boost is specified, search only the specified directory hierarchy for libraries.

Arguably, if --with_boost is specified, the user wants to use only
that boost installation, and no other. This changeset implements this
behavior.

The original code in _BOOST_FIND_LIBS prepended the --with_boost path
to the default list of paths, resulting in all of the paths being
searched if the library wasn't found in that specified by
--with_boost. Because the search for a library begins with the most
specialized version:

boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_
boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_
boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_
boost_$boost_lib_$boost_tag_$boost_ver_

if the user's preferred boost installation has a less specialized
version of a library than one provided in the default path, the latter
will be chosen instead.

This may lead to a mismatch between the headers discovered in the
--with_boost hierarchy and the library discovered in the default path,
if they are for different versions of boost, leading to link problems
if the latter is for an earlier version .

Additionally, this will silently invalidate a request for a specific
version of boost in BOOST_REQUIRE, as it will be fulfilled by the
headers, but not by the library.

The new code does the following:

  • It will only search the --with_boost hierarchy if that is provided;
  • It will (following the suggestion of issue Bug involving BOOST library detection when different BOOST versions are present #49 by mateidavid) use the
    absolute path to the library so that the linker's default
    library paths are not searched if the library is not found in the
    --with_boost hierarchy
  • It adds a second path "$with_boost/lib" to the search path, as that
    seems to be a standard place for libraries

N.B. There is still a potential for mishap if --with_boost is not
specified, namely that if there exist multiple boost installations and
some do not have all of the libraries, it is possible to end up with
libraries selected from multiple installations.

@djerius
Copy link
Contributor Author

djerius commented Jan 27, 2016

I just discovered a problem on OS X; am working on a fix.

@djerius
Copy link
Contributor Author

djerius commented Jan 28, 2016

I've updated the code to fix the problem. Should be good to go.

…ierarchy for libraries.

Arguably, if --with_boost is specified, the user wants to use only
that boost installation, and no other.  This changeset implements this
behavior.

The original code in _BOOST_FIND_LIBS prepended the --with_boost path
to the default list of paths, resulting in all of the paths being
searched if the library wasn't found in that specified by
--with_boost.  Because the search for a library begins with the most
specialized version:

    boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_
    boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_
    boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_
    boost_$boost_lib_$boost_tag_$boost_ver_

if the user's preferred boost installation has a less specialized
version of a library than one provided in the default path, the latter
will be chosen instead.

This may lead to a mismatch between the headers discovered in the
--with_boost hierarchy and the library discovered in the default path,
if they are for different versions of boost, leading to link problems
if the latter is for an earlier version .

Additionally, this will silently invalidate a request for a specific
version of boost in BOOST_REQUIRE, as it will be fulfilled by the
headers, but not by the library.

The new code does the following:

* It will only search the --with_boost hierarchy if that is provided;

* It will (following the suggestion of issue tsuna#49 by mateidavid) use the
  absolute path to the library so that the linker's default
  library paths are not searched if the library is not found in the
  --with_boost hierarchy

* It adds a second path "$with_boost/lib" to the search path, as that
  seems to be a standard place for libraries

N.B. There is still a potential for mishap if --with_boost is *not*
specified, namely that if there exist multiple boost installations and
some do not have all of the libraries, it is possible to end up with
libraries selected from multiple installations.
shrext_cmds is actually a quoted set of commands to generate the
shared library extension, not the actual shrext itself (regardless of
it initially being set directly to .so as a default).
boost_cv_inc_path can have values 'yes' and 'no' in addition to a real
path, so don't use it to generate an ldpath if it's 'yes' or 'no'
If the tested ldpath = '', using it to create an absolute
path to a library leads to a path in the root directory, which
isn't what's intended. So don't.

Additionally if ldpath = '', it's equivalent to letting the linker
use only the system default paths, and there's no way of knowing in
which directory the linker might find the library.
@djerius
Copy link
Contributor Author

djerius commented Aug 27, 2019

I've rebased the code on current master, and fixed a couple of bugs, one of which led to problems on systems where the default search path for libraries wasn't covered by the directories explicitly searched (e.g. on Debian 10 with multi-arch, where libraries are in /usr/lib/x86_64-linux-gnu/)

koomie added a commit to hpcsi/grvy that referenced this pull request Jan 21, 2022
provided. Needed to avoid pulling in old multi-threaded variants
on TACC's frontera system that are incompatible with intel
compiler. Based on PR from tsuna/boost.m4#82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant