[Buildroot] Enable -fPIC for static toolchain libs

robertbarnes at airmail.cc robertbarnes at airmail.cc
Mon Oct 30 09:06:25 UTC 2023


Hello,

I am trying to enable -fPIC when building the static libs for the 
buildroot toolchain (BR2_STATIC_LIBS=y).
I need the static libs to be built with PIC in order to use them when 
building dynamic libraries (.so's) that uses these static libs.

How can I enable all static libs to be compiled with -fPIC?
Can I use some global CFLAG/CXXFLAG-override?

I understand that this is not very common, so hacks are welcome.

For example, there is a config parameter in: Toolchain -> "Additional 
gcc options" - can I use this parameter to force the buildroot toolchain 
to always use -fPIC?

Please speak up if you have done this yourself, or if you know, or think 
you know of a solution.

I am currently using the LTS (2018.08) version but I can make a switch 
if it is needed.

Best,
Robert



More information about the buildroot mailing list