<div><br><div class="gmail_quote"><div dir="auto">On Tue, Jul 18, 2017 at 6:45 PM Juro Bystricky &lt;<a href="mailto:juro.bystricky@intel.com">juro.bystricky@intel.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Suppose we have an autotools project that looks like it is using the cross<br>
compiler but is actually reaching out to the host compiler instead.<br>
On an x86-64 build, you may not even notice.<br>
To be able to prevent this, this patch implements a new gcc warning<br>
&quot;Wnot-cross-compiler&quot;. The intention here is to intentionally break a build<br>
if we are not using a cross-compiler when one is expected to be used.<br>
<br>
Expected usage: &quot; -Wnot-cross-compiler -Werror=not-cross-compiler &quot;will </blockquote><div dir="auto"><br></div><div dir="auto">Shouldn&#39;t this patch get applied to native gcc on build hosts ?</div><div dir="auto"><br></div><div dir="auto">And I would suggest to sent it to gcc mailing lists before we apply it to oe </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
[YOCTO #11587]<br>
<br>
Signed-off-by: Juro Bystricky &lt;<a href="mailto:juro.bystricky@intel.com" target="_blank">juro.bystricky@intel.com</a>&gt;<br>
---<br>
 meta/recipes-devtools/gcc/gcc-7.1.inc              |  1 +<br>
 .../gcc/gcc-7.1/0051-warn-not-cross-compiler.patch | 39 ++++++++++++++++++++++<br>
 2 files changed, 40 insertions(+)<br>
 create mode 100644 meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch<br>
<br>
diff --git a/meta/recipes-devtools/gcc/gcc-7.1.inc b/meta/recipes-devtools/gcc/gcc-7.1.inc<br>
index 3f1c06d..e9b1f21 100644<br>
--- a/meta/recipes-devtools/gcc/gcc-7.1.inc<br>
+++ b/meta/recipes-devtools/gcc/gcc-7.1.inc<br>
@@ -75,6 +75,7 @@ SRC_URI = &quot;\<br>
            file://0048-gcc-Enable-static-PIE.patch \<br>
            file://0049-libsanitizer-Use-stack_t-instead-of-struct-sigaltsta.patch \<br>
            file://0050-replace-struct-ucontext-with-ucontext_t.patch \<br>
+           file://0051-warn-not-cross-compiler.patch \<br>
            ${BACKPORTS} \<br>
 &quot;<br>
 BACKPORTS = &quot;\<br>
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<br>
new file mode 100644<br>
index 0000000..78671ed<br>
--- /dev/null<br>
+++ b/meta/recipes-devtools/gcc/gcc-7.1/0051-warn-not-cross-compiler.patch<br>
@@ -0,0 +1,39 @@<br>
+<br>
+This patch implements an additional gcc command line option warning<br>
+&quot;Wnot-cross-compiler&quot;. The option (if specified) will simply generate<br>
+a warning if gcc being used is not a cross-compiler.<br>
+<br>
+Upstream-Status: Pending<br>
+Signed-off-by: Juro Bystricky &lt;<a href="mailto:juro.bystricky@intel.com" target="_blank">juro.bystricky@intel.com</a>&gt;<br>
+<br>
+<br>
+diff --git a/gcc/common.opt b/gcc/common.opt<br>
+--- a/gcc/common.opt<br>
++++ b/gcc/common.opt<br>
+@@ -801,6 +801,10 @@<br>
+ Common Var(warn_vector_operation_performance) Warning<br>
+ Warn when a vector operation is compiled outside the SIMD.<br>
+<br>
++Wnot-cross-compiler<br>
++Common Warning<br>
++Warn when not-cross-compiling.<br>
++<br>
+ Xassembler<br>
+ Driver Separate<br>
+<br>
+diff --git a/gcc/opts.c b/gcc/opts.c<br>
+--- a/gcc/opts.c<br>
++++ b/gcc/opts.c<br>
+@@ -2334,6 +2334,12 @@<br>
+       opts-&gt;x_flag_ipa_icf_variables = value;<br>
+       break;<br>
+<br>
++    case OPT_Wnot_cross_compiler:<br>
++#ifndef CROSS_DIRECTORY_STRUCTURE<br>
++      warning (OPT_Wnot_cross_compiler, &quot;Not using cross-compiler!&quot;);<br>
++#endif<br>
++      break;<br>
++<br>
+     default:<br>
+       /* If the flag was handled in a standard way, assume the lack of<br>
+        processing here is intentional.  */<br>
--<br>
2.7.4<br>
<br>
</blockquote></div></div>