Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Ross Burton <ross.burton@intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 4/6] meson: stop Meson using target CFLAGS in native builds
Date: Tue, 25 Sep 2018 14:43:46 +0100	[thread overview]
Message-ID: <20180925134348.5562-4-ross.burton@intel.com> (raw)
In-Reply-To: <20180925134348.5562-1-ross.burton@intel.com>

With the goal of autoconf-compatibility Meson respects $CFLAGS et al in builds.
In cross-compiled build the cross file is the one true source of flags and the
environment isn't used, but in a native build the environment will still be
respected.

As this can lead to target flags being used in the build for native binaries
(including a single native binary inside a target recipe), export
CFLAGS=${BUILD_CFLAGS) et al.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/meson.bbclass | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 07322cf7865..ed08a4058cb 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -24,7 +24,11 @@ MESONOPTS = " --prefix ${prefix} \
               --infodir ${@noprefix('infodir', d)} \
               --sysconfdir ${sysconfdir} \
               --localstatedir ${localstatedir} \
-              --sharedstatedir ${sharedstatedir}"
+              --sharedstatedir ${sharedstatedir} \
+              -Dc_args='${BUILD_CPPFLAGS} ${BUILD_CFLAGS}' \
+              -Dc_link_args='${BUILD_LDFLAGS}' \
+              -Dcpp_args='${BUILD_CPPFLAGS} ${BUILD_CXXFLAGS}' \
+              -Dcpp_link_args='${BUILD_LDFLAGS}'"
 
 MESON_TOOLCHAIN_ARGS = "${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
 MESON_C_ARGS = "${MESON_TOOLCHAIN_ARGS} ${CFLAGS}"
@@ -114,14 +118,15 @@ meson_do_configure() {
 override_native_tools() {
     # Set these so that meson uses the native tools for its build sanity tests,
     # which require executables to be runnable. The cross file will still
-    # override these for the target build. Note that we do *not* set CFLAGS,
-    # LDFLAGS, etc. as they will be slurped in by meson and applied to the
-    # target build, causing errors.
+    # override these for the target build.
     export CC="${BUILD_CC}"
     export CXX="${BUILD_CXX}"
     export LD="${BUILD_LD}"
     export AR="${BUILD_AR}"
-
+    # These contain *target* flags but will be used as *native* flags.  The
+    # correct native flags will be passed via -Dc_args and so on, unset them so
+    # they don't interfere with tools invoked by Meson (such as g-ir-scanner)
+    unset CPPFLAGS CFLAGS CXXFLAGS LDFLAGS
 }
 
 meson_do_configure_prepend_class-target() {
-- 
2.11.0



  parent reply	other threads:[~2018-09-25 13:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 13:43 [PATCH 1/6] siteinfo: generalise siteinfo Ross Burton
2018-09-25 13:43 ` [PATCH 2/6] meson: squash the architecture warning patches together Ross Burton
2018-09-25 13:43 ` [PATCH 3/6] meson: pass correct endian in the cross file Ross Burton
2018-09-25 13:43 ` Ross Burton [this message]
2018-09-25 13:43 ` [PATCH 5/6] meson: respect target/native flag distinction in G-I and gtk-doc Ross Burton
2018-09-25 13:43 ` [PATCH 6/6] meson: make native-specific patches native-specific Ross Burton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180925134348.5562-4-ross.burton@intel.com \
    --to=ross.burton@intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox