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

Khem Raj raj.khem at gmail.com
Tue Mar 28 20:47:20 UTC 2017



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

> 
> Does adding:
> 
>   SECURITY_CFLAGS_pn-gtest = "${SECURITY_NO_PIE_CFLAGS}"
> 
> to meta-oe/conf/distro/include/meta_oe_security_flags.inc help? If so,
> that might be the better approach.
> 
>> Signed-off-by: Martin Kelly <mkelly at xevo.com>
>> ---
>>  meta-oe/recipes-test/gtest/gtest_1.8.0.bb | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/meta-oe/recipes-test/gtest/gtest_1.8.0.bb b/meta-oe/recipes-test/gtest/gtest_1.8.0.bb
>> index 483dc1f..9ba4ee4 100644
>> --- a/meta-oe/recipes-test/gtest/gtest_1.8.0.bb
>> +++ b/meta-oe/recipes-test/gtest/gtest_1.8.0.bb
>> @@ -19,6 +19,15 @@ S = "${WORKDIR}/googletest-release-${PV}"
>>
>>  inherit cmake
>>
>> +# -fPIC is needed to prevent relocation errors when we compile with Yocto
>> +# security flags. See this issue for more details:
>> +#
>> +# https://github.com/google/googletest/issues/854
>> +#
>> +# If that issue is fixed, we can probably remove the manual -fPIC flags here.
>> +OECMAKE_C_FLAGS += " -fPIC"
>> +OECMAKE_CXX_FLAGS += " -fPIC"
> 
> No leading space is required with +=
> 
>> +
>>  ALLOW_EMPTY_${PN} = "1"
>>  ALLOW_EMPTY_${PN}-dbg = "1"
>>
>> --
>> 2.1.4
>>
>> --
>> _______________________________________________
>> Openembedded-devel mailing list
>> Openembedded-devel at lists.openembedded.org
>> http://lists.openembedded.org/mailman/listinfo/openembedded-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 204 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openembedded.org/pipermail/openembedded-devel/attachments/20170328/0ccc8512/attachment-0002.sig>


More information about the Openembedded-devel mailing list