summaryrefslogtreecommitdiffstats
path: root/meta
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:37 +0000
commitf43713878453473b1be65fc5669c9c8147ed496f (patch)
treeb26b51738994fbd12310ad5a009ef1a8b0edda73 /meta
parent0131136504e5cc16e8c95ab12d366d7ad2530fc4 (diff)
downloadpoky-f43713878453473b1be65fc5669c9c8147ed496f.tar.gz
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. (From OE-Core rev: de7ae028c65a978969b2e06fdc1a2d08bc141a5b) 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>
Diffstat (limited to 'meta')
-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}"
9# Where the meson.build build configuration is 9# Where the meson.build build configuration is
10MESON_SOURCEPATH = "${S}" 10MESON_SOURCEPATH = "${S}"
11 11
12# These variables in the environment override meson's *native* tools settings.
13# We have to unset them, so that meson doesn't pick up the cross tools and
14# use them for native builds.
15unset CC
16unset CXX
17unset AR
18
19def noprefix(var, d): 12def noprefix(var, d):
20 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1) 13 return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
21 14
@@ -92,6 +85,18 @@ meson_do_configure() {
92 fi 85 fi
93} 86}
94 87
88meson_do_configure_prepend_class-target() {
89 # Set these so that meson uses the native tools for its build sanity tests,
90 # which require executables to be runnable. The cross file will still
91 # override these for the target build. Note that we do *not* set CFLAGS,
92 # LDFLAGS, etc. as they will be slurped in by meson and applied to the
93 # target build, causing errors.
94 export CC="${BUILD_CC}"
95 export CXX="${BUILD_CXX}"
96 export LD="${BUILD_LD}"
97 export AR="${BUILD_AR}"
98}
99
95meson_do_configure_prepend_class-native() { 100meson_do_configure_prepend_class-native() {
96 export PKG_CONFIG="pkg-config-native" 101 export PKG_CONFIG="pkg-config-native"
97} 102}