cmake/interpreter: propagate object library pie flag#15958
Conversation
If the target has no ordinary or generated sources, then propagate the "pie" flag from the object libraries. Otherwise it will not use position independent code, making it impossible to link into shared libraries. Fixes mesonbuild#10764
|
Without this change but I feel like there is inadequate handling of this in meson. E.g. consider: and then this is accepted without any complaints: It seems to me that the "pic" state should be tracked on a per-object-file basis. And then the #10764 would just disappear. |
It would be pretty trivial to add a |
|
I'm also wondering if the best solution is to represent object_library as a static library with a direct call to |
But what if it contains objects from both a pic and a non-pic static library? Will that be disallowed? If not, then isn't it necessary to track it on a per-file basis?
What would be the alternatives? |
I can't remember all of the linking rules around mixing PIE and non-PIE objects, IIRC you can treat PIE objects as non-PIE which would mean mixing PIE and non-PIE would just create a non-PIE ExtractedObjects, just like it should create a non-PIE static library? The problem here is that Meson doesn't really have per-object granularity in our IR, targets really are the base object of our model. See also why repeated calls for per-object compile flags have been met with resistance, it would be really hard to implement, and it would go against part of our design. |
If the target has no ordinary or generated sources, then propagate the "pie" flag from the object libraries. Otherwise it will not use position independent code, making it impossible to link into shared libraries.
Fixes #10764
No idea if this is on the right path, or what else could be done. Another potentially problematic thing is that meson forces each
OBJECT_LIBRARYto havepie==True, but cmake does not do that, I think.