Specifying "-fPIC" CFLAG for static library
shermp opened this issue · comments
Hi @NiLuJe
Would you be willing to add "-fPIC" as an optional CFLAG when compiling the static library?
The reason is that CGo does not seem to like linking to a static build without that flag, unless specifying the "--static" argument in cgo, which in turn breaks linking to glibc.
I did it myself, but I figured you may want to consider it for the project as a whole.
Thanks
Is -fPIC mandatory, or does -fpic do the job?
I added a "pic" target that builds a PIC static library ;).
(Because not a huge fan of suffering the performance implications of PIC unilaterally :/).
Random thought: given the size of the library, it appears to have been stripped.
I imagine you're aware of the current mess that is stripping LTO archives?
EDIT: Feel free to ignore that if that was a non-LTO MINIMAL build instead ;).
It seems happy with -fpic
as well.
The error I was getting from the linker was specifically regarding -fPIC
Note that the rest of the SHARED_CFLAGS
don't appear to be required when linking a static build in Go, just -fpic
.
Okay, then make pic
it is, then ;).
Thanks!
EDIT: -fno-semantic-interposition
starts to "take" as soon as PIC is enabled, shared library or not ;).