From: Alexander Kanavin <alexander.kanavin@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH 8/9] meson: export native env only for native build
Date: Thu, 21 Dec 2017 15:04:33 +0200 [thread overview]
Message-ID: <20171221130434.24427-8-alexander.kanavin@linux.intel.com> (raw)
In-Reply-To: <20171221130434.24427-1-alexander.kanavin@linux.intel.com>
From: Martin Kelly <mkelly@xevo.com>
Although the meson crossfile should take care of setting the right cross
environment for a target build, meson slurps any set CFLAGS, CXXFLAGS,
LDFLAGS, and CPPFLAGS from the environment and injects them into the
build (see mesonbuild/environment.py:get_args_from_envvars for details).
This means that we are seeing native CFLAGS, CXXFLAGS, LDFLAGS, and
CPPFLAGS in the target build, which is wrong and causes build failures
when target and native have libraries in common (the linker gets
confused and bails).
That said, we *do* need to set certain vars for all builds so that meson
can find the right build tools. Without this, meson will fail during its
sanity checking step because it will determine the build tools to be
unrunnable since they output target instead of native artifacts.
The solution to all of this is to set CC, CXX, LD, and AR globally to
the native tools while setting the other native vars *only* for the
native build. For target builds, these vars will get overridden by the
cross file as we expect.
Signed-off-by: Martin Kelly <mkelly@xevo.com>
Signed-off-by: Alexander Kanavin <alexander.kanavin@linux.intel.com>
---
meta/classes/meson.bbclass | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 5953b5d698c..b72e5207abc 100644
--- a/meta/classes/meson.bbclass
+++ b/meta/classes/meson.bbclass
@@ -9,13 +9,6 @@ do_configure[cleandirs] = "${B}"
# Where the meson.build build configuration is
MESON_SOURCEPATH = "${S}"
-# These variables in the environment override meson's *native* tools settings.
-# We have to unset them, so that meson doesn't pick up the cross tools and
-# use them for native builds.
-unset CC
-unset CXX
-unset AR
-
def noprefix(var, d):
return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
@@ -92,6 +85,18 @@ meson_do_configure() {
fi
}
+meson_do_configure_prepend_class-target() {
+ # 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.
+ export CC="${BUILD_CC}"
+ export CXX="${BUILD_CXX}"
+ export LD="${BUILD_LD}"
+ export AR="${BUILD_AR}"
+}
+
meson_do_configure_prepend_class-native() {
export PKG_CONFIG="pkg-config-native"
}
--
2.15.1
next prev parent reply other threads:[~2017-12-21 13:10 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-21 13:04 [PATCH 1/9] meson: add a recipe and class from meta-oe Alexander Kanavin
2017-12-21 13:04 ` [PATCH 2/9] gnomebase.bbclass: split into autotools and meson versions Alexander Kanavin
2018-01-03 11:11 ` Richard Purdie
2018-01-04 13:13 ` Alexander Kanavin
2017-12-21 13:04 ` [PATCH 3/9] json-glib: convert to meson build Alexander Kanavin
2018-01-04 8:40 ` ChenQi
2018-01-04 12:35 ` Alexander Kanavin
2018-01-04 8:51 ` ChenQi
2018-01-04 9:27 ` Alexander Kanavin
2018-01-12 7:49 ` Yi Zhao
2017-12-21 13:04 ` [PATCH 4/9] libepoxy: " Alexander Kanavin
2017-12-21 13:04 ` [PATCH 5/9] libinput: " Alexander Kanavin
2017-12-21 13:04 ` [PATCH 6/9] sysprof: " Alexander Kanavin
2017-12-21 13:04 ` [PATCH 7/9] gst-player: Upgrade, rename to gst-examples Alexander Kanavin
2017-12-21 13:04 ` Alexander Kanavin [this message]
2017-12-21 13:04 ` [PATCH 9/9] meson: Port pkgconfig-native patch to 0.44.0 Alexander Kanavin
-- strict thread matches above, loose matches on Subject: below --
2018-01-04 13:12 [PATCH 1/9] meson: add a recipe and class from meta-oe Alexander Kanavin
2018-01-04 13:12 ` [PATCH 8/9] meson: export native env only for native build Alexander Kanavin
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=20171221130434.24427-8-alexander.kanavin@linux.intel.com \
--to=alexander.kanavin@linux.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