Build changes correcting FPIC definition (was: [PATCH] gmp: compile with -DPIC to use correct asm code)

Philip Prindeville philipp_subx at redfish-solutions.com
Wed Mar 24 18:34:48 GMT 2021



> On Mar 19, 2021, at 4:59 PM, Philip Prindeville <philipp_subx at redfish-solutions.com> wrote:
> 
> 
> 
>> On Mar 19, 2021, at 4:06 PM, Eneas U de Queiroz <cotequeiroz at gmail.com> wrote:
>> 
>> On Fri, Mar 19, 2021 at 5:08 PM Philip Prindeville
>> <philipp_subx at redfish-solutions.com> wrote:
>>> 
>>> 
>>> Maybe I'm missing something, but why not just fix rules.mk:
>>> 
>>> 
>>> ifneq (,$(findstring $(ARCH) , aarch64 aarch64_be powerpc ))
>>> FPIC:=-fPIC
>>> else
>>> FPIC:=-fpic
>>> endif
>>> 
>>> HOST_FPIC:=-fPIC
>>> 
>>> 
>>> To have the FPIC and HOST_FPIC definitions include -DPIC?
>> 
>> I think it would be the proper way to handle this.  I was initially
>> fearful of changing too much and breaking things, but I think it
>> should be expected behaviour.  What else would you use a 'PIC'
>> definition for?  I will resend a patch changing rules.mk instead.
> 
> 
> Just saw this... Turns out that this would break a couple of packages (both in openwrt and in packages), so I've included those as well.
> 
> -Philip
> 


Hi all,

I think that Eneas and I have converged on a fix, it should help with some of the CircleCI issues we've been having with x86_64 (which oddly isn't our most leveraged architecture for CI/CD testing, even though it's the easiest to cloud deploy... but that's a separate discussion).

We've both built and tested with this patch and no ill effects.

There's actually a surprising number of places where the symbol "PIC" is tested, not just in asm files (which was the original libgmp problem), but also in C files supporting dlopen(), stack unwinding, etc.

If you go into build_dir/target-*/ and run:

% find . \( -name "*.[hc]" -o -name "*.[hc]pp" -o -name "*.asm" \) -print | xargs egrep -r -n '\<if.*\<PIC\>' 

You'll get about 200+ hits (modulo some occurrences of "PIC" in comments), very close to 50% of those being in gmp-6.2.1 itself (not surprising because it has a lot of asm code).

Other hits are also where you'd expect them: elfutils, binutils, gdb, etc. i.e. things that need to be relocation-aware or else projects with plugin support in the form of .so's (such as cyrus-sasl).

The fix itself is trivial: it's 3 lines of changes.  Can we please get core reviewers to consider and merge this?

https://github.com/openwrt/openwrt/pull/4006

Thanks!

-Philip





More information about the openwrt-devel mailing list