Skip to content
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

Support for position-independent code generation (linking static boost libraries into shared libraries with -fPIC) #366

Open
jeking3 opened this issue Nov 14, 2018 · 1 comment
Labels
transition Transition to bfgroup/b2

Comments

@jeking3
Copy link
Contributor

jeking3 commented Nov 14, 2018

From a discussion in Boost.Serialization and on the mailing list, it was understood that the gcc compiler jam enables -fPIC if linking shared. Another use case is linking static, but then incorporating that into a shared library. On some platform/compiler combinations this requires special treatment, for example with linux and gcc or clang, -fPIC is required to enable this to work.

From the mailing list I received advice on testing for -fPIC support in the compiler and then enabling it on a given project. @pdimov suggested that to do it properly would require some work in Boost.Build, but I think it's worth the effort.

Steven Watanabe wrote:
...

import flags ;
project
: requirements
[ check-has-flag -fPIC : -fPIC ]
;

Note 1: The documentation for this is only in
b2 --help flags.check-has-flag. It isn't
integrated into the html docs yet.

Note 2: This is pretty new, so if you run into
any problems, please let me know.

Note 3: It might be more reliable to separate
the object files out and set shared on them:
obj x.o : x.cpp : shared ;
...
lib l : x.o y.o ... ;
(This will only work if the library is one
that is specifically built for the test, not
if it's a generic Boost library.)

Note 4: (from @pdimov)

This should probably be a feature, like <position-independent>on, which
toolsets translate to -fPIC as appropriate.

jeking3 referenced this issue in res2k/serialization Nov 14, 2018
@stale
Copy link

stale bot commented Jun 11, 2021

Thank you for your contributions. Main development of B2 has moved to https://github.com/bfgroup/b2
This issue has been automatically marked as "transition" to indicate the potential for needing transition to the new B2 development project.

@stale stale bot added the transition Transition to bfgroup/b2 label Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
transition Transition to bfgroup/b2
Projects
None yet
Development

No branches or pull requests

1 participant