infra/pkg-meson: avoid host ccache detection
PATCH 1/1 infra/pkg-meson: avoid host ccache detection
meson will by default try to detect the presence of ccache, and if found, will use it unconditioanlly.
However, using a system-wide ccache, which would be using our own cache directory, may very well conflict with our own ccache.
But there is option to disable that meson nehaviour. The only workaround that is even the official documented way to do so, is to actually pass envornment variables that point to the compiler:
https://mesonbuild.com/Feature-autodetection.html#ccache
For the host variants, we pass $(HOST_CONFIGURE_OPTS) in the environment, and this contains correct settings for CC and CXX, so meson does not try and detect ccache; it uses exactly what we tell it to use.
For the target variant, the settings for the cross-compiler are defined in the cross-compilation file, and so meson just abides by our will. But for the compiler-for-build, there is no way to specify the CC_FOR_BUILD or CXX_FOR_BUILD via a cross-compilation file:
https://mesonbuild.com/Machine-files.html
https://mesonbuild.com/Cross-compilation.html
We could pass the full TARGET_CONFIGURE_OPTS in the environment, like we do for the host variant, but this contains a lot more variables that are supposed to be covered by the cross-compilation file.
So, we stay safe and just provide the exact two variables that meson will use to avoid detecting ccache.
If the current configuration defines the use of ccache, then these two variables will be properly setup to use our own ccache.
--- package/pkg-meson.mk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
package/pkg-meson.mk +5 -1
@@ -81,7 +81,11 @@ define $(2)_CONFIGURE_CMDS -e "/^\[properties\]$$$$/s:$$$$:$$(foreach x,$$($(2)_MESON_EXTRA_PROPERTIES),\n$$(x)):" \ package/meson/cross-compilation.conf.in \ > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf - PATH=$$(BR_PATH) $$($$(PKG)_CONF_ENV) $$(MESON) \ + PATH=$$(BR_PATH) \ + CC_FOR_BUILD="$(HOSTCC)" \ + CXX_FOR_BUILD="$(HOSTCC)" \ + $$($$(PKG)_CONF_ENV) \ + $$(MESON) \ --prefix=/usr \ --libdir=lib \ --default-library=$(if $(BR2_STATIC_LIBS),static,shared) \
Signature · 1 line
2.25.1
PATCH 1/1 infra/pkg-meson: avoid host ccache detection
Quoted 33 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Yann" == Yann E MORIN <[email protected]> writes:
meson will by default try to detect the presence of ccache, and if found, will use it unconditioanlly.
However, using a system-wide ccache, which would be using our own cache directory, may very well conflict with our own ccache.
But there is option to disable that meson nehaviour. The only workaround that is even the official documented way to do so, is to actually pass envornment variables that point to the compiler:
https://mesonbuild.com/Feature-autodetection.html#ccache
For the host variants, we pass $(HOST_CONFIGURE_OPTS) in the environment, and this contains correct settings for CC and CXX, so meson does not try and detect ccache; it uses exactly what we tell it to use.
For the target variant, the settings for the cross-compiler are defined in the cross-compilation file, and so meson just abides by our will. But for the compiler-for-build, there is no way to specify the
CC_FOR_BUILDorCXX_FOR_BUILDvia a cross-compilation file:https://mesonbuild.com/Machine-files.html
https://mesonbuild.com/Cross-compilation.htmlWe could pass the full
TARGET_CONFIGURE_OPTSin the environment, like we do for the host variant, but this contains a lot more variables that are supposed to be covered by the cross-compilation file.So, we stay safe and just provide the exact two variables that meson will use to avoid detecting ccache.
Quoted 8 lines
If the current configuration defines the use of ccache, then these two variables will be properly setup to use our own ccache.
Signed-off-by Yann E. MORIN <[email protected]>Cc Arnout Vandecappelle <[email protected]>Cc Gleb Mazovetskiy <[email protected]>Cc James Hilliard <[email protected]>Cc Norbert Lange <[email protected]>
Committed to 2020.02.x and 2020.11.x, thanks.
Signature · 1 line
Bye, Peter Korsgaard