summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2018-01-04 15:12:37 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-01-05 12:02:28 +0000
commitde7ae028c65a978969b2e06fdc1a2d08bc141a5b (patch)
tree4f417144b3a6d4b806f65711b1147e56111c78b5
parent32c2faf394ba7bf75a7273fb9f5e58cc4ee3f3ad (diff)
downloadopenembedded-core-contrib-de7ae028c65a978969b2e06fdc1a2d08bc141a5b.tar.gz
openembedded-core-contrib-de7ae028c65a978969b2e06fdc1a2d08bc141a5b.tar.bz2
openembedded-core-contrib-de7ae028c65a978969b2e06fdc1a2d08bc141a5b.zip
meson: export native env only for native build
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> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/meson.bbclass19
1 files changed, 12 insertions, 7 deletions
diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
index 5953b5d698..b72e5207ab 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"
}