[OE-core] [PATCH] gcc-7.inc: add new warning "Wnot-cross-compiler"

Andre McCurdy armccurdy at gmail.com
Wed Jul 19 00:33:15 UTC 2017


On Tue, Jul 18, 2017 at 5:12 PM, Khem Raj <raj.khem at gmail.com> wrote:
>
> On Tue, Jul 18, 2017 at 6:45 PM Juro Bystricky <juro.bystricky at intel.com>
> wrote:
>>
>> Suppose we have an autotools project that looks like it is using the cross
>> compiler but is actually reaching out to the host compiler instead.
>> On an x86-64 build, you may not even notice.
>> To be able to prevent this, this patch implements a new gcc warning
>> "Wnot-cross-compiler". The intention here is to intentionally break a
>> build
>> if we are not using a cross-compiler when one is expected to be used.
>>
>> Expected usage: " -Wnot-cross-compiler -Werror=not-cross-compiler "will
>
> Shouldn't this patch get applied to native gcc on build hosts ?

Isn't the intention that native gcc won't recognise the new options
and will therefore fail if they're accidentally passed to it?

> And I would suggest to sent it to gcc mailing lists before we apply it to oe
>>
>> [YOCTO #11587]
>>
>> Signed-off-by: Juro Bystricky <juro.bystricky at intel.com>
>> ---
>>  meta/recipes-devtools/gcc/gcc-7.1.inc              |  1 +
>>  .../gcc/gcc-7.1/0051-warn-not-cross-compiler.patch | 39
>> ++++++++++++++++++++++
>>  2 files changed, 40 insertions(+)
>>  create mode 100644
>> meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch
>>
>> diff --git a/meta/recipes-devtools/gcc/gcc-7.1.inc
>> b/meta/recipes-devtools/gcc/gcc-7.1.inc
>> index 3f1c06d..e9b1f21 100644
>> --- a/meta/recipes-devtools/gcc/gcc-7.1.inc
>> +++ b/meta/recipes-devtools/gcc/gcc-7.1.inc
>> @@ -75,6 +75,7 @@ SRC_URI = "\
>>             file://0048-gcc-Enable-static-PIE.patch \
>>
>> file://0049-libsanitizer-Use-stack_t-instead-of-struct-sigaltsta.patch \
>>             file://0050-replace-struct-ucontext-with-ucontext_t.patch \
>> +           file://0051-warn-not-cross-compiler.patch \
>>             ${BACKPORTS} \
>>  "
>>  BACKPORTS = "\
>> diff --git
>> a/meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch
>> b/meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch
>> new file mode 100644
>> index 0000000..78671ed
>> --- /dev/null
>> +++ b/meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch
>> @@ -0,0 +1,39 @@
>> +
>> +This patch implements an additional gcc command line option warning
>> +"Wnot-cross-compiler". The option (if specified) will simply generate
>> +a warning if gcc being used is not a cross-compiler.
>> +
>> +Upstream-Status: Pending
>> +Signed-off-by: Juro Bystricky <juro.bystricky at intel.com>
>> +
>> +
>> +diff --git a/gcc/common.opt b/gcc/common.opt
>> +--- a/gcc/common.opt
>> ++++ b/gcc/common.opt
>> +@@ -801,6 +801,10 @@
>> + Common Var(warn_vector_operation_performance) Warning
>> + Warn when a vector operation is compiled outside the SIMD.
>> +
>> ++Wnot-cross-compiler
>> ++Common Warning
>> ++Warn when not-cross-compiling.
>> ++
>> + Xassembler
>> + Driver Separate
>> +
>> +diff --git a/gcc/opts.c b/gcc/opts.c
>> +--- a/gcc/opts.c
>> ++++ b/gcc/opts.c
>> +@@ -2334,6 +2334,12 @@
>> +       opts->x_flag_ipa_icf_variables = value;
>> +       break;
>> +
>> ++    case OPT_Wnot_cross_compiler:
>> ++#ifndef CROSS_DIRECTORY_STRUCTURE
>> ++      warning (OPT_Wnot_cross_compiler, "Not using cross-compiler!");
>> ++#endif
>> ++      break;
>> ++
>> +     default:
>> +       /* If the flag was handled in a standard way, assume the lack of
>> +        processing here is intentional.  */
>> --
>> 2.7.4
>>
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
>



More information about the Openembedded-core mailing list