]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commit
meson: use absolute cross-compiler paths
authorEnguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Mon, 19 Feb 2024 16:55:24 +0000 (17:55 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 20 Feb 2024 12:58:20 +0000 (12:58 +0000)
commitb4e00248049c2627b05eafa9313a48cf253623fa
tree19f55eb53dc0ad837396bb97d4e8d98849725a7f
parent8a95ad9aecb81732c865e00a987bb8bd3d6cb91d
meson: use absolute cross-compiler paths

Among the files generated by meson is compile_commands.json. It is not
used by bitbake during the build. However, if the devtool workspace is
opened inside an IDE, that IDE can use compile_commands.json to
configure linting and code completion. This is notably relied on by the
new devtool ide-sdk command.

The problem is that the IDE using compile_commands.json does not know
the $PATH set-up by bitbake, so it won't find the compiler. This results
in linting errors, like missing headers. We can fix this by expliciting
the absolute compiler paths in meson.cross.

The compile_commands.json specification expressly states:
"All paths specified in the command or file fields must be either
absolute or relative to this directory."
Link: https://clang.llvm.org/docs/JSONCompilationDatabase.html
An alternative way to implement this is to directly change CXX inside
bitbake.conf to make all recipes use absolute compiler paths.Since this
would affect all recipes, so I would like to have the maintainers'
opinion on this. It could make sense to use absolute compiler paths for
all toolchain binaries, we already do so for the sysroot
TOOLCHAIN_OPTIONS.

Discussions have been opened with meson/ninja maintainers to implement
this at their level:
 - https://github.com/ninja-build/ninja/issues/2383
 - https://github.com/mesonbuild/meson/issues/12834
These tools have even less information on the environment so it makes
sense for Yocto to provide the absolute paths.

Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/meson-routines.bbclass
meta/classes-recipe/meson.bbclass