All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags)
@ 2019-06-24 20:25 Yann E. MORIN
  2019-06-24 20:25 ` [Buildroot] [PATCH 1/4] package/meson: fix empty arguments in cross-compilation.conf Yann E. MORIN
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-24 20:25 UTC (permalink / raw)
  To: buildroot

Hello All!

With meson, it is impossible to pass extra CFLAGS or override them
entirely from the command line (i.e. neither in the environment nor as
command line arguments). Worse, if we were to do so, they would be
passed to the host compiler, not the target compiler.

This series adds two changes to the meson infrastructure:
  - a fix for when the *FLAGS variables are empty ut with spaces,
  - the ability for packages to pass their own *FLAGS if they need to.

Finally, two changes are done in libglib2, that take advantage of this
new feature:
  - fix the build when the external gettext provides the i18n functions,
  - fix the build on ARM in Thumb mode.

Thanks to Peter S. for the initial infra patch, thanks to Thomas for a
previous review, and thanks to Adam for investigting a bug that led to
the first patch and parts of the second patch, as well as proof-reading
my crappy commit logs; any leftover typo is entirely his fault, now!
Muahaha! ;-]


Regards,
Yann E. MORIN.


The following changes since commit cd1b1773dd6cf585c18ea836192787b1f20727ad

  package/libglib2: security bump to version 2.60.4 (2019-06-24 06:36:21 +0200)


are available in the git repository at:

  git://git.buildroot.org/~ymorin/git/buildroot.git

for you to fetch changes up to cc3b7eda26b3838277ec43a1c956dbb8c55cf602

  package/libglib2: fix build on ARM in Thumb mode (2019-06-24 21:58:51 +0200)


----------------------------------------------------------------
Peter Seiderer (1):
      infra/pkg-meson: allow packages to pass custom compiler/linker flags

Yann E. MORIN (3):
      package/meson: fix empty arguments in cross-compilation.conf
      package/libglib2: fix NLS build on musl and uclibc
      package/libglib2: fix build on ARM in Thumb mode

 docs/manual/adding-packages-meson.txt | 12 ++++++++++++
 package/libglib2/libglib2.mk          |  5 ++++-
 package/meson/meson.mk                | 20 +++++++++++++-------
 package/pkg-meson.mk                  | 14 +++++++++++---
 4 files changed, 40 insertions(+), 11 deletions(-)

-- 
.-----------------.--------------------.------------------.--------------------.
|  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] 12+ messages in thread

* [Buildroot] [PATCH 1/4] package/meson: fix empty arguments in cross-compilation.conf
  2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
@ 2019-06-24 20:25 ` Yann E. MORIN
  2019-06-24 20:25 ` [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags Yann E. MORIN
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-24 20:25 UTC (permalink / raw)
  To: buildroot

When TARGET_CFLAGS (or _LDFLAGS or _CXXFLAGS) are empty, but were
constructed by appending other variables, like:

    TARGET_CFLAGS = $(SOMETHING) $(SOMETHING_ELSE)

and both variables are empty, then $(TARGET_CFLAGS) is _not_ the
null-string; it's value is a string made of a single space.

This means that the construct:

    $(if $(TARGET_CFLAGS),true,false)

will in fact return 'true'.

In our case, it means that we will call:

    `printf '"%s", ' `

which expands to just:

    "",

which we are then happy to insert as-is in the generated
cross-compilation.conf.

Then meson, will happily call the compiler with an empty argument.

The compiler is less happy, though:

    arm-none-linux-gnueabi-gcc: error: : No such file or directory

And this is not even trivial to debug either... The only clue being that
there seems to be something missing between ': :'

We fix that testing the $(strip)ed value. We can still pass the
non-$(strip) expansion, because the shell will just do it for us, and we
are then sure there is at least one non-blank word in there.

Thanks a lot to Adam for his invaluable help debugging this!

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Arnout Vandecappelle <arnout@mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 package/meson/meson.mk | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/package/meson/meson.mk b/package/meson/meson.mk
index 5b5100cccc..511be05a46 100644
--- a/package/meson/meson.mk
+++ b/package/meson/meson.mk
@@ -45,9 +45,9 @@ else
 HOST_MESON_TARGET_CPU_FAMILY = $(ARCH)
 endif
 
-HOST_MESON_SED_CFLAGS = $(if $(TARGET_CFLAGS),`printf '"%s"$(comma) ' $(TARGET_CFLAGS)`)
-HOST_MESON_SED_LDFLAGS = $(if $(TARGET_LDFLAGS),`printf '"%s"$(comma) ' $(TARGET_LDFLAGS)`)
-HOST_MESON_SED_CXXFLAGS = $(if $(TARGET_CXXFLAGS),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
+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)`)
 
 # Generate a Meson cross-compilation.conf suitable for use with the
 # SDK
-- 
2.20.1

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
  2019-06-24 20:25 ` [Buildroot] [PATCH 1/4] package/meson: fix empty arguments in cross-compilation.conf Yann E. MORIN
@ 2019-06-24 20:25 ` Yann E. MORIN
  2019-06-25 20:28   ` Peter Seiderer
  2019-06-30 16:12   ` Arnout Vandecappelle
  2019-06-24 20:25 ` [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc Yann E. MORIN
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-24 20:25 UTC (permalink / raw)
  To: buildroot

From: Peter Seiderer <ps.report@gmx.net>

Meson does not allow to pass CFLAGS/LDFLAGS/CXXFLAGS via the environment
or via command-line arguments or options (instead, those flags from the
environment are passed to the host compiler, which is seldom what we
need). The only way to pas those flags is via the cross-compilation.conf
file.

Add LIBFOO_CFLAGS, LIBFOO_LDFLAGS and LIBFOO_CXXFLAGS variables to allow
packages to provide their own flags, possibly overriding the generic
ones entirely, as we allow for other infras. Those per-package flags will
then be used to generate the per-package cross-compilation.conf.

This means that the meson infra is the first and only infra for which
FOO_CFLAGS, FOO_LDFLAGS, and FOO_CXXFLAGS are meaningful, while for the
other infras, they are just variables private to the package itself.
Instead of naming those variables after the meson infra (e.g.
FOO_MESON_CFLAGS), we name them with a generic name, as maybe, just
maybe, we could also change the other infras to also recognise those
variables.

To mimic this feature for packages that are built from the SDK, we also
install a templatised version of cross-compilation.conf, with three new
placeholders for custom flags. If a user wants to build a package that
needs custom flags, they can use that template to generate a per-package
cross-compilation.conf.

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

---
Changes v2 -> v3:
  - simplify the default clauses in the manual  (Thomas)
  - expand commit log with the first paragraph  (Thomas)
  - fix missing double-dollars in some places, bug introduced when
    adopted by Yann.

Changes v1 -> v2 (adopted by Yann):
  - rename the variables
  - don't add new placeholders in the bundled template; instead, insert
    those placeholders when generating the partially-templatised
    template (irk!).
  - update the doc
---
 docs/manual/adding-packages-meson.txt | 12 ++++++++++++
 package/meson/meson.mk                | 14 ++++++++++----
 package/pkg-meson.mk                  | 14 +++++++++++---
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/docs/manual/adding-packages-meson.txt b/docs/manual/adding-packages-meson.txt
index 30c338f486..8e2d448788 100644
--- a/docs/manual/adding-packages-meson.txt
+++ b/docs/manual/adding-packages-meson.txt
@@ -97,6 +97,18 @@ will therefore only use a few of them.
 * +FOO_CONF_OPTS+, to specify additional options to pass to +meson+ for the
   configuration step. By default, empty.
 
+* +FOO_CFLAGS+, to specify compiler arguments added to the package specific
+  +cross-compile.conf+ file +c_args+ property. By default, the value of
+  +TARGET_CFLAGS+.
+
+* +FOO_CXXFLAGS+, to specify compiler arguments added to the package specific
+  +cross-compile.conf+ file +cpp_args+ property. By default, the value of
+  +TARGET_CXXFLAGS+.
+
+* +FOO_LDFLAGS+, to specify compiler arguments added to the package specific
+  +cross-compile.conf+ file +c_link_args+ and +cpp_link_args+ properties. By
+  default, the value of +TARGET_LDFLAGS+.
+
 * +FOO_NINJA_ENV+, to specify additional environment variables to pass to
   +ninja+, meson companion tool in charge of the build operations. By default,
   empty.
diff --git a/package/meson/meson.mk b/package/meson/meson.mk
index 511be05a46..dffa301191 100644
--- a/package/meson/meson.mk
+++ b/package/meson/meson.mk
@@ -50,18 +50,24 @@ HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) '
 HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
 
 # Generate a Meson cross-compilation.conf suitable for use with the
-# SDK
+# SDK; also install the file as a template for users to add their
+# own flags if they need to.
 define HOST_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)%g" \
-	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
-	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%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" \
 	    $(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" \
+	    $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
 	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
 endef
 
diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
index 886fcf7205..0b811d1cc0 100644
--- a/package/pkg-meson.mk
+++ b/package/pkg-meson.mk
@@ -57,6 +57,14 @@ $(2)_NINJA_ENV		?=
 ifndef $(2)_CONFIGURE_CMDS
 ifeq ($(4),target)
 
+$(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
 #
 #
@@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
 	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
-	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
-	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
 	    package/meson/cross-compilation.conf.in \
 	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
-- 
2.20.1

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

* [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc
  2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
  2019-06-24 20:25 ` [Buildroot] [PATCH 1/4] package/meson: fix empty arguments in cross-compilation.conf Yann E. MORIN
  2019-06-24 20:25 ` [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags Yann E. MORIN
@ 2019-06-24 20:25 ` Yann E. MORIN
  2019-07-01  8:13   ` Arnout Vandecappelle
  2019-06-24 20:25 ` [Buildroot] [PATCH 4/4] package/libglib2: fix build on ARM in Thumb mode Yann E. MORIN
  2019-07-01  8:06 ` [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Arnout Vandecappelle
  4 siblings, 1 reply; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-24 20:25 UTC (permalink / raw)
  To: buildroot

libglib2 uses a very crude and error-prone way to detect the intl
functions, which basically fails when the C library is not glibc.

Now that a meson package can specify its LDFLAGS, use that to pass the
infrastructure-provided TARGET_NLS_LIBS to link with.

Fixes:
    http://autobuild.buildroot.org/results/f0d/f0d85d76786343d767fba9c7c5c01f042ecfc018/
    [...]

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>
Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>

---
Note: a few lines above, we do export LIBGLIB2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
but this does not work at all and was broken by the conversion over to
meson, and will need to be addressed by another patch.

---
Changes v2 -> v3:
  - rebased on master, with libglib2 2.60.4

Changes v1 -> v2:
  - rebased on master
---
 package/libglib2/libglib2.mk | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/package/libglib2/libglib2.mk b/package/libglib2/libglib2.mk
index 28a50f96a4..28f404b74a 100644
--- a/package/libglib2/libglib2.mk
+++ b/package/libglib2/libglib2.mk
@@ -12,6 +12,8 @@ LIBGLIB2_LICENSE = LGPL-2.1+
 LIBGLIB2_LICENSE_FILES = COPYING
 LIBGLIB2_INSTALL_STAGING = YES
 
+LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
+
 # glib/valgrind.h contains inline asm not compatible with thumb1
 ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
 LIBGLIB2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
-- 
2.20.1

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

* [Buildroot] [PATCH 4/4] package/libglib2: fix build on ARM in Thumb mode
  2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
                   ` (2 preceding siblings ...)
  2019-06-24 20:25 ` [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc Yann E. MORIN
@ 2019-06-24 20:25 ` Yann E. MORIN
  2019-07-01  8:06 ` [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Arnout Vandecappelle
  4 siblings, 0 replies; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-24 20:25 UTC (permalink / raw)
  To: buildroot

Commit 4102db0f7 (package/libglib2: bump to version 2.60.3) did convert
libglib2 over to meson. In doing so, it left a very corner-case along.

When the target is an ARM CPU and the build is in thumb mode, then we
want to ensure that libglib2 is still biuld in arm mode (because if
inline asm).

But with meson, CFLAGS from the environment are passed to the host
compiler, so the build breaks, and the meson log contains:

    Appending CFLAGS from environment: '-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os   -marm'
    No LDFLAGS in the environment, not changing global flags.
    No CPPFLAGS in the environment, not changing global flags.
    Sanity testing C compiler: cc
    Is cross compiler: False.
    Sanity check compiler command line: cc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -marm [...]/build/libglib2-2.60.4/build/meson-private/sanitycheckc.c -o [...]/build/libglib2-2.60.4/build/meson-private/sanitycheckc.exe
    Sanity check compile stdout:
    -----
    Sanity check compile stderr:
    cc: error: unrecognized command line option ?-marm?; did you mean ?-mabm??
    -----
    meson.build:1:0: ERROR: Compiler cc can not compile programs.

Fix that by using the new per-package CFLAGS feature of the meson infra.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Cc: Eric Le Bihan <eric.le.bihan.dev@free.fr>
Cc: Adam Duskett <aduskett@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 package/libglib2/libglib2.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/libglib2/libglib2.mk b/package/libglib2/libglib2.mk
index 28f404b74a..38941ca79d 100644
--- a/package/libglib2/libglib2.mk
+++ b/package/libglib2/libglib2.mk
@@ -12,11 +12,12 @@ LIBGLIB2_LICENSE = LGPL-2.1+
 LIBGLIB2_LICENSE_FILES = COPYING
 LIBGLIB2_INSTALL_STAGING = YES
 
+LIBGLIB2_CFLAGS = $(TARGET_CFLAGS)
 LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
 
 # glib/valgrind.h contains inline asm not compatible with thumb1
 ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
-LIBGLIB2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
+LIBGLIB2_CFLAGS += -marm
 endif
 
 HOST_LIBGLIB2_CONF_OPTS = \
-- 
2.20.1

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-24 20:25 ` [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags Yann E. MORIN
@ 2019-06-25 20:28   ` Peter Seiderer
  2019-06-30 16:12   ` Arnout Vandecappelle
  1 sibling, 0 replies; 12+ messages in thread
From: Peter Seiderer @ 2019-06-25 20:28 UTC (permalink / raw)
  To: buildroot

Hello Yann,

On Mon, 24 Jun 2019 22:25:48 +0200, "Yann E. MORIN" <yann.morin.1998@free.fr> wrote:

> From: Peter Seiderer <ps.report@gmx.net>
>
> Meson does not allow to pass CFLAGS/LDFLAGS/CXXFLAGS via the environment
> or via command-line arguments or options (instead, those flags from the
> environment are passed to the host compiler, which is seldom what we
> need). The only way to pas those flags is via the cross-compilation.conf
> file.
>
> Add LIBFOO_CFLAGS, LIBFOO_LDFLAGS and LIBFOO_CXXFLAGS variables to allow
> packages to provide their own flags, possibly overriding the generic
> ones entirely, as we allow for other infras. Those per-package flags will
> then be used to generate the per-package cross-compilation.conf.
>
> This means that the meson infra is the first and only infra for which
> FOO_CFLAGS, FOO_LDFLAGS, and FOO_CXXFLAGS are meaningful, while for the
> other infras, they are just variables private to the package itself.
> Instead of naming those variables after the meson infra (e.g.cc55205e417ab6616bb14a21bf403f901f742c0d
> FOO_MESON_CFLAGS), we name them with a generic name, as maybe, just
> maybe, we could also change the other infras to also recognise those
> variables.
>
> To mimic this feature for packages that are built from the SDK, we also
> install a templatised version of cross-compilation.conf, with three new
> placeholders for custom flags. If a user wants to build a package that
> needs custom flags, they can use that template to generate a per-package
> cross-compilation.conf.
>
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Adam Duskett <aduskett@gmail.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
>
> ---
> Changes v2 -> v3:
>   - simplify the default clauses in the manual  (Thomas)
>   - expand commit log with the first paragraph  (Thomas)
>   - fix missing double-dollars in some places, bug introduced when
>     adopted by Yann.
>
> Changes v1 -> v2 (adopted by Yann):
>   - rename the variables
>   - don't add new placeholders in the bundled template; instead, insertcc55205e417ab6616bb14a21bf403f901f742c0d
>     those placeholders when generating the partially-templatised
>     template (irk!).
>   - update the doc
> ---
>  docs/manual/adding-packages-meson.txt | 12 ++++++++++++
>  package/meson/meson.mk                | 14 ++++++++++----
>  package/pkg-meson.mk                  | 14 +++++++++++---
>  3 files changed, 33 insertions(+), 7 deletions(-)
>
> diff --git a/docs/manual/adding-packages-meson.txt b/docs/manual/adding-packages-meson.txt
> index 30c338f486..8e2d448788 100644
> --- a/docs/manual/adding-packages-meson.txt
> +++ b/docs/manual/adding-packages-meson.txt
> @@ -97,6 +97,18 @@ will therefore only use a few of them.
>  * +FOO_CONF_OPTS+, to specify additional options to pass to +meson+ for the
>    configuration step. By default, empty.
>
> +* +FOO_CFLAGS+, to specify compiler arguments added to the package specific
> +  +cross-compile.conf+ file +c_args+ property. By default, the value of
> +  +TARGET_CFLAGS+.
> +
> +* +FOO_CXXFLAGS+, to specify compiler arguments added to the package specific
> +  +cross-compile.conf+ file +cpp_args+ property. By default, the value of
> +  +TARGET_CXXFLAGS+.cc55205e417ab6616bb14a21bf403f901f742c0d
> +
> +* +FOO_LDFLAGS+, to specify compiler arguments added to the package specific
> +  +cross-compile.conf+ file +c_link_args+ and +cpp_link_args+ properties. By
> +  default, the value of +TARGET_LDFLAGS+.
> +
>  * +FOO_NINJA_ENV+, to specify additional environment variables to pass to
>    +ninja+, meson companion tool in charge of the build operations. By default,
>    empty.
> diff --git a/package/meson/meson.mk b/package/meson/meson.mk
> index 511be05a46..dffa301191 100644
> --- a/package/meson/meson.mk
> +++ b/package/meson/meson.mk
> @@ -50,18 +50,24 @@ HOST_MESON_SED_LDFLAGS = $(if $(strip $(TARGET_LDFLAGS)),`printf '"%s"$(comma) '
>  HOST_MESON_SED_CXXFLAGS = $(if $(strip $(TARGET_CXXFLAGS)),`printf '"%s"$(comma) ' $(TARGET_CXXFLAGS)`)
>
>  # Generate a Meson cross-compilation.conf suitable for use with the
> -# SDK
> +# SDK; also install the file as a template for users to add their
> +# own flags if they need to.
>  define HOST_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)%g" \
> -	    -e "s%@TARGET_LDFLAGS@%$(HOST_MESON_SED_LDFLAGS)%g" \
> -	    -e "s%@TARGET_CXXFLAGS@%$(HOST_MESON_SED_CXXFLAGS)%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" \
>  	    $(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" \
> +	    $(HOST_DIR)/etc/meson/cross-compilation.conf.in \
>  	    > $(HOST_DIR)/etc/meson/cross-compilation.conf
>  endef
>
> diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk
> index 886fcf7205..0b811d1cc0 100644
> --- a/package/pkg-meson.mk
> +++ b/package/pkg-meson.mk
> @@ -57,6 +57,14 @@ $(2)_NINJA_ENV		?=
>  ifndef $(2)_CONFIGURE_CMDS
>  ifeq ($(4),target)
>
> +$(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
>  #
>  #
> @@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
>  	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
> -	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
> -	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
>  	    package/meson/cross-compilation.conf.in \
>  	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf

Tested with the updated version of '[PATCH v7] libdrm: change to meson build system' ([1]), you can add my

Tested-by: Peter Seiderer <ps.report@gmx.net>

Regards,
Peter

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-24 20:25 ` [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags Yann E. MORIN
  2019-06-25 20:28   ` Peter Seiderer
@ 2019-06-30 16:12   ` Arnout Vandecappelle
  2019-06-30 16:32     ` Yann E. MORIN
  1 sibling, 1 reply; 12+ messages in thread
From: Arnout Vandecappelle @ 2019-06-30 16:12 UTC (permalink / raw)
  To: buildroot

 Hi Yann,

On 24/06/2019 22:25, Yann E. MORIN wrote:
[snip]
> +$(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)`)

 This is ridiculous - why not the much simpler make construct

	-e "s%@TARGET_CFLAGS@%$$(foreach flag,$$($(2)_CFLAGS),"$$(flag)"$(comma))%g" \

 Note that this would also fix the issue from patch 1. Obviously untested,
because that's just the kind of person I am :-). If it does need to be a little
bit complicated, then I'd still prefer it to be managed by a macro rather than
defining additional variables for each kind of flag. E.g. quoted-comma-list.

 Then again, this is the way it's already done in meson.mk, so why not. Maybe
something to fix in a follow-up patch.

 If you haven't sent a v2 that applies this technique by the next time I'm
applying stuff, I'll apply it as is.

 Regards,
 Arnout


> +
>  # Configure package for target
>  #
>  #
> @@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
>  	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
> -	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
> -	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
>  	    package/meson/cross-compilation.conf.in \
>  	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
> 

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-30 16:12   ` Arnout Vandecappelle
@ 2019-06-30 16:32     ` Yann E. MORIN
  2019-07-01  8:11       ` Arnout Vandecappelle
  2019-07-01  8:12       ` Arnout Vandecappelle
  0 siblings, 2 replies; 12+ messages in thread
From: Yann E. MORIN @ 2019-06-30 16:32 UTC (permalink / raw)
  To: buildroot

On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
>  Hi Yann,
> 
> On 24/06/2019 22:25, Yann E. MORIN wrote:
> [snip]
> > +$(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)`)
> 
>  This is ridiculous - why not the much simpler make construct

Look, I know I do a lot of crap, granted, but your often calling things
"ridiculous" or "bullshit" or other nasty qualifiers is starting to be
a little bit unnerving...

> 	-e "s%@TARGET_CFLAGS@%$$(foreach flag,$$($(2)_CFLAGS),"$$(flag)"$(comma))%g" \

Because it does not work as you think it works?

Consider the following:

    FOO_CFLAGS = -DMEH='foo bar' -DBLEH="buz baz"

I'll leave it up to you to think what it gives in either case...

>  Note that this would also fix the issue from patch 1. Obviously untested,
> because that's just the kind of person I am :-). If it does need to be a little
> bit complicated, then I'd still prefer it to be managed by a macro rather than
> defining additional variables for each kind of flag. E.g. quoted-comma-list.
> 
>  Then again, this is the way it's already done in meson.mk, so why not. Maybe
> something to fix in a follow-up patch.

Nope, there is nothing to fix.

If there were anything to fix, that would have been the commit log of
5cd8afbd, which failed to explain this pecularity.

>  If you haven't sent a v2 that applies this technique by the next time I'm
> applying stuff, I'll apply it as is.

I will definitely *not* send a v2.

Regards,
Yann E. MORIN.

>  Regards,
>  Arnout
> 
> 
> > +
> >  # Configure package for target
> >  #
> >  #
> > @@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
> >  	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
> > -	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
> > -	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
> >  	    package/meson/cross-compilation.conf.in \
> >  	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
> > 

-- 
.-----------------.--------------------.------------------.--------------------.
|  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] 12+ messages in thread

* [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags)
  2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
                   ` (3 preceding siblings ...)
  2019-06-24 20:25 ` [Buildroot] [PATCH 4/4] package/libglib2: fix build on ARM in Thumb mode Yann E. MORIN
@ 2019-07-01  8:06 ` Arnout Vandecappelle
  4 siblings, 0 replies; 12+ messages in thread
From: Arnout Vandecappelle @ 2019-07-01  8:06 UTC (permalink / raw)
  To: buildroot



On 24/06/2019 22:25, Yann E. MORIN wrote:
> Hello All!
> 
> With meson, it is impossible to pass extra CFLAGS or override them
> entirely from the command line (i.e. neither in the environment nor as
> command line arguments). Worse, if we were to do so, they would be
> passed to the host compiler, not the target compiler.
> 
> This series adds two changes to the meson infrastructure:
>   - a fix for when the *FLAGS variables are empty ut with spaces,
>   - the ability for packages to pass their own *FLAGS if they need to.
> 
> Finally, two changes are done in libglib2, that take advantage of this
> new feature:
>   - fix the build when the external gettext provides the i18n functions,
>   - fix the build on ARM in Thumb mode.
> 
> Thanks to Peter S. for the initial infra patch, thanks to Thomas for a
> previous review, and thanks to Adam for investigting a bug that led to
> the first patch and parts of the second patch, as well as proof-reading
> my crappy commit logs; any leftover typo is entirely his fault, now!
> Muahaha! ;-]
> 
> 
> Regards,
> Yann E. MORIN.

 Series applied to master, thanks!

 Regards,
 Arnout

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-30 16:32     ` Yann E. MORIN
@ 2019-07-01  8:11       ` Arnout Vandecappelle
  2019-07-01  8:12       ` Arnout Vandecappelle
  1 sibling, 0 replies; 12+ messages in thread
From: Arnout Vandecappelle @ 2019-07-01  8:11 UTC (permalink / raw)
  To: buildroot

 Hi Yann

On 30/06/2019 18:32, Yann E. MORIN wrote:
> On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
>>  Hi Yann,
>>
>> On 24/06/2019 22:25, Yann E. MORIN wrote:
>> [snip]
>>> +$(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)`)
>>
>>  This is ridiculous - why not the much simpler make construct
> 
> Look, I know I do a lot of crap, granted, but your often calling things
> "ridiculous" or "bullshit" or other nasty qualifiers is starting to be
> a little bit unnerving...

 You're absolutely right. I'm really sorry. I'll try to be less aggressive in
the future.

 Thanks for pointing this out to me.



>> 	-e "s%@TARGET_CFLAGS@%$$(foreach flag,$$($(2)_CFLAGS),"$$(flag)"$(comma))%g" \
> 
> Because it does not work as you think it works?
> 
> Consider the following:
> 
>     FOO_CFLAGS = -DMEH='foo bar' -DBLEH="buz baz"
> 
> I'll leave it up to you to think what it gives in either case...

 That could be handled by using $(space) in the definition of FOO_CFLAGS, but
that would look very bad. Indeed, it should be the infra that takes care of
complexities like that.


>>  Note that this would also fix the issue from patch 1. Obviously untested,
>> because that's just the kind of person I am :-). If it does need to be a little
>> bit complicated, then I'd still prefer it to be managed by a macro rather than
>> defining additional variables for each kind of flag. E.g. quoted-comma-list.

 I still stand by this statement: it could move to a macro.


>>  Then again, this is the way it's already done in meson.mk, so why not. Maybe
>> something to fix in a follow-up patch.
> 
> Nope, there is nothing to fix.
> 
> If there were anything to fix, that would have been the commit log of
> 5cd8afbd, which failed to explain this pecularity.

 Good point. I've added a paragraph to this commit's log that summarizes the issue.


 Regards,
 Arnout

> 
>>  If you haven't sent a v2 that applies this technique by the next time I'm
>> applying stuff, I'll apply it as is.
> 
> I will definitely *not* send a v2.
> 
> Regards,
> Yann E. MORIN.
> 
>>  Regards,
>>  Arnout
>>
>>
>>> +
>>>  # Configure package for target
>>>  #
>>>  #
>>> @@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
>>>  	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
>>> -	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
>>> -	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
>>>  	    package/meson/cross-compilation.conf.in \
>>>  	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
>>>
> 

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

* [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags
  2019-06-30 16:32     ` Yann E. MORIN
  2019-07-01  8:11       ` Arnout Vandecappelle
@ 2019-07-01  8:12       ` Arnout Vandecappelle
  1 sibling, 0 replies; 12+ messages in thread
From: Arnout Vandecappelle @ 2019-07-01  8:12 UTC (permalink / raw)
  To: buildroot

 Hi Yann

On 30/06/2019 18:32, Yann E. MORIN wrote:
> On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
>>  Hi Yann,
>>
>> On 24/06/2019 22:25, Yann E. MORIN wrote:
>> [snip]
>>> +$(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)`)
>>
>>  This is ridiculous - why not the much simpler make construct
> 
> Look, I know I do a lot of crap, granted, but your often calling things
> "ridiculous" or "bullshit" or other nasty qualifiers is starting to be
> a little bit unnerving...

 You're absolutely right. I'm really sorry. I'll try to be less aggressive in
the future.

 Thanks for pointing this out to me.



>> 	-e "s%@TARGET_CFLAGS@%$$(foreach flag,$$($(2)_CFLAGS),"$$(flag)"$(comma))%g" \
> 
> Because it does not work as you think it works?
> 
> Consider the following:
> 
>     FOO_CFLAGS = -DMEH='foo bar' -DBLEH="buz baz"
> 
> I'll leave it up to you to think what it gives in either case...

 That could be handled by using $(space) in the definition of FOO_CFLAGS, but
that would look very bad. Indeed, it should be the infra that takes care of
complexities like that.


>>  Note that this would also fix the issue from patch 1. Obviously untested,
>> because that's just the kind of person I am :-). If it does need to be a little
>> bit complicated, then I'd still prefer it to be managed by a macro rather than
>> defining additional variables for each kind of flag. E.g. quoted-comma-list.

 I still stand by this statement: it could move to a macro.


>>  Then again, this is the way it's already done in meson.mk, so why not. Maybe
>> something to fix in a follow-up patch.
> 
> Nope, there is nothing to fix.
> 
> If there were anything to fix, that would have been the commit log of
> 5cd8afbd, which failed to explain this pecularity.

 Good point. I've added a paragraph to this commit's log that summarizes the issue.


 Regards,
 Arnout

> 
>>  If you haven't sent a v2 that applies this technique by the next time I'm
>> applying stuff, I'll apply it as is.
> 
> I will definitely *not* send a v2.
> 
> Regards,
> Yann E. MORIN.
> 
>>  Regards,
>>  Arnout
>>
>>
>>> +
>>>  # Configure package for target
>>>  #
>>>  #
>>> @@ -67,9 +75,9 @@ define $(2)_CONFIGURE_CMDS
>>>  	    -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@%$$(HOST_MESON_SED_CFLAGS)%g" \
>>> -	    -e "s%@TARGET_LDFLAGS@%$$(HOST_MESON_SED_LDFLAGS)%g" \
>>> -	    -e "s%@TARGET_CXXFLAGS@%$$(HOST_MESON_SED_CXXFLAGS)%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" \
>>>  	    package/meson/cross-compilation.conf.in \
>>>  	    > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
>>>
> 

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

* [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc
  2019-06-24 20:25 ` [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc Yann E. MORIN
@ 2019-07-01  8:13   ` Arnout Vandecappelle
  0 siblings, 0 replies; 12+ messages in thread
From: Arnout Vandecappelle @ 2019-07-01  8:13 UTC (permalink / raw)
  To: buildroot



On 24/06/2019 22:25, Yann E. MORIN wrote:
> libglib2 uses a very crude and error-prone way to detect the intl
> functions, which basically fails when the C library is not glibc.

 I've added a reference here to the upstream meson bug report [1], so we might
remember to remove this workaround once meson is fixed.

 Regards,
 Arnout

[1] https://github.com/mesonbuild/meson/issues/3740

> 
> Now that a meson package can specify its LDFLAGS, use that to pass the
> infrastructure-provided TARGET_NLS_LIBS to link with.
> 
> Fixes:
>     http://autobuild.buildroot.org/results/f0d/f0d85d76786343d767fba9c7c5c01f042ecfc018/
>     [...]
> 
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> Cc: Adam Duskett <aduskett@gmail.com>
> Cc: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> 
> ---
> Note: a few lines above, we do export LIBGLIB2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
> but this does not work at all and was broken by the conversion over to
> meson, and will need to be addressed by another patch.
> 
> ---
> Changes v2 -> v3:
>   - rebased on master, with libglib2 2.60.4
> 
> Changes v1 -> v2:
>   - rebased on master
> ---
>  package/libglib2/libglib2.mk | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/package/libglib2/libglib2.mk b/package/libglib2/libglib2.mk
> index 28a50f96a4..28f404b74a 100644
> --- a/package/libglib2/libglib2.mk
> +++ b/package/libglib2/libglib2.mk
> @@ -12,6 +12,8 @@ LIBGLIB2_LICENSE = LGPL-2.1+
>  LIBGLIB2_LICENSE_FILES = COPYING
>  LIBGLIB2_INSTALL_STAGING = YES
>  
> +LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
> +
>  # glib/valgrind.h contains inline asm not compatible with thumb1
>  ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
>  LIBGLIB2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -marm"
> 

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

end of thread, other threads:[~2019-07-01  8:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-24 20:25 [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) Yann E. MORIN
2019-06-24 20:25 ` [Buildroot] [PATCH 1/4] package/meson: fix empty arguments in cross-compilation.conf Yann E. MORIN
2019-06-24 20:25 ` [Buildroot] [PATCH 2/4] infra/pkg-meson: allow packages to pass custom compiler/linker flags Yann E. MORIN
2019-06-25 20:28   ` Peter Seiderer
2019-06-30 16:12   ` Arnout Vandecappelle
2019-06-30 16:32     ` Yann E. MORIN
2019-07-01  8:11       ` Arnout Vandecappelle
2019-07-01  8:12       ` Arnout Vandecappelle
2019-06-24 20:25 ` [Buildroot] [PATCH 3/4] package/libglib2: fix NLS build on musl and uclibc Yann E. MORIN
2019-07-01  8:13   ` Arnout Vandecappelle
2019-06-24 20:25 ` [Buildroot] [PATCH 4/4] package/libglib2: fix build on ARM in Thumb mode Yann E. MORIN
2019-07-01  8:06 ` [Buildroot] [PATCH 0/4] libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags) 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.