POSITION_INDEPENDENT_CODE's [un]expected behaviour

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

POSITION_INDEPENDENT_CODE's [un]expected behaviour

CMake mailing list

Hello,

I would like to ask about POSITION_INDEPENDENT_CODE target property. As of CMake 3.8.2 POSITION_INDEPENDENT_CODE appends -fPIE or -fPIC to CMAKE_<LANG>_FLAGS and CMAKE_EXE_LINKER_FLAGS when building an executable or a library respectively. However, to build a PIE -pie linker flag is additionally required. Thus POSITION_INDEPENDENT_CODE is not behaving as expected being a really easy to fix for someone aware with CMake codebase.

Is there any reason why it wasn't added when the property was introduced? Somebody proposed introducing POSITION_INDEPENDENT_EXECUTABLE later on in addition to POSITION_INDEPENDENT_CODE to maintain backwards compatibility (I suppose policies are also a solution?).

This email is the result of the thread and the message by Juan Navarro (big thanks to him), which fully summarizes CMake's POSITION_INDEPENDENT_CODE treatment and links to multiple bugs: this one, so far without attention, and this one, resolved for Android.

Thank you.

Regards,
Oleksii Vilchanskyi


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: POSITION_INDEPENDENT_CODE's [un]expected behaviour

Craig Scott-3
Thanks for the links. I've updated the relevant issue in gitlab and also added links to other related ones so that the full picture is captured more or less in one place. I'll ping the dev list to see if anyone has further updates or thoughts on the PIE picture for executables. From a very quick look, it may be non-trivial to get all compilers/platforms updated with the correct options and at least one issue talks about problems with QT and having PIE being enabled, but I'll defer to the dev list to provide further insights. You can see the updated issue with links here:




On Sat, Jul 22, 2017 at 3:01 AM, Oleksii Vilchanskyi via CMake <[hidden email]> wrote:

Hello,

I would like to ask about POSITION_INDEPENDENT_CODE target property. As of CMake 3.8.2 POSITION_INDEPENDENT_CODE appends -fPIE or -fPIC to CMAKE_<LANG>_FLAGS and CMAKE_EXE_LINKER_FLAGS when building an executable or a library respectively. However, to build a PIE -pie linker flag is additionally required. Thus POSITION_INDEPENDENT_CODE is not behaving as expected being a really easy to fix for someone aware with CMake codebase.

Is there any reason why it wasn't added when the property was introduced? Somebody proposed introducing POSITION_INDEPENDENT_EXECUTABLE later on in addition to POSITION_INDEPENDENT_CODE to maintain backwards compatibility (I suppose policies are also a solution?).

This email is the result of the thread and the message by Juan Navarro (big thanks to him), which fully summarizes CMake's POSITION_INDEPENDENT_CODE treatment and links to multiple bugs: this one, so far without attention, and this one, resolved for Android.

Thank you.

Regards,
Oleksii Vilchanskyi


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake



--
Craig Scott
Melbourne, Australia

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake
Loading...