[oe] [meta-oe][PATCH] meson: export native env only for native build

Martin Kelly mkelly at xevo.com
Tue Nov 14 18:23:42 UTC 2017


On 11/14/2017 04:36 AM, Alexander Kanavin wrote:
> On 11/13/2017 09:27 PM, Martin Kelly wrote:
>> 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.
> 
> Hello Martin,
> 
> meson support will land in oe-core shortly (and will be removed from 
> meta-oe), so can you please check if my patchset is doing the right thing?
> http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=akanavin/meson 
> 
> 
> Alex

Hi, excellent, I'm glad this is going to oe-core. I tried the 
meson.bbclass from your branch and it fails one of my builds because the 
CC variable is not found since it's unset.

It looks like the meson.bbclass in poky-contrib was forked at some point 
and some of the patches since have not been merged back in. I think some 
of them have needed fixes (e.g. the patch for PKG_CONFIG=pkg-config-native).

I believe the right configuration is:

For native builds:
- Keep the defaults (which use native tools), but export 
PKG_CONFIG=pkg-config-native instead of pkg-config.

For target builds:
- Set CC, CXX, LD, and AR, but *not* CFLAGS, CXXFLAGS, LDFLAGS etc. We 
need CC, CXX etc. so meson finds the native tools for its build sanity 
tests, but we don't want to set the flags, as meson will slurp them in 
and apply them to the cross build. Note that even though we set CC, etc. 
meson will correctly override them in the cross file for the actual 
target build.

By the way, I simplified my patch a little bit and made it slightly more 
correct, so I sent a patch v2 for this. I CC'ed you on that patch.



More information about the Openembedded-devel mailing list