[oe] [meta-oe][PATCH] gtest: add -fPIC

Andre McCurdy armccurdy at gmail.com
Tue Mar 28 21:32:46 UTC 2017


On Tue, Mar 28, 2017 at 2:17 PM, Martin Kelly <mkelly at xevo.com> wrote:
> On 03/28/2017 02:05 PM, Andre McCurdy wrote:
>> On Tue, Mar 28, 2017 at 1:55 PM, Martin Kelly <mkelly at xevo.com> wrote:
>>> On 03/28/2017 01:47 PM, Khem Raj wrote:
>>>> On 3/28/17 1:37 PM, Andre McCurdy wrote:
>>>>> On Tue, Mar 28, 2017 at 12:33 PM, Martin Kelly <martin at xevo.com> wrote:
>>>>>> From: Martin Kelly <mkelly at xevo.com>
>>>>>>
>>>>>> I tried turning on the Yocto security flags and hit a compilation
>>>>>> error due to gtest not compiling. Adding -fPIC fixes the issue.
>>>>>
>>>>> Since gtest only creates static libraries, compiling everything with
>>>>> -fPIC might not be the correct solution.
>>>>
>>>> it still is going to be linked with a PIE binary then it should be PIC
>>
>> Wouldn't compiling all gtest objects with -fpie work in that case too?
>
> I am no expert in this, but from the gcc manpage, it looks like -fPIE will
> work only when linking with executables, while -fPIC will work in either
> case.

Right. So the question is if security flags are enabled (and therefore
-fpie is passed into the gtest build via CFLAGS) then why do you see
an issue?

> Thus I suppose it depends on whether we want to support linking gtest
> against a library.

If gtest needs to support linking against an .so then it would need
-fPIC, regardless of any security flags. That seems like a separate
question.



More information about the Openembedded-devel mailing list