libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags)
cover libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags)
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(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/4 package/meson: fix empty arguments in cross-compilation.conf
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!
--- package/meson/meson.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
package/meson/meson.mk +3 -3
@@ -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
Signature · 1 line
2.20.1
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
In reply to Yann E. MORINFrom: Peter Seiderer <[email protected]>
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.
---
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(-)
docs/manual/adding-packages-meson.txt +12 -0
@@ -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.
package/meson/meson.mk +10 -4
@@ -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
package/pkg-meson.mk +11 -3
@@ -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
Signature · 1 line
2.20.1
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
Hello Yann,
Quoted 129 lines · Yann E. MORIN
From: Peter Seiderer <[email protected]>
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_LDFLAGSandLIBFOO_CXXFLAGSvariables 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, andFOO_CXXFLAGSare 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.cc55205e417ab6616bb14a21bf403f901f742c0dFOO_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 <[email protected]>Signed-off-by Yann E. MORIN <[email protected]>Cc Adam Duskett <[email protected]>Cc Thomas Petazzoni <[email protected]>---
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(-)docs/manual/adding-packages-meson.txt +12
-0@@ -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.package/meson/meson.mk +10
-4@@ -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 endefpackage/pkg-meson.mk +8
-0@@ -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" \
package/pkg-meson.mk define $(2)_CONFIGURE_CMDS · line 83
Quoted 10 lines
package/pkg-meson.mk +3
-3-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
Regards,
Peter
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
In reply to Yann E. MORINHi Yann,
On 24/06/2019 22:25, Yann E. MORIN wrote:
[snip]
Quoted 3 lines
+$(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
Quoted 18 lines
package/pkg-meson.mk +4
-3+ # 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
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
Quoted 9 lines
Hi Yann,
On 24/06/2019 22:25, Yann E. MORIN wrote:
[snip]Quoted 3 lines
+$(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...
Quoted 1 line
-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...
Quoted 7 lines
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.
Quoted 2 lines
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.
Quoted 22 lines
Regards,
ArnoutQuoted 18 lines
package/pkg-meson.mk +4
-3+ # 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
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | 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. | '------------------------------^-------^------------------^--------------------'
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
Hi Yann
Quoted 9 lines · Yann E. MORIN
On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
Quoted 8 lines
Hi Yann,
On 24/06/2019 22:25, Yann E. MORIN wrote:
[snip]Quoted 3 lines
+$(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))
Quoted 5 lines
Quoted 1 line
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.
Quoted 9 lines
Quoted 1 line
-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.
Quoted 4 lines
Quoted 4 lines
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.
Quoted 7 lines
Quoted 2 lines
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
Quoted 32 lines
Quoted 3 lines
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.Quoted 22 lines
Regards,
ArnoutQuoted 18 lines
package/pkg-meson.mk +4
-3+ # 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
PATCH 2/4 infra/pkg-meson: allow packages to pass custom compiler/linker flags
In reply to Yann E. MORINHi Yann
Quoted 9 lines · Yann E. MORIN
On 2019-06-30 18:12 +0200, Arnout Vandecappelle spake thusly:
Quoted 8 lines
Hi Yann,
On 24/06/2019 22:25, Yann E. MORIN wrote:
[snip]Quoted 3 lines
+$(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))
Quoted 5 lines
Quoted 1 line
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.
Quoted 9 lines
Quoted 1 line
-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.
Quoted 4 lines
Quoted 4 lines
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.
Quoted 7 lines
Quoted 2 lines
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
Quoted 32 lines
Quoted 3 lines
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.Quoted 22 lines
Regards,
ArnoutQuoted 18 lines
package/pkg-meson.mk +4
-3+ # 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
PATCH 3/4 package/libglib2: fix NLS build on musl and uclibc
In reply to Yann E. MORINlibglib2 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/ [...]
---
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(+)
package/libglib2/libglib2.mk +2 -0
@@ -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"
Signature · 1 line
2.20.1
PATCH 3/4 package/libglib2: fix NLS build on musl and uclibc
Quoted 2 lines · Yann E. MORIN
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
Quoted 41 lines
Now that a meson package can specify its LDFLAGS, use that to pass the infrastructure-provided
TARGET_NLS_LIBSto link with.Fixes:
http://autobuild.buildroot.org/results/f0d/f0d85d76786343d767fba9c7c5c01f042ecfc018/ [...]Signed-off-by Yann E. MORIN <[email protected]>Cc Adam Duskett <[email protected]>Cc Fabrice Fontaine <[email protected]>---
Note: a few lines above, we do exportLIBGLIB2_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.4Changes v1 -> v2:
- rebased on master--- package/libglib2/libglib2.mk | 2 ++ 1 file changed, 2 insertions(+)package/libglib2/libglib2.mk +2
-0@@ -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"
PATCH 4/4 package/libglib2: fix build on ARM in Thumb mode
In reply to Yann E. MORINCommit 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.
--- package/libglib2/libglib2.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
package/libglib2/libglib2.mk +2 -1
@@ -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 = \
Signature · 1 line
2.20.1
cover libglib: fix build with NLS or in Thumb mode (branch yem/meson-per-pkg-flags)
In reply to Yann E. MORINQuoted 23 lines · Yann E. MORIN
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! ;-]
Quoted 2 lines
Regards,
Yann E. MORIN.
Series applied to master, thanks!
Regards,
Arnout