All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list
@ 2020-02-05 10:33 Arnout Vandecappelle
  2020-02-05 10:33 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Arnout Vandecappelle @ 2020-02-05 10:33 UTC (permalink / raw)
  To: buildroot

pkg-meson defines variables _MESON_SED_CFLAGS, _MESON_SED_LDFLAGS and
_MESON_SED_CXXFLAGS that reformat the make-style flags (space-separated
and unquoted) as meson-style flags (comma-separated and double-quoted).
Similar variables are also defined in meson.mk. A future patch will add
even more similar cases.

However, we already have a macro that does something similar for
generating JSON output: make-comma-list. So let's use that. However,
make-comma-list doesn't add all the shell-expanded magic like
_MESON_SED_CFLAGS, which results in the double quotes being removed by
the shell. Therefore, we also need to change the quoting around it to
single quotes instead of double quotes. For consistency, the quotes of
the other sed expressions are changed as well. Except for the
_MESON_EXTRA_BINARIES: the values set by packages (e.g. mesa3d) already
contain single quotes, so changing the surrounding quotes to double
would break them.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/meson/meson.mk |  4 ----
 package/pkg-meson.mk   | 42 +++++++++++++++++++-----------------------
 2 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/package/meson/meson.mk b/package/meson/meson.mk
index e51e76d1c0..810c84690a 100644
--- a/package/meson/meson.mk
+++ b/package/meson/meson.mk
@@ -45,10 +45,6 @@ else
 HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
 endif
 
-HOST_MESON_SED_CFLAGS = $(if $(strip $(TARGET_CFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
-HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
-HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
-
 # Avoid interpreter shebang longer than 128 chars
 define HOST_MESON_SET_INTERPRETER
 	$(SED) '1s:.*:#!/usr/bin/env python3:' $(HOST_DIR)/bin/meson
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index e7eea2aa58..1f3aaadf5d 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -61,24 +61,20 @@ $(2)_CFLAGS ?= $$(TARGET_CFLAGS)
 $(2)_LDFLAGS ?= $$(TARGET_LDFLAGS)
 $(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
 
-$(2)_MESON_SED_CFLAGS = $$(if $$(strip $$($(2)_CFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CFLAGS)`)
-$(2)_MESON_SED_LDFLAGS = $$(if $$(strip $$($(2)_LDFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_LDFLAGS)`)
-$(2)_MESON_SED_CXXFLAGS = $$(if $$(strip $$($(2)_CXXFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CXXFLAGS)`)
-
 # Configure package for target
 #
 #
 define $(2)_CONFIGURE_CMDS
 	rm -rf $$($$(PKG)_SRCDIR)/build
 	mkdir -p $$($$(PKG)_SRCDIR)/build
-	sed -e "s%@TARGET_CROSS@%$$(TARGET_CROSS)%g" \
-	    -e "s%@TARGET_ARCH@%$$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
-	    -e "s%@TARGET_CPU@%$$(GCC_TARGET_CPU)%g" \
-	    -e "s%@TARGET_ENDIAN@%$$(call LOWERCASE,$$(BR2_ENDIAN))%g" \
-	    -e "s%@TARGET_CFLAGS@%$$($(2)_MESON_SED_CFLAGS)%g" \
-	    -e "s%@TARGET_LDFLAGS@%$$($(2)_MESON_SED_LDFLAGS)%g" \
-	    -e "s%@TARGET_CXXFLAGS@%$$($(2)_MESON_SED_CXXFLAGS)%g" \
-	    -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
+	sed -e 's%@TARGET_CROSS@%$$(TARGET_CROSS)%g' \
+	    -e 's%@TARGET_ARCH@%$$(HOST_MESON_TARGET_CPU_FAMILY)%g' \
+	    -e 's%@TARGET_CPU@%$$(GCC_TARGET_CPU)%g' \
+	    -e 's%@TARGET_ENDIAN@%$$(call LOWERCASE,$$(BR2_ENDIAN))%g' \
+	    -e 's%@TARGET_CFLAGS@%$$(call make-comma-list,$$($(2)_CFLAGS))%g' \
+	    -e 's%@TARGET_LDFLAGS@%$$(call make-comma-list,$$($(2)_LDFLAGS))%g' \
+	    -e 's%@TARGET_CXXFLAGS@%$$(call make-comma-list,$$($(2)_CXXFLAGS))%g' \
+	    -e 's%@HOST_DIR@%$$(HOST_DIR)%g' \
 	    $$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
 	        -e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
 	    ) \
@@ -188,19 +184,19 @@ host-meson-package = $(call inner-meson-package,host-$(pkgname),$(call UPPERCASE
 # own flags if they need to.
 define PKG_MESON_INSTALL_CROSS_CONF
 	mkdir -p $(HOST_DIR)/etc/meson
-	sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
-	    -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
-	    -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
-	    -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
-	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)@PKG_TARGET_CFLAGS@%g" \
-	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)@PKG_TARGET_CFLAGS@%g" \
-	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)@PKG_TARGET_CFLAGS@%g" \
-	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
+	sed -e 's%@TARGET_CROSS@%$(TARGET_CROSS)%g' \
+	    -e 's%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g' \
+	    -e 's%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g' \
+	    -e 's%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g' \
+	    -e 's%@TARGET_CFLAGS@%$(call make-comma-list,$(TARGET_CFLAGS))@PKG_TARGET_CFLAGS@%g' \
+	    -e 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g' \
+	    -e 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g' \
+	    -e 's%@HOST_DIR@%$(HOST_DIR)%g' \
 	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
-	sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
-	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
-	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
+	sed -e 's%@PKG_TARGET_CFLAGS@%%g' \
+	    -e 's%@PKG_TARGET_LDFLAGS@%%g' \
+	    -e 's%@PKG_TARGET_CXXFLAGS@%%g' \
 	    $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
 endef
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir
  2020-02-05 10:33 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Arnout Vandecappelle
@ 2020-02-05 10:33 ` Arnout Vandecappelle
  2020-02-05 10:33 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
  2020-02-05 16:07 ` [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Yann E. MORIN
  2 siblings, 0 replies; 7+ messages in thread
From: Arnout Vandecappelle @ 2020-02-05 10:33 UTC (permalink / raw)
  To: buildroot

To allow meson to distinguish between pkg-config for host (= native)
and pkg-config for target (= cross), we want to be able to give a
different pkg_config_libdir for host and for target. meson already has a
'sys_root' option that sets the sysroot that is used by pkg-config, but
we also need explicit search directories for pkg-config.

Therefore, back-port an upstream patch (will be included in 0.54) that
adds this feature.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 ...onfig-add-pkg_config_libdir-property.patch | 102 ++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 package/meson/0003-envconfig-add-pkg_config_libdir-property.patch

diff --git a/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch b/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch
new file mode 100644
index 0000000000..ae40ab8b1c
--- /dev/null
+++ b/package/meson/0003-envconfig-add-pkg_config_libdir-property.patch
@@ -0,0 +1,102 @@
+From 3af920cb4a9c272b9b75a4f3eea9da9000520949 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= <scerveau@collabora.com>
+Date: Tue, 14 Jan 2020 11:11:52 +0100
+Subject: [PATCH] envconfig: add pkg_config_libdir property
+
+In order to unify the use of sysroot in the cross-file,
+the pkg_config_libdir can now be passed directly in the file.
+
+Upstream: 958df63dac810246e84c2b8eaa32d22d19ace0ef
+[Arnout: remove documentation changes: we don't extract docs/]
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+---
+ mesonbuild/dependencies/base.py |  6 ++++++
+ mesonbuild/envconfig.py         |  6 ++++++
+ run_unittests.py                | 30 +++++++++++++++++++++++++++++-
+ 3 files changed, 41 insertions(+), 1 deletion(-)
+
+diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
+index 40e304c7..282c314b 100644
+--- a/mesonbuild/dependencies/base.py
++++ b/mesonbuild/dependencies/base.py
+@@ -697,6 +697,12 @@ class PkgConfigDependency(ExternalDependency):
+         mlog.debug('PKG_CONFIG_PATH: ' + new_pkg_config_path)
+         env['PKG_CONFIG_PATH'] = new_pkg_config_path
+ 
++        pkg_config_libdir_prop = self.env.properties[self.for_machine].get_pkg_config_libdir()
++        if pkg_config_libdir_prop:
++            new_pkg_config_libdir = ':'.join([p for p in pkg_config_libdir_prop])
++            env['PKG_CONFIG_LIBDIR'] = new_pkg_config_libdir
++            mlog.debug('PKG_CONFIG_LIBDIR: ' + new_pkg_config_libdir)
++
+         fenv = frozenset(env.items())
+         targs = tuple(args)
+         cache = PkgConfigDependency.pkgbin_cache
+diff --git a/mesonbuild/envconfig.py b/mesonbuild/envconfig.py
+index c8a37f4c..3e5e44b8 100644
+--- a/mesonbuild/envconfig.py
++++ b/mesonbuild/envconfig.py
+@@ -143,6 +143,12 @@ class Properties(HasEnvVarFallback):
+     def get_sys_root(self) -> T.Optional[T.Union[str, T.List[str]]]:
+         return self.properties.get('sys_root', None)
+ 
++    def get_pkg_config_libdir(self) -> T.Optional[T.List[str]]:
++        p = self.properties.get('pkg_config_libdir', None)
++        if p is None:
++            return p
++        return mesonlib.listify(p)
++
+     def __eq__(self, other: T.Any) -> 'T.Union[bool, NotImplemented]':
+         if isinstance(other, type(self)):
+             return self.properties == other.properties
+diff --git a/run_unittests.py b/run_unittests.py
+index 676604f4..382c0964 100755
+--- a/run_unittests.py
++++ b/run_unittests.py
+@@ -3621,6 +3621,34 @@ recommended as it is not supported on some platforms''')
+         self.wipe()
+         self.init(testdir, extra_args=['-Dstart_native=true'], override_envvars=env)
+ 
++    @skipIfNoPkgconfig
++    @unittest.skipIf(is_windows(), 'Help needed with fixing this test on windows')
++    def test_pkg_config_libdir(self):
++        testdir = os.path.join(self.unit_test_dir,
++                               '46 native dep pkgconfig var')
++        with tempfile.NamedTemporaryFile(mode='w', delete=False) as crossfile:
++            crossfile.write(textwrap.dedent(
++                '''[binaries]
++                pkgconfig = 'pkg-config'
++
++                [properties]
++                pkg_config_libdir = [r'{0}']
++
++                [host_machine]
++                system = 'linux'
++                cpu_family = 'arm'
++                cpu = 'armv7'
++                endian = 'little'
++                '''.format(os.path.join(testdir, 'cross_pkgconfig'))))
++            crossfile.flush()
++            self.meson_cross_file = crossfile.name
++
++        env = {'PKG_CONFIG_LIBDIR':  os.path.join(testdir,
++                                                  'native_pkgconfig')}
++        self.init(testdir, extra_args=['-Dstart_native=false'], override_envvars=env)
++        self.wipe()
++        self.init(testdir, extra_args=['-Dstart_native=true'], override_envvars=env)
++
+     def __reconfigure(self, change_minor=False):
+         # Set an older version to force a reconfigure from scratch
+         filename = os.path.join(self.privatedir, 'coredata.dat')
+@@ -6847,7 +6875,7 @@ class NativeFileTests(BasePlatformTests):
+ 
+ class CrossFileTests(BasePlatformTests):
+ 
+-    """Tests for cross file functioality not directly related to
++    """Tests for cross file functionality not directly related to
+     cross compiling.
+ 
+     This is mainly aimed to testing overrides from cross files.
+-- 
+2.24.1
+
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings
  2020-02-05 10:33 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Arnout Vandecappelle
  2020-02-05 10:33 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
@ 2020-02-05 10:33 ` Arnout Vandecappelle
  2020-02-19 20:38   ` Thomas Petazzoni
  2020-02-05 16:07 ` [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Yann E. MORIN
  2 siblings, 1 reply; 7+ messages in thread
From: Arnout Vandecappelle @ 2020-02-05 10:33 UTC (permalink / raw)
  To: buildroot

meson is able to distinguish between host (= native) and target (=
cross) compilation. It will explicitly pass different options to
pkg-config to distinguish them. Therefore, we don't need to use the
pkg-config wrapper when using meson, and can instead pass the pkg-config
settings through the cross-compilation.conf.

This is important because in some situations (e.g. for the Python
configuration), meson sets the PKG_CONFIG_LIBDIR variable to a different
value before calling pkg-config. Relying on our wrapper script doesn't
work in that case (except if the script would unconditionally set
PKG_CONFIG_LIBDIR, which it doesn't do at the moment).

Add the sys_root and pkg_config_lib settings to cross-compilation.conf
and use pkgconf directly instead of the wrapper.

Note that this requires us to substitute STAGING_DIR as well, with an
absolute path. This is not a big deal since cross-compilation.conf is
regenerated for every package.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/meson/cross-compilation.conf.in | 4 +++-
 package/pkg-meson.mk                    | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/meson/cross-compilation.conf.in b/package/meson/cross-compilation.conf.in
index fc8e27f7eb..369e225b3e 100644
--- a/package/meson/cross-compilation.conf.in
+++ b/package/meson/cross-compilation.conf.in
@@ -8,7 +8,7 @@ c = '@TARGET_CROSS at gcc'
 cpp = '@TARGET_CROSS at g++'
 ar = '@TARGET_CROSS at ar'
 strip = '@TARGET_CROSS at strip'
-pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
+pkgconfig = '@HOST_DIR@/bin/pkgconf'
 
 [properties]
 needs_exe_wrapper = true
@@ -16,6 +16,8 @@ c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
 cpp_link_args = [@TARGET_LDFLAGS@]
+sys_root = '@STAGING_DIR@'
+pkg_config_libdir = '@STAGING_DIR@/usr/lib/pkgconfig:@STAGING_DIR@/usr/share/pkgconfig'
 
 [host_machine]
 system = 'linux'
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index 1f3aaadf5d..642b715938 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -75,6 +75,7 @@ define $(2)_CONFIGURE_CMDS
 	    -e 's%@TARGET_LDFLAGS@%$$(call make-comma-list,$$($(2)_LDFLAGS))%g' \
 	    -e 's%@TARGET_CXXFLAGS@%$$(call make-comma-list,$$($(2)_CXXFLAGS))%g' \
 	    -e 's%@HOST_DIR@%$$(HOST_DIR)%g' \
+	    -e 's%@STAGING_DIR@%$$(STAGING_DIR)%g' \
 	    $$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
 	        -e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
 	    ) \
@@ -192,6 +193,7 @@ define PKG_MESON_INSTALL_CROSS_CONF
 	    -e 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g' \
 	    -e 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g' \
 	    -e 's%@HOST_DIR@%$(HOST_DIR)%g' \
+	    -e 's%@STAGING_DIR@%$$(STAGING_DIR)%g' \
 	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
 	sed -e 's%@PKG_TARGET_CFLAGS@%%g' \
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list
  2020-02-05 10:33 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Arnout Vandecappelle
  2020-02-05 10:33 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
  2020-02-05 10:33 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
@ 2020-02-05 16:07 ` Yann E. MORIN
  2 siblings, 0 replies; 7+ messages in thread
From: Yann E. MORIN @ 2020-02-05 16:07 UTC (permalink / raw)
  To: buildroot

Arnout, All,

On 2020-02-05 11:33 +0100, Arnout Vandecappelle (Essensium/Mind) spake thusly:
> pkg-meson defines variables _MESON_SED_CFLAGS, _MESON_SED_LDFLAGS and
> _MESON_SED_CXXFLAGS that reformat the make-style flags (space-separated
> and unquoted) as meson-style flags (comma-separated and double-quoted).
> Similar variables are also defined in meson.mk. A future patch will add
> even more similar cases.
> 
> However, we already have a macro that does something similar for
> generating JSON output: make-comma-list. So let's use that. However,
> make-comma-list doesn't add all the shell-expanded magic like
> _MESON_SED_CFLAGS, which results in the double quotes being removed by
> the shell. Therefore, we also need to change the quoting around it to
> single quotes instead of double quotes. For consistency, the quotes of
> the other sed expressions are changed as well. Except for the
> _MESON_EXTRA_BINARIES: the values set by packages (e.g. mesa3d) already
> contain single quotes, so changing the surrounding quotes to double
> would break them.

That's the opposite: changing to single quotes would break them.

I fixed and applied to master, thanks.

Regards,
Yann E. MORIN.

> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> ---
>  package/meson/meson.mk |  4 ----
>  package/pkg-meson.mk   | 42 +++++++++++++++++++-----------------------
>  2 files changed, 19 insertions(+), 27 deletions(-)
> 
> diff --git a/package/meson/meson.mk b/package/meson/meson.mk
> index e51e76d1c0..810c84690a 100644
> --- a/package/meson/meson.mk
> +++ b/package/meson/meson.mk
> @@ -45,10 +45,6 @@ else
>  HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
>  endif
>  
> -HOST_MESON_SED_CFLAGS = $(if $(strip $(TARGET_CFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
> -HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
> -HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
> -
>  # Avoid interpreter shebang longer than 128 chars
>  define HOST_MESON_SET_INTERPRETER
>  	$(SED) '1s:.*:#!/usr/bin/env python3:' $(HOST_DIR)/bin/meson
> diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
> index e7eea2aa58..1f3aaadf5d 100644
> --- a/package/pkg-meson.mk
> +++ b/package/pkg-meson.mk
> @@ -61,24 +61,20 @@ $(2)_CFLAGS ?= $$(TARGET_CFLAGS)
>  $(2)_LDFLAGS ?= $$(TARGET_LDFLAGS)
>  $(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
>  
> -$(2)_MESON_SED_CFLAGS = $$(if $$(strip $$($(2)_CFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CFLAGS)`)
> -$(2)_MESON_SED_LDFLAGS = $$(if $$(strip $$($(2)_LDFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_LDFLAGS)`)
> -$(2)_MESON_SED_CXXFLAGS = $$(if $$(strip $$($(2)_CXXFLAGS)),`printf '"%s"$$(comma) ' $$($(2)_CXXFLAGS)`)
> -
>  # Configure package for target
>  #
>  #
>  define $(2)_CONFIGURE_CMDS
>  	rm -rf $$($$(PKG)_SRCDIR)/build
>  	mkdir -p $$($$(PKG)_SRCDIR)/build
> -	sed -e "s%@TARGET_CROSS@%$$(TARGET_CROSS)%g" \
> -	    -e "s%@TARGET_ARCH@%$$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
> -	    -e "s%@TARGET_CPU@%$$(GCC_TARGET_CPU)%g" \
> -	    -e "s%@TARGET_ENDIAN@%$$(call LOWERCASE,$$(BR2_ENDIAN))%g" \
> -	    -e "s%@TARGET_CFLAGS@%$$($(2)_MESON_SED_CFLAGS)%g" \
> -	    -e "s%@TARGET_LDFLAGS@%$$($(2)_MESON_SED_LDFLAGS)%g" \
> -	    -e "s%@TARGET_CXXFLAGS@%$$($(2)_MESON_SED_CXXFLAGS)%g" \
> -	    -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
> +	sed -e 's%@TARGET_CROSS@%$$(TARGET_CROSS)%g' \
> +	    -e 's%@TARGET_ARCH@%$$(HOST_MESON_TARGET_CPU_FAMILY)%g' \
> +	    -e 's%@TARGET_CPU@%$$(GCC_TARGET_CPU)%g' \
> +	    -e 's%@TARGET_ENDIAN@%$$(call LOWERCASE,$$(BR2_ENDIAN))%g' \
> +	    -e 's%@TARGET_CFLAGS@%$$(call make-comma-list,$$($(2)_CFLAGS))%g' \
> +	    -e 's%@TARGET_LDFLAGS@%$$(call make-comma-list,$$($(2)_LDFLAGS))%g' \
> +	    -e 's%@TARGET_CXXFLAGS@%$$(call make-comma-list,$$($(2)_CXXFLAGS))%g' \
> +	    -e 's%@HOST_DIR@%$$(HOST_DIR)%g' \
>  	    $$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
>  	        -e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
>  	    ) \
> @@ -188,19 +184,19 @@ host-meson-package = $(call inner-meson-package,host-$(pkgname),$(call UPPERCASE
>  # own flags if they need to.
>  define PKG_MESON_INSTALL_CROSS_CONF
>  	mkdir -p $(HOST_DIR)/etc/meson
> -	sed -e "s%@TARGET_CROSS@%$(TARGET_CROSS)%g" \
> -	    -e "s%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g" \
> -	    -e "s%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g" \
> -	    -e "s%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g" \
> -	    -e "s%@TARGET_CFLAGS@%$(HOST_MESON_SED_CFLAGS)@PKG_TARGET_CFLAGS@%g" \
> -	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)@PKG_TARGET_CFLAGS@%g" \
> -	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)@PKG_TARGET_CFLAGS@%g" \
> -	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
> +	sed -e 's%@TARGET_CROSS@%$(TARGET_CROSS)%g' \
> +	    -e 's%@TARGET_ARCH@%$(HOST_MESON_TARGET_CPU_FAMILY)%g' \
> +	    -e 's%@TARGET_CPU@%$(HOST_MESON_TARGET_CPU)%g' \
> +	    -e 's%@TARGET_ENDIAN@%$(HOST_MESON_TARGET_ENDIAN)%g' \
> +	    -e 's%@TARGET_CFLAGS@%$(call make-comma-list,$(TARGET_CFLAGS))@PKG_TARGET_CFLAGS@%g' \
> +	    -e 's%@TARGET_LDFLAGS@%$(call make-comma-list,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g' \
> +	    -e 's%@TARGET_CXXFLAGS@%$(call make-comma-list,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g' \
> +	    -e 's%@HOST_DIR@%$(HOST_DIR)%g' \
>  	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
>  	    > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
> -	sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
> -	    -e "s%@PKG_TARGET_LDFLAGS@%%g" \
> -	    -e "s%@PKG_TARGET_CXXFLAGS@%%g" \
> +	sed -e 's%@PKG_TARGET_CFLAGS@%%g' \
> +	    -e 's%@PKG_TARGET_LDFLAGS@%%g' \
> +	    -e 's%@PKG_TARGET_CXXFLAGS@%%g' \
>  	    $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
>  	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
>  endef
> -- 
> 2.24.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings
  2020-02-05 10:33 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
@ 2020-02-19 20:38   ` Thomas Petazzoni
  2020-02-20  9:05     ` Arnout Vandecappelle
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2020-02-19 20:38 UTC (permalink / raw)
  To: buildroot

Hello Arnout,

On Wed,  5 Feb 2020 11:33:04 +0100
"Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be> wrote:

> meson is able to distinguish between host (= native) and target (=
> cross) compilation. It will explicitly pass different options to
> pkg-config to distinguish them. Therefore, we don't need to use the
> pkg-config wrapper when using meson, and can instead pass the pkg-config
> settings through the cross-compilation.conf.
> 
> This is important because in some situations (e.g. for the Python
> configuration), meson sets the PKG_CONFIG_LIBDIR variable to a different
> value before calling pkg-config. Relying on our wrapper script doesn't
> work in that case (except if the script would unconditionally set
> PKG_CONFIG_LIBDIR, which it doesn't do at the moment).
> 
> Add the sys_root and pkg_config_lib settings to cross-compilation.conf
> and use pkgconf directly instead of the wrapper.
> 
> Note that this requires us to substitute STAGING_DIR as well, with an
> absolute path. This is not a big deal since cross-compilation.conf is
> regenerated for every package.
> 
> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

Unfortunately, this breaks the build of libglib2 in static linking
scenarios:

  http://autobuild.buildroot.net/results/35c/35ce460192581a3ce2866ef5d3cb5391afd68cc5/build-end.log

And now that I have merged the fixes for the erlang an sdbusplus
issues, this libglib2 issue is the #1 issue hitting the autobuilders on
master.

The problem comes from the fact that by skipping the wrapper, you are
no longer passing the --static option to pkg-config when building
statically.

From a quick look at build/lib/mesonbuild/dependencies/base.py in the
Meson code base, it seems like there is some way to have it pass
--static to pkg-config:

        if self.static:
            libcmd.append('--static')

But it's not clear to me how that happens. Perhaps with your better
knowledge of the Meson code base you will have an idea here ?

Of course, we don't want to unconditionally pass --static, as --static
should be passed when using pkg-config to look up for target libraries,
but not when looking up for host libraries, and the whole point of your
initial patch was precisely to leave it up to meson to invoke
pkg-config the "right" way depending on whether it was cross-compiling
something or natively compiling.

Could you help here ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings
  2020-02-19 20:38   ` Thomas Petazzoni
@ 2020-02-20  9:05     ` Arnout Vandecappelle
  0 siblings, 0 replies; 7+ messages in thread
From: Arnout Vandecappelle @ 2020-02-20  9:05 UTC (permalink / raw)
  To: buildroot



On 19/02/2020 21:38, Thomas Petazzoni wrote:
> Hello Arnout,
> 
> On Wed,  5 Feb 2020 11:33:04 +0100
> "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be> wrote:
> 
>> meson is able to distinguish between host (= native) and target (=
>> cross) compilation. It will explicitly pass different options to
>> pkg-config to distinguish them. Therefore, we don't need to use the
>> pkg-config wrapper when using meson, and can instead pass the pkg-config
>> settings through the cross-compilation.conf.
>>
>> This is important because in some situations (e.g. for the Python
>> configuration), meson sets the PKG_CONFIG_LIBDIR variable to a different
>> value before calling pkg-config. Relying on our wrapper script doesn't
>> work in that case (except if the script would unconditionally set
>> PKG_CONFIG_LIBDIR, which it doesn't do at the moment).
>>
>> Add the sys_root and pkg_config_lib settings to cross-compilation.conf
>> and use pkgconf directly instead of the wrapper.
>>
>> Note that this requires us to substitute STAGING_DIR as well, with an
>> absolute path. This is not a big deal since cross-compilation.conf is
>> regenerated for every package.
>>
>> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> 
> Unfortunately, this breaks the build of libglib2 in static linking
> scenarios:
> 
>   http://autobuild.buildroot.net/results/35c/35ce460192581a3ce2866ef5d3cb5391afd68cc5/build-end.log
> 
> And now that I have merged the fixes for the erlang an sdbusplus
> issues, this libglib2 issue is the #1 issue hitting the autobuilders on
> master.
> 
> The problem comes from the fact that by skipping the wrapper, you are
> no longer passing the --static option to pkg-config when building
> statically.
> 
> From a quick look at build/lib/mesonbuild/dependencies/base.py in the
> Meson code base, it seems like there is some way to have it pass
> --static to pkg-config:
> 
>         if self.static:
>             libcmd.append('--static')

 self.static is set based on settings in the project, not anything that we can
control from the outside (at least from a quick look at the source).


> But it's not clear to me how that happens. Perhaps with your better
> knowledge of the Meson code base you will have an idea here ?
> 
> Of course, we don't want to unconditionally pass --static, as --static
> should be passed when using pkg-config to look up for target libraries,
> but not when looking up for host libraries, and the whole point of your
> initial patch was precisely to leave it up to meson to invoke
> pkg-config the "right" way depending on whether it was cross-compiling
> something or natively compiling.

 No it wasn't. meson only uses cross-compilation.conf for target compile. So for
native compile, it will use the pkg-config from PATH (which indeed is also wrong
because it will still give target settings). I had another patch that pointed
meson to pkgconf directly as well for native compilation. (This is all from
memory, I may be mistaken...)

 The point of that patch was to make sure that meson knows about the
PKG_CONFIG_LIBDIR that we want it to use, because otherwise it is going to set
the PKG_CONFIG_LIBDIR variable itself to a wrong value and thus bypass the
setting we do in the pkg-config wrapper.

 It is true that I completely forgot about the --static (and --keep-system-libs,
but I'm not sure why we pass *that*...).

 For the problem addressed by my original patch, I think we can in fact *still*
call the wrapper, but also set the pkg_config_libdir and sys_root meson configs.
That way, PKG_CONFIG_LIBDIR will always be set in the environment when calling
pkg-config, so that part of the wrapper gets overridden, but the rest still
applies. If the wrapper is still called, the sys_root part is probably not
needed any more either since the wrapper sets PKG_CONFIG_SYSROOT_DIR, and meson
only overrides it when sys_root is set (again, as far as I can see from a quick
scan of the source).


 Regards,
 Arnout


> 
> Could you help here ?
> 
> Thanks!
> 
> Thomas
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings
  2020-02-04 16:58 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Arnout Vandecappelle
@ 2020-02-04 16:58 ` Arnout Vandecappelle
  0 siblings, 0 replies; 7+ messages in thread
From: Arnout Vandecappelle @ 2020-02-04 16:58 UTC (permalink / raw)
  To: buildroot

meson is able to distinguish between host (= native) and target (=
cross) compilation. It will explicitly pass different options to
pkg-config to distinguish them. Therefore, we don't need to use the
pkg-config wrapper when using meson, and can instead pass the pkg-config
settings through the cross-compilation.conf.

This is important because in some situations (e.g. for the Python
configuration), meson sets the PKG_CONFIG_LIBDIR variable to a different
value before calling pkg-config. Relying on our wrapper script doesn't
work in that case (except if the script would unconditionally set
PKG_CONFIG_LIBDIR, which it doesn't do at the moment).

Add the sys_root and pkg_config_lib settings to cross-compilation.conf
and use pkgconf directly instead of the wrapper.

Note that this requires us to substitute STAGING_DIR as well, with an
absolute path. This is not a big deal since cross-compilation.conf is
regenerated for every package.

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
 package/meson/cross-compilation.conf.in | 4 +++-
 package/pkg-meson.mk                    | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/meson/cross-compilation.conf.in b/package/meson/cross-compilation.conf.in
index fc8e27f7eb..369e225b3e 100644
--- a/package/meson/cross-compilation.conf.in
+++ b/package/meson/cross-compilation.conf.in
@@ -8,7 +8,7 @@ c = '@TARGET_CROSS at gcc'
 cpp = '@TARGET_CROSS at g++'
 ar = '@TARGET_CROSS at ar'
 strip = '@TARGET_CROSS at strip'
-pkgconfig = '@HOST_DIR@/usr/bin/pkg-config'
+pkgconfig = '@HOST_DIR@/bin/pkgconf'
 
 [properties]
 needs_exe_wrapper = true
@@ -16,6 +16,8 @@ c_args = [@TARGET_CFLAGS@]
 c_link_args = [@TARGET_LDFLAGS@]
 cpp_args = [@TARGET_CXXFLAGS@]
 cpp_link_args = [@TARGET_LDFLAGS@]
+sys_root = '@STAGING_DIR@'
+pkg_config_libdir = '@STAGING_DIR@/usr/lib/pkgconfig:@STAGING_DIR@/usr/share/pkgconfig'
 
 [host_machine]
 system = 'linux'
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index f1a3a69129..6bed2c26d2 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -79,6 +79,7 @@ define $(2)_CONFIGURE_CMDS
 	    -e "s%@TARGET_LDFLAGS@%$$(call meson-format-flags,$$($(2)_LDFLAGS))%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$$(call meson-format-flags,$$($(2)_CXXFLAGS))%g" \
 	    -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
+	    -e "s%@STAGING_DIR@%$$(STAGING_DIR)%g" \
 	    $$(foreach x,$$($(2)_MESON_EXTRA_BINARIES), \
 	        -e "/^\[binaries\]$$$$/s:$$$$:\n$$(x):" \
 	    ) \
@@ -196,6 +197,7 @@ define PKG_MESON_INSTALL_CROSS_CONF
 	    -e "s%@TARGET_LDFLAGS@%$(call meson-format-flags,$(TARGET_LDFLAGS))@PKG_TARGET_CFLAGS@%g" \
 	    -e "s%@TARGET_CXXFLAGS@%$(call meson-format-flags,$(TARGET_CXXFLAGS))@PKG_TARGET_CFLAGS@%g" \
 	    -e "s%@HOST_DIR@%$(HOST_DIR)%g" \
+	    -e "s%@STAGING_DIR@%$$(STAGING_DIR)%g" \
 	    $(HOST_MESON_PKGDIR)/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf.in
 	sed -e "s%@PKG_TARGET_CFLAGS@%%g" \
-- 
2.24.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-02-20  9:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 10:33 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Arnout Vandecappelle
2020-02-05 10:33 ` [Buildroot] [PATCH 2/3] package/meson: add upstream patch to support pkg_config_libdir Arnout Vandecappelle
2020-02-05 10:33 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle
2020-02-19 20:38   ` Thomas Petazzoni
2020-02-20  9:05     ` Arnout Vandecappelle
2020-02-05 16:07 ` [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution with make-comma-list Yann E. MORIN
  -- strict thread matches above, loose matches on Subject: below --
2020-02-04 16:58 [Buildroot] [PATCH 1/3] package/pkg-meson.mk: refactor flags substitution into function Arnout Vandecappelle
2020-02-04 16:58 ` [Buildroot] [PATCH 3/3] package/pkg-meson.mk: explicitly specify pkg-config settings Arnout Vandecappelle

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.