Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Build with -fPIC #49

Closed
ringerc opened this issue Jan 24, 2018 · 9 comments
Closed

Build with -fPIC #49

ringerc opened this issue Jan 24, 2018 · 9 comments

Comments

@ringerc
Copy link

ringerc commented Jan 24, 2018

Opentracing should really default to building a shared lib with -fPIC (gcc); there's not really any good reason not to build position-indepedent code anymore.

Lack of -fPIC upsets jaeger-cpp among other things.

@rnburn
Copy link
Contributor

rnburn commented Jan 24, 2018

CMake should automatically set PIC for shared libraries. Are you not seeing this?

Jaeger links to opentracing-cpp statically (even for its dynamic build), which is probably why it's complaining. But you can build with cmake -DCMAKE_CXX_FLAGS="-fPIC" to override the static library defaults.

@isaachier
Copy link
Contributor

@rnburn I use CMAKE_POSITION_INDEPENDENT_CODE to compile both static and shared libraries with -fPIC.

@ringerc
Copy link
Author

ringerc commented Jan 24, 2018

I don't really see any good reason not to build without -fPIC these days, but in any case, that seems like Jaeger doing something weird. It shouldn't be linking to the opentracing static lib for its own shared lib anyway. Will open issue there.

@ringerc
Copy link
Author

ringerc commented Jan 24, 2018

@isaachier That only helps if you let Jaeger build opentracing via its download-everything-from-the-Internet magic. That's not going to fly in the sorts of environments many things like databases deploy in. Otherwise you have to know to build your opentracing that way, and it's currently an undocumented requirement.

More generally, linking to a static lib in a shared lib is a weird thing to do. Is there a compelling reason Jaeger does that?

@ringerc
Copy link
Author

ringerc commented Jan 24, 2018

Workaround: build opentracing with cmake -DCMAKE_POSITION_INDEPENDENT_CODE=on per @isaachier

@isaachier
Copy link
Contributor

Well this particular setting has nothing to do with Hunter. I'm suggesting @rnburn use this standard cmake setting I used.

@rnburn
Copy link
Contributor

rnburn commented Jan 24, 2018

@isaachier it's not at all standard to build static libraries with -fPIC.

@isaachier
Copy link
Contributor

I don't mean it is standard behavior, just a well documented CMake option. However, I have seen it done in OpenSSL and gRPC.

@isaachier
Copy link
Contributor

The reason Jaeger does it is to allow linking a shared object from the static archive. I would consider switching that out, but the downsides seem rather vague (potential slowdown, unclear how significant).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants