Skip to contentSkip to conversation

package/libglib2: fix build with NLS on musl/uclibc (branch yem/meson-per-pkg-flags)

PATCH New Yann E. MORIN 3 participants 7 messages Jun 11, 2019 – Jun 12, 2019 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

cover package/libglib2: fix build with NLS on musl/uclibc (branch yem/meson-per-pkg-flags)

Hello All!

Under musl or uclibc, we need -lintl when NLS is enabled.

Regards,
Yann E. MORIN.

The following changes since commit 04efb17c863606cdbc2405d01c3d48d6868c5245

package/vlc: bump version to 3.0.7 (2019-06-11 00:54:16 +0200)

are available in the git repository at:

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

for you to fetch changes up to 348952c2f966fb8c1ccb5b18418b3a8596925645

package/libglib2: fix NLS build on musl and uclibc (2019-06-11 22:52:30 +0200)

----------------------------------------------------------------
Yann E. MORIN (2):
infra/pkg-meson: allow packages to expand their CFLAGS/CXXFLAGS/LDFLAGS package/libglib2: fix NLS build on musl and uclibc

 package/libglib2/libglib2.mk |  2 ++
 package/pkg-meson.mk         | 10 +++++++---
 2 files changed, 9 insertions(+), 3 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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 1/2 infra/pkg-meson: allow packages to expand their CFLAGS/CXXFLAGS/LDFLAGS

Some packages will want to pass extra CFLAGS, CXXFLAGS, or LDFLAGS. For example, they may want/have to pass $(TARGET_NLS_LIBS), like libglib2 when the toolchain is based on musl or uClibc (because meson does not have all the necessary infra internally to properly and reliably detect the presence of, or need for linking with, -lintl.

Cc Adam Duskett <[email protected]>
Cc Eric Le Bihan <[email protected]>
---
 package/pkg-meson.mk | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
package/pkg-meson.mk +7 -3
index 886fcf7205..8512a3559d 100644
@@ -49,6 +49,10 @@ $(2)_CONF_ENV		?=
 $(2)_CONF_OPTS		?=
 $(2)_NINJA_ENV		?=
 
+$(2)_CFLAGS ?= $$(TARGET_CFLAGS)
+$(2)_LDFLAGS ?= $$(TARGET_LDFLAGS)
+$(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
+
 #
 # Configure step. Only define it if not already defined by the package
 # .mk file. And take care of the differences between host and target
@@ -67,9 +71,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@%$$(if $$($(2)_CFLAGS),`printf '"%s"$$(comma) ' $$($(2)_CFLAGS)`)%g" \
+	    -e "s%@TARGET_LDFLAGS@%$$(if $$($(2)_LDFLAGS),`printf '"%s"$$(comma) ' $$($(2)_LDFLAGS)`)%g" \
+	    -e "s%@TARGET_CXXFLAGS@%$$(if $$($(2)_CXXFLAGS),`printf '"%s"$$(comma) ' $$($(2)_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
#2 lore raw

PATCH 1/2 infra/pkg-meson: allow packages to expand their CFLAGS/CXXFLAGS/LDFLAGS

Quoted 45 lines · Yann E. MORIN

Some packages will want to pass extra CFLAGS, CXXFLAGS, or LDFLAGS. For example, they may want/have to pass $(TARGET_NLS_LIBS), like libglib2 when the toolchain is based on musl or uClibc (because meson does not have all the necessary infra internally to properly and reliably detect the presence of, or need for linking with, -lintl.

Cc Adam Duskett <[email protected]>
Cc Eric Le Bihan <[email protected]>
---
 package/pkg-meson.mk | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
package/pkg-meson.mk +7 -4
index 886fcf7205..8512a3559d 100644
@@ -49,6 +49,10 @@ $(2)_CONF_ENV                ?=
 $(2)_CONF_OPTS         ?=
 $(2)_NINJA_ENV         ?=
 
+$(2)_CFLAGS ?= $$(TARGET_CFLAGS)
+$(2)_LDFLAGS ?= $$(TARGET_LDFLAGS)
+$(2)_CXXFLAGS ?= $$(TARGET_CXXFLAGS)
+
 #
 # Configure step. Only define it if not already defined by the package
 # .mk file. And take care of the differences between host and target
@@ -67,9 +71,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@%$$(if $$($(2)_CFLAGS),`printf '"%s"$$(comma) ' $$($(2)_CFLAGS)`)%g" \
+           -e "s%@TARGET_LDFLAGS@%$$(if $$($(2)_LDFLAGS),`printf '"%s"$$(comma) ' $$($(2)_LDFLAGS)`)%g" \
+           -e "s%@TARGET_CXXFLAGS@%$$(if $$($(2)_CXXFLAGS),`printf '"%s"$$(comma) ' $$($(2)_CXXFLAGS)`)%g" \
            -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \
            package/meson/cross-compilation.conf.in \
            > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf
--

2.20.1

#3 lore raw

PATCH 1/2 infra/pkg-meson: allow packages to expand their CFLAGS/CXXFLAGS/LDFLAGS

In reply to Yann E. MORIN
Quoted 9 lines · On Tue, 11 Jun 2019 22:55:43 +0200 "Yann E. MORIN" <[email protected]>…

Some packages will want to pass extra CFLAGS, CXXFLAGS, or LDFLAGS. For example, they may want/have to pass $(TARGET_NLS_LIBS), like libglib2 when the toolchain is based on musl or uClibc (because meson does not have all the necessary infra internally to properly and reliably detect the presence of, or need for linking with, -lintl.

Cc Adam Duskett <[email protected]>
Cc Eric Le Bihan <[email protected]>

This looks highly similar to
http://patchwork.ozlabs.org/patch/1089760/, which seems more complete.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/2 infra/pkg-meson: allow packages to expand their CFLAGS/CXXFLAGS/LDFLAGS

Thomas, All,

On 2019-06-11 23:00 +0200, Thomas Petazzoni spake thusly:

Quoted 8 lines
Quoted 6 lines · On Tue, 11 Jun 2019 22:55:43 +0200 "Yann E. MORIN" <[email protected]>…

Some packages will want to pass extra CFLAGS, CXXFLAGS, or LDFLAGS. For example, they may want/have to pass $(TARGET_NLS_LIBS), like libglib2 when the toolchain is based on musl or uClibc (because meson does not have all the necessary infra internally to properly and reliably detect the presence of, or need for linking with, -lintl.

Quoted 6 lines
Quoted 3 lines
Cc Adam Duskett <[email protected]>
Cc Eric Le Bihan <[email protected]>

This looks highly similar to
http://patchwork.ozlabs.org/patch/1089760/, which seems more complete.

Hmm. It indeed looks to achieve the same goal, I'll look into it in more details shortly.

Regards,
Yann E. MORIN.

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.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 2/2 package/libglib2: fix NLS build on musl and uclibc

In reply to 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.

Now that a meson pacakge 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/
    [...]
Cc Adam Duskett <[email protected]>
Cc Fabrice Fontaine <[email protected]>
---
 package/libglib2/libglib2.mk | 2 ++
 1 file changed, 2 insertions(+)
package/libglib2/libglib2.mk +2 -0
index 78d6e5ab32..04f747cec7 100644
@@ -31,6 +31,8 @@ LIBGLIB2_DEPENDENCIES = \
 	host-pkgconf host-libglib2 \
 	libffi pcre util-linux zlib $(TARGET_NLS_DEPENDENCIES)
 
+LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
+
 HOST_LIBGLIB2_DEPENDENCIES = \
 	host-gettext \
 	host-libffi \
Signature · 1 line
2.20.1
#6 lore raw

PATCH 2/2 package/libglib2: fix NLS build on musl and uclibc

All;

Quoted 34 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.

Now that a meson pacakge 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/
    [...]
Cc Adam Duskett <[email protected]>
Cc Fabrice Fontaine <[email protected]>
---
 package/libglib2/libglib2.mk | 2 ++
 1 file changed, 2 insertions(+)
package/libglib2/libglib2.mk +2 -1
index 78d6e5ab32..04f747cec7 100644
@@ -31,6 +31,8 @@ LIBGLIB2_DEPENDENCIES = \
        host-pkgconf host-libglib2 \
        libffi pcre util-linux zlib $(TARGET_NLS_DEPENDENCIES)
 
+LIBGLIB2_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
+
 HOST_LIBGLIB2_DEPENDENCIES = \
        host-gettext \
        host-libffi \
--

2.20.1