Skip to contentSkip to conversation

package/gobject-introspection: fix host-linking

PATCH Superseded aduskett at gmail.com 2 participants 10 messages Mar 12, 2020 – Mar 15, 2020 Arm/Amlogic Meson SoC support

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 package/gobject-introspection: fix host-linking

From: Adam Duskett <[email protected]>

When building, gobject-introspection uses g-ir-scanner to build several .gir files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in order to ensure that g-ir-scanner does not use the host library path.

This fix has the added benefit of allowing the host gobject-introspection to build the host .gir, .rnc, and .typelib files, which some packages may require.

---
Changes v1 -> v3:
- Update comment to be more clear.

Changes v3 -> v4:
- Update patch to work with gobject-introspection 2.64.0

 package/gobject-introspection/gobject-introspection.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
package/gobject-introspection/gobject-introspection.mk +5 -5
index c18a1f17d3..9043390857 100644
@@ -33,11 +33,11 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
 GOBJECT_INTROSPECTION_NINJA_ENV += \
 	CC="$(TARGET_CC)"
 
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-	-Dbuild_introspection_data=false
+# When building, gobject-introspection uses g-ir-scanner to build several .gir
+# files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in
+# order to ensure that g-ir-scanner does not use the host library path.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+	LD_LIBRARY_PATH="$(HOST_DIR)/lib"
 
 # Use the host gi-scanner to prevent the scanner from generating incorrect
 # elf classes.
Signature · 1 line
2.24.1
#1 lore raw

PATCH v4 2/3 package/gobject-introspection: export cc in g-ir-scanner

From: Adam Duskett <[email protected]>

Without this export, the host variant of g-ir-scanner will call the host gcc for linking.

For autotools packages, this is not an issue as they use Makefile.introspection, which will export the cross-cc, however for meson, this is not the case, and linking errors occur when meson packages generate .gir and .typelib files.

---
Changes v1 -> v3:
- Use relative paths. (Yann)

 package/gobject-introspection/g-ir-scanner.in          | 2 ++
 package/gobject-introspection/gobject-introspection.mk | 2 ++
 2 files changed, 4 insertions(+)
package/gobject-introspection/g-ir-scanner.in +2 -0
index 9f97497b7e..d5847ad063 100644
@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 
 export GI_SCANNER_DISABLE_CACHE=1
+export CC="$(dirname "${0}")/../../../../bin/@BASENAME_TARGET_CC@"
+
 ${HOST_DIR}/bin/g-ir-scanner \
 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
package/gobject-introspection/gobject-introspection.mk +2 -0
index 9043390857..a508957904 100644
@@ -104,6 +104,8 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
 		$(INSTALL) -D -m 755 \
 			$(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
 	)
+	$(SED) "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" $(STAGING_DIR)/usr/bin/g-ir-scanner
+
 	# Gobject-introspection installs Makefile.introspection in
 	# $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
 	# build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
Signature · 1 line
2.24.1
#2 lore raw

PATCH v4 2/3 package/gobject-introspection: export cc in g-ir-scanner

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 24 lines

From: Adam Duskett <[email protected]>

Without this export, the host variant of g-ir-scanner will call the host gcc for linking.

For autotools packages, this is not an issue as they use Makefile.introspection, which will export the cross-cc, however for meson, this is not the case, and linking errors occur when meson packages generate .gir and .typelib files.

---
Changes v1 -> v3:
- Use relative paths. (Yann)

 package/gobject-introspection/g-ir-scanner.in          | 2 ++
 package/gobject-introspection/gobject-introspection.mk | 2 ++
 2 files changed, 4 insertions(+)
package/gobject-introspection/g-ir-scanner.in +0 -0
index 9f97497b7e..d5847ad063 100644

package/gobject-introspection/g-ir-scanner.in line 5

Quoted 5 lines
package/gobject-introspection/g-ir-scanner.in +2 -0
@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 
 export GI_SCANNER_DISABLE_CACHE=1
+export CC="$(dirname "${0}")/../../../../bin/@BASENAME_TARGET_CC@"
+

HHhmmm. I remember that I said I wanted the wrapper to still be rrrelocatable. But it is in staging (sysroot) while the compiler is in host dir, so you added that many .././/.. needed to got from there to there.

But look at the line below: we already have HOST_DIR:

package/gobject-introspection/g-ir-scanner.in line 6

Quoted 1 line
package/gobject-introspection/g-ir-scanner.in +0 -0
 ${HOST_DIR}/bin/g-ir-scanner \

^^^^^^^^^^^

So, just:

    export CC="${HOSTTT_DIR}/bin/@BASENAME_TARGET_CC@"

Or did we miss something?

Regards,
Yann E. MORIN.

Quoted 22 lines
package/gobject-introspection/g-ir-scanner.in +0 -0
 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
package/gobject-introspection/gobject-introspection.mk +2 -0
index 9043390857..a508957904 100644
@@ -104,6 +104,8 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
 		$(INSTALL) -D -m 755 \
 			$(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
 	)
+	$(SED) "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" $(STAGING_DIR)/usr/bin/g-ir-scanner
+
 	# Gobject-introspection installs Makefile.introspection in
 	# $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
 	# build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
Signature · 6 lines
2.24.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
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.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v4 2/3 package/gobject-introspection: export cc in g-ir-scanner

Yann;

Quoted 41 lines · Yann E. MORIN

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 24 lines

From: Adam Duskett <[email protected]>

Without this export, the host variant of g-ir-scanner will call the host gcc for linking.

For autotools packages, this is not an issue as they use Makefile.introspection, which will export the cross-cc, however for meson, this is not the case, and linking errors occur when meson packages generate .gir and .typelib files.

---
Changes v1 -> v3:
- Use relative paths. (Yann)

 package/gobject-introspection/g-ir-scanner.in          | 2 ++
 package/gobject-introspection/gobject-introspection.mk | 2 ++
 2 files changed, 4 insertions(+)
package/gobject-introspection/g-ir-scanner.in +0 -0
index 9f97497b7e..d5847ad063 100644

package/gobject-introspection/g-ir-scanner.in line 5

Quoted 5 lines
package/gobject-introspection/g-ir-scanner.in +2 -0
@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 
 export GI_SCANNER_DISABLE_CACHE=1
+export CC="$(dirname "${0}")/../../../../bin/@BASENAME_TARGET_CC@"
+

HHhmmm. I remember that I said I wanted the wrapper to still be relocatable. But it is in staging (sysroot) while the compiler is in host dir, so you added that many .././/.. needed to got from there to there.

But look at the line below: we already have HOST_DIR:

Quoted 8 lines

package/gobject-introspection/g-ir-scanner.in line 6

Quoted 1 line
package/gobject-introspection/g-ir-scanner.in +0 -0
 ${HOST_DIR}/bin/g-ir-scanner \

^^^^^^^^^^^

So, just:

    export CC="${HOST_DIR}/bin/@BASENAME_TARGET_CC@"

Or did we miss something?

That's what I had originally and you said to change it to this! Make up your mind! These patches take 2 - 3 weeks each to be reviewed and it is fairly annoying when a request for a change comes through, I make that change quickly, the changes sit for several weeks, and then a new request to revert
the change that was originally requested comes in.

I will remake the patch with
HOST_DIR again.

Adam

Quoted 34 lines

Regards,
Yann E. MORIN.

Quoted 18 lines
package/gobject-introspection/g-ir-scanner.in +0 -0
 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
package/gobject-introspection/gobject-introspection.mk +2 -1
index 9043390857..a508957904 100644
@@ -104,6 +104,8 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
              $(INSTALL) -D -m 755 \
                      $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
      )
+     $(SED) "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" $(STAGING_DIR)/usr/bin/g-ir-scanner
+
      # Gobject-introspection installs Makefile.introspection in
      # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
      # build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
--

2.24.1

Quoted 4 lines

_______________________________________________
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.  |

'------------------------------^-------^------------------^--------------------'

#4 lore raw

PATCH v4 2/3 package/gobject-introspection: export cc in g-ir-scanner

Adam, ll,

On 2020-03-14 17:40 -0700, Adam Duskett spake thusly:

Quoted 5 lines · Yann E. MORIN
Quoted 4 lines

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 3 lines

From: Adam Duskett <[email protected]>
Without this export, the host variant of g-ir-scanner will call the host gcc for linking.

[--SNIP--]

Quoted 11 lines
Quoted 11 lines
Quoted 1 line

+export CC="$(dirname "${0}")/../../../../bin/@BASENAME_TARGET_CC@"

HHhmmm. I remember that I said I wanted the wrapper to still be relocatable. But it is in staging (sysroot) while the compiler is in host dir, so you added that many .././/.. needed to got from there to there.

But look at the line below: we already have HOST_DIR:

Quoted 1 line

${HOST_DIR}/bin/g-ir-scanner \

^^^^^^^^^^^

Quoted 7 lines
Quoted 5 lines

So, just:

    export CC="${HOST_DIR}/bin/@BASENAME_TARGET_CC@"

Or did we miss something?

That's what I had originally and you said to change it to this!

That's not exactly what you did, which was:

export CC=@TARGET_CC@

and:

    $(SED) "s%@TARGET_CC@%$(TARGET_CC)%g" $(STAGING_DIR)/usr/bin/g-ir-scanner

So, even if it would use the same path, it is not semantically equivalent.

Quoted 5 lines

Make up your mind! These patches take 2 - 3 weeks each to be reviewed and it is fairly annoying when a request for a change comes through, I make that change quickly, the changes sit for several weeks, and then a new request to revert
the change that was originally requested comes in.

Sorry, but as you know well, this is a volunteer effort, and there is always so much time available, and so many patches pending.

I agree that it can be frustrating, yes. I've been there too. We've all been there...

But please, be sure that your work is very welcome. It's just that the goi is so baly borked by design that it makes the topic so complex.

And when applying something, I like to at least have the impression that I do understand the problkem and that the fix, how ugly it is, is indeed the only solution.

Quoted 2 lines

I will remake the patch with
HOST_DIR again.

Thank you for staying on board! :-)

Regards,
Yann E. MORIN.

Quoted 35 lines

Adam

Quoted 34 lines

Regards,
Yann E. MORIN.

Quoted 18 lines

--lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
--use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \

package/gobject-introspection/gobject-introspection.mk +2 -1
index 9043390857..a508957904 100644
@@ -104,6 +104,8 @@ define GOBJECT_INTROSPECTION_INSTALL_WRAPPERS
              $(INSTALL) -D -m 755 \
                      $(GOBJECT_INTROSPECTION_PKGDIR)/$(w).in $(STAGING_DIR)/usr/bin/$(w)
      )
+     $(SED) "s%@BASENAME_TARGET_CC@%$(notdir $(TARGET_CC))%g" $(STAGING_DIR)/usr/bin/g-ir-scanner
+
      # Gobject-introspection installs Makefile.introspection in
      # $(STAGING_DIR)/usr/share which is needed for autotools-based programs to
      # build .gir and .typelib files. Unfortuantly, gobject-introspection-1.0.pc
--

2.24.1

Quoted 4 lines

_______________________________________________
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.  |

'------------------------------^-------^------------------^--------------------'

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 v4 3/3 package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

In reply to aduskett at gmail.com

From: Adam Duskett <[email protected]>

Currently, meson hard codes the paths of these binaries which results in cross-compiled environments to run the host versions of these tools. However, GObject-introspection provides the appropriate paths to these utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If g-ir-scanner or g-ir-compiler are in the build or source directory use those. If they aren't found in the source directory, use the results from pkg-config.

Current upstream-status: merged
https://github.com/mesonbuild/meson/pull/6687
https://github.com/mesonbuild/meson/pull/6696

---
Changes v1 -> v3:
- Use an upstream patch that fixes this issue permanently.

 ...canner-and-g-ir-compiler-paths-from-.patch | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +68 -0
new file mode 100644
index 0000000000..4f765e2157
@@ -0,0 +1,68 @@
+From e8c2c21aabb4a06915b2e3a2c8e99bd74999db92 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Wed, 26 Feb 2020 10:42:54 -0800
+Subject: [PATCH] determine g-ir-scanner and g-ir-compiler paths from pkgconfig
+
+Currently, meson hard codes the paths of these binaries which results in
+cross-compiled environments to run the host versions of these tools.
+However, GObject-introspection provides the appropriate paths to these
+utilities via pkg-config
+
+find_program is needed in the case g-i is built as a subproject. If
+g-ir-scanner or g-ir-compiler are in the build or source directory use those.
+If they aren't found in the source directory, use the results from pkg-config.
+
+Cherry picked from:
+https://github.com/mesonbuild/meson/commit/f66b04b0996eae5cd7b0ad007435d5a51f28b691
+https://github.com/mesonbuild/meson/commit/6ba034c37d8004a72d392f37f66e709c593d8983
+
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 25 ++++++++++++++++++++++---
+ 1 file changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 9bd7a99..df01409 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -736,15 +736,34 @@ class GnomeModule(ExtensionModule):
+         if kwargs.get('install_dir'):
+             raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
+ 
+-        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
+-        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+-
+         girtargets = [self._unwrap_gir_target(arg, state) for arg in args]
+ 
+         if len(girtargets) > 1 and any([isinstance(el, build.Executable) for el in girtargets]):
+             raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
+ 
+         self.gir_dep, pkgargs = self._get_gir_dep(state)
++        # find_program is needed in the case g-i is built as subproject.
++        # In that case it uses override_find_program so the gobject utilities
++        # can be used from the build dir instead of from the system.
++        # However, GObject-introspection provides the appropriate paths to
++        # these utilities via pkg-config, so it would be best to use the
++        # results from pkg-config when possible.
++        gi_util_dirs_check = [state.environment.get_build_dir(), state.environment.get_source_dir()]
++        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
++        if giscanner.found():
++            giscanner_path = giscanner.get_command()[0]
++            if not any(x in giscanner_path for x in gi_util_dirs_check):
++                giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++        else:
++            giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++
++        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
++        if gicompiler.found():
++            gicompiler_path = gicompiler.get_command()[0]
++            if not any(x in gicompiler_path for x in gi_util_dirs_check):
++                gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
++        else:
++            gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+ 
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+-- 
+2.24.1
+
Signature · 1 line
2.24.1
#6 lore raw

PATCH v4 3/3 package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 37 lines

From: Adam Duskett <[email protected]>

Currently, meson hard codes the paths of these binaries which results in cross-compiled environments to run the host versions of these tools. However, GObject-introspection provides the appropriate paths to these utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If g-ir-scanner or g-ir-compiler are in the build or source directory use those. If they aren't found in the source directory, use the results from pkg-config.

Current upstream-status: merged
https://github.com/mesonbuild/meson/pull/6687
https://github.com/mesonbuild/meson/pull/6696

---
Changes v1 -> v3:
- Use an upstream patch that fixes this issue permanently.

 ...canner-and-g-ir-compiler-paths-from-.patch | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +7 -0
new file mode 100644
index 0000000000..4f765e2157
@@ -0,0 +1,68 @@
+From e8c2c21aabb4a06915b2e3a2c8e99bd74999db92 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Wed, 26 Feb 2020 10:42:54 -0800
+Subject: [PATCH] determine g-ir-scanner and g-ir-compiler paths from pkgconfig
+
+Currently, meson hard codes the paths of these binaries which results in
+cross-compiled environments to run the host versions of these tools.

package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch line 17

Quoted 10 lines
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +10 -0
+However, GObject-introspection provides the appropriate paths to these
+utilities via pkg-config
+
+find_program is needed in the case g-i is built as a subproject. If
+g-ir-scanner or g-ir-compiler are in the build or source directory use those.
+If they aren't found in the source directory, use the results from pkg-config.
+
+Cherry picked from:
+https://github.com/mesonbuild/meson/commit/f66b04b0996eae5cd7b0ad007435d5a51f28b691
+https://github.com/mesonbuild/meson/commit/6ba034c37d8004a72d392f37f66e709c593d8983

This is backporting two commits, so should be two patches.

Regards,
Yann E. MORIN.

Quoted 57 lines
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +50 -0
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 25 ++++++++++++++++++++++---
+ 1 file changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 9bd7a99..df01409 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -736,15 +736,34 @@ class GnomeModule(ExtensionModule):
+         if kwargs.get('install_dir'):
+             raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
+ 
+-        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
+-        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+-
+         girtargets = [self._unwrap_gir_target(arg, state) for arg in args]
+ 
+         if len(girtargets) > 1 and any([isinstance(el, build.Executable) for el in girtargets]):
+             raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
+ 
+         self.gir_dep, pkgargs = self._get_gir_dep(state)
++        # find_program is needed in the case g-i is built as subproject.
++        # In that case it uses override_find_program so the gobject utilities
++        # can be used from the build dir instead of from the system.
++        # However, GObject-introspection provides the appropriate paths to
++        # these utilities via pkg-config, so it would be best to use the
++        # results from pkg-config when possible.
++        gi_util_dirs_check = [state.environment.get_build_dir(), state.environment.get_source_dir()]
++        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
++        if giscanner.found():
++            giscanner_path = giscanner.get_command()[0]
++            if not any(x in giscanner_path for x in gi_util_dirs_check):
++                giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++        else:
++            giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++
++        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
++        if gicompiler.found():
++            gicompiler_path = gicompiler.get_command()[0]
++            if not any(x in gicompiler_path for x in gi_util_dirs_check):
++                gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
++        else:
++            gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+ 
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+-- 
+2.24.1
+
Signature · 6 lines
2.24.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
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.  |
'------------------------------^-------^------------------^--------------------'
#7 lore raw

PATCH v4 3/3 package/meson: determine g-ir-scanner and g-ir-compiler paths from pkgconfig

Yann;

Quoted 45 lines · Yann E. MORIN

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 41 lines

From: Adam Duskett <[email protected]>

Currently, meson hard codes the paths of these binaries which results in cross-compiled environments to run the host versions of these tools. However, GObject-introspection provides the appropriate paths to these utilities via pkg-config

find_program is needed in the case g-i is built as a subproject. If g-ir-scanner or g-ir-compiler are in the build or source directory use those. If they aren't found in the source directory, use the results from pkg-config.

Current upstream-status: merged
https://github.com/mesonbuild/meson/pull/6687
https://github.com/mesonbuild/meson/pull/6696

---
Changes v1 -> v3:
- Use an upstream patch that fixes this issue permanently.

 ...canner-and-g-ir-compiler-paths-from-.patch | 68 +++++++++++++++++++
 1 file changed, 68 insertions(+)
 create mode 100644 package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +11 -0
new file mode 100644
index 0000000000..4f765e2157
@@ -0,0 +1,68 @@
+From e8c2c21aabb4a06915b2e3a2c8e99bd74999db92 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <[email protected]>
+Date: Wed, 26 Feb 2020 10:42:54 -0800
+Subject: [PATCH] determine g-ir-scanner and g-ir-compiler paths from pkgconfig
+
+Currently, meson hard codes the paths of these binaries which results in
+cross-compiled environments to run the host versions of these tools.
+However, GObject-introspection provides the appropriate paths to these
+utilities via pkg-config
+
+find_program is needed in the case g-i is built as a subproject. If
Quoted 9 lines

package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch line 17

Quoted 6 lines
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +6 -0
+g-ir-scanner or g-ir-compiler are in the build or source directory use those.
+If they aren't found in the source directory, use the results from pkg-config.
+
+Cherry picked from:
+https://github.com/mesonbuild/meson/commit/f66b04b0996eae5cd7b0ad007435d5a51f28b691
+https://github.com/mesonbuild/meson/commit/6ba034c37d8004a72d392f37f66e709c593d8983

This is backporting two commits, so should be two patches.

I guess? The second patch fixes the first one. Is there any reason why it would have to be two patches other
than precednence?

Adam

Quoted 68 lines

Regards,
Yann E. MORIN.

Quoted 53 lines
package/meson/0004-determine-g-ir-scanner-and-g-ir-compiler-paths-from-.patch new file +50 -1
+Signed-off-by: Adam Duskett <[email protected]>
+---
+ mesonbuild/modules/gnome.py | 25 ++++++++++++++++++++++---
+ 1 file changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/mesonbuild/modules/gnome.py b/mesonbuild/modules/gnome.py
+index 9bd7a99..df01409 100644
+--- a/mesonbuild/modules/gnome.py
++++ b/mesonbuild/modules/gnome.py
+@@ -736,15 +736,34 @@ class GnomeModule(ExtensionModule):
+         if kwargs.get('install_dir'):
+             raise MesonException('install_dir is not supported with generate_gir(), see "install_dir_gir" and "install_dir_typelib"')
+
+-        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
+-        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
+-
+         girtargets = [self._unwrap_gir_target(arg, state) for arg in args]
+
+         if len(girtargets) > 1 and any([isinstance(el, build.Executable) for el in girtargets]):
+             raise MesonException('generate_gir only accepts a single argument when one of the arguments is an executable')
+
+         self.gir_dep, pkgargs = self._get_gir_dep(state)
++        # find_program is needed in the case g-i is built as subproject.
++        # In that case it uses override_find_program so the gobject utilities
++        # can be used from the build dir instead of from the system.
++        # However, GObject-introspection provides the appropriate paths to
++        # these utilities via pkg-config, so it would be best to use the
++        # results from pkg-config when possible.
++        gi_util_dirs_check = [state.environment.get_build_dir(), state.environment.get_source_dir()]
++        giscanner = self.interpreter.find_program_impl('g-ir-scanner')
++        if giscanner.found():
++            giscanner_path = giscanner.get_command()[0]
++            if not any(x in giscanner_path for x in gi_util_dirs_check):
++                giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++        else:
++            giscanner = self.gir_dep.get_pkgconfig_variable('g_ir_scanner', {})
++
++        gicompiler = self.interpreter.find_program_impl('g-ir-compiler')
++        if gicompiler.found():
++            gicompiler_path = gicompiler.get_command()[0]
++            if not any(x in gicompiler_path for x in gi_util_dirs_check):
++                gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
++        else:
++            gicompiler = self.gir_dep.get_pkgconfig_variable('g_ir_compiler', {})
+
+         ns = kwargs.pop('namespace')
+         nsversion = kwargs.pop('nsversion')
+--
+2.24.1
+
--

2.24.1

Quoted 4 lines

_______________________________________________
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.  |

'------------------------------^-------^------------------^--------------------'

#8 lore raw

PATCH v4 1/3 package/gobject-introspection: fix host-linking

In reply to aduskett at gmail.com

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 4 lines

From: Adam Duskett <[email protected]>

When building, gobject-introspection uses g-ir-scanner to build several .gir files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in

What's LDPATH? Did you mean LDFLAGS? Or LD_RUN_PATH? Or soemthing else?

Still, this is not clear what the problem is, and why we need LD_LIBRART_PATH. We already discussed this on IRC, and you said upstream said to use it, but I am still not convinced, because this is really ugly.

Also, this is not just g-ir-scanner that has the problem Is we were to just export LD_LIBRARY_PATH in our wrapper, that would stil cause build failures:

    1 #!/usr/bin/env bash
    2
    3 export GI_SCANNER_DISABLE_CACHE=1
    4 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${HOST_DIR}/lib"  # Not enough!
    5 ${HOST_DIR}/bin/g-ir-scanner \
    6 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
    7 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
    8 --use-ldd-wrapper=$(dirname $0)/g-ir-scanner-lddwrapper \
    9 --add-include-path=$(dirname $0)/../share/gir-1.0 "$@"
Quoted 1 line

order to ensure that g-ir-scanner does not use the host library path.

Did you mean:
... that g-ir-scanner does not use the system-install libglib2.

There is indeed a problem, but I still don't understand it, and even if setting LD_LIBRARY_PATH does indeed solve the issue, I'm still not happy about that... :-(

Yeah, we've already concluded that anything goi related would have to be ugly by design... Still, I'm not happy... :-(

Maybe if the commit log were to at least point at the discussion with upstream (on their issue tracker?), that could make the pill easier to swallow... :-/

Regards,
Yann E. MORIN.

Quoted 42 lines

This fix has the added benefit of allowing the host gobject-introspection to build the host .gir, .rnc, and .typelib files, which some packages may require.

---
Changes v1 -> v3:
- Update comment to be more clear.

Changes v3 -> v4:
- Update patch to work with gobject-introspection 2.64.0

 package/gobject-introspection/gobject-introspection.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
package/gobject-introspection/gobject-introspection.mk +5 -5
index c18a1f17d3..9043390857 100644
@@ -33,11 +33,11 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
 GOBJECT_INTROSPECTION_NINJA_ENV += \
 	CC="$(TARGET_CC)"
 
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-	-Dbuild_introspection_data=false
+# When building, gobject-introspection uses g-ir-scanner to build several .gir
+# files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in
+# order to ensure that g-ir-scanner does not use the host library path.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+	LD_LIBRARY_PATH="$(HOST_DIR)/lib"
 
 # Use the host gi-scanner to prevent the scanner from generating incorrect
 # elf classes.
Signature · 6 lines
2.24.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
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.  |
'------------------------------^-------^------------------^--------------------'
#9 lore raw

PATCH v4 1/3 package/gobject-introspection: fix host-linking

Yann;

Quoted 10 lines · Yann E. MORIN

Adam, All,

On 2020-03-12 12:46 -0700, aduskett at gmail.com spake thusly:

Quoted 4 lines

From: Adam Duskett <[email protected]>

When building, gobject-introspection uses g-ir-scanner to build several .gir files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in

What's LDPATH? Did you mean LDFLAGS? Or LD_RUN_PATH? Or soemthing else?

I meant LDFLAGS. Sorry about that.

Quoted 5 lines

Still, this is not clear what the problem is, and why we need LD_LIBRARY_PATH. We already discussed this on IRC, and you said upstream said to use it, but I am still not convinced, because this is really ugly.

It's specifically needed during the build process because during the build process
host-goi builds and calls g-ir-scanner to build .gir files. I don't like it either, but it
works and on IRC a maintainer told me that it needs to be exported and that is the correct solution.

Quoted 15 lines

Also, this is not just g-ir-scanner that has the problem Is we were to just export LD_LIBRARY_PATH in our wrapper, that would stil cause build failures:

    1 #!/usr/bin/env bash
    2
    3 export GI_SCANNER_DISABLE_CACHE=1
    4 export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${HOST_DIR}/lib"  # Not enough!
    5 ${HOST_DIR}/bin/g-ir-scanner \
    6 --lib-dirs-envvar=GIR_EXTRA_LIBS_PATH \
    7 --use-binary-wrapper=$(dirname $0)/g-ir-scanner-qemuwrapper \
    8 --use-ldd-wrapper=$(dirname $0)/g-ir-scanner-lddwrapper \
    9 --add-include-path=$(dirname $0)/../share/gir-1.0 "$@"
Quoted 4 lines
Quoted 1 line

order to ensure that g-ir-scanner does not use the host library path.

Did you mean:
... that g-ir-scanner does not use the system-install libglib2.

The host computer or system-installed libglib2.

Quoted 4 lines

There is indeed a problem, but I still don't understand it, and even if setting LD_LIBRARY_PATH does indeed solve the issue, I'm still not happy about that... :-(

There is not much else I can do.

Quoted 7 lines

Yeah, we've already concluded that anything goi related would have to be ugly by design... Still, I'm not happy... :-(

Maybe if the commit log were to at least point at the discussion with upstream (on their issue tracker?), that could make the pill easier to swallow... :-/

It was on IRC.

Quoted 3 lines

Regards,
Yann E. MORIN.

Adam

Quoted 51 lines
Quoted 39 lines

This fix has the added benefit of allowing the host gobject-introspection to build the host .gir, .rnc, and .typelib files, which some packages may require.

---
Changes v1 -> v3:
- Update comment to be more clear.

Changes v3 -> v4:
- Update patch to work with gobject-introspection 2.64.0

 package/gobject-introspection/gobject-introspection.mk | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
package/gobject-introspection/gobject-introspection.mk +5 -6
index c18a1f17d3..9043390857 100644
@@ -33,11 +33,11 @@ HOST_GOBJECT_INTROSPECTION_DEPENDENCIES = \
 GOBJECT_INTROSPECTION_NINJA_ENV += \
      CC="$(TARGET_CC)"
 
-# Disable introspection data on the host, as it is not needed and
-# the package will attempt to use the systems libglib2 which will fail
-# if the systems libglib2 version is older than 2.60.
-HOST_GOBJECT_INTROSPECTION_CONF_OPTS = \
-     -Dbuild_introspection_data=false
+# When building, gobject-introspection uses g-ir-scanner to build several .gir
+# files. g-ir-scanner does not use LDPATH, so LD_LIBRARY_PATH must be used in
+# order to ensure that g-ir-scanner does not use the host library path.
+HOST_GOBJECT_INTROSPECTION_NINJA_ENV += \
+     LD_LIBRARY_PATH="$(HOST_DIR)/lib"
 
 # Use the host gi-scanner to prevent the scanner from generating incorrect
 # elf classes.
--

2.24.1

Quoted 4 lines

_______________________________________________
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.  |

'------------------------------^-------^------------------^--------------------'