mbox series

[bug#49025,core-updates,00/37] Support cross-compilation with meson

Message ID 419215938396207999184dafa43afaed6d7a0715.camel@telenet.be
Headers show
Series Support cross-compilation with meson | expand

Message

M June 14, 2021, 3:22 p.m. UTC
This patch series adds cross-compilation support to meson-build-system.
meson-build-system is used by many gtk applications (sometimes directly,
sometimes because a dependency uses meson-build-system).

This has been tested with

  ./pre-inst-env guix build --target=i686-linux-gnu glib

on a x86_64-linux system. The build succeeds, and
"guix gc --references ..." looked reasonable to me.

Meson cross-compilation is implemented by the last patch.
The one-before-last patch works-around the brokenness of
GCC cross-compilers on current core-updates
(see <http://issues.guix.gnu.org/48913>;).

The first two patches define a few utilities target-linux?,
target-x86-32? and target-x86-64? which are used by the last patch,
but could be useful elsewhere as well. The third patch is used
in various cross-compilation fixes.

The other 34 patches are cross-compilation fixes for dependencies
of glib, and follow-up patches making the package definitions
somewhat nicer IMHO (like removing trailing #t from phases,
and computing derivation for some architecture-independent packages
when cross-compiling and compiling natively).

Maxime Devos (37):
  utils: Define target-linux? predicate.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Make #:builder argument a G-expression.
  net-base: Fix cross-compilation, eliminating %build-inputs & friends
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpgerror: Maybe fix a cross-compilation bug.
  libgpg-error: Fix cross-compilation error.
  libgcrypt: Fix cross-compilation build error.
  wrap-python3: Make #:builder a G-exp instead of a raw S-exp.
  wrap-python3: Fix cross-compilation.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Find bin/env when cross-compiling.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  readline: Make #:configure-flags a G-expression.
  readline: Fix build error when cross-compiling.
  bash: Make #:configure-flags a G-expression.
  bash: Fix cross-compilation build error.
  fontconfig: Make the #:configure-flags argument a G-expression.
  fontconfig: Fix build error when cross-compiling.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  tk: Make #:configure-flags a G-expression.
  tk: Do not use %build-inputs when cross-compiling.
  libelf: Use the cross-compiler when cross-compiling.
  opendht: Correct 'nettle' variable name in inputs.
  cross-base: Fix cross-compiler for i686-linux-gnu.
  meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |  44 ++++---
 gnu/packages/base.scm              |   9 ++
 gnu/packages/bash.scm              |  39 +++---
 gnu/packages/cross-base.scm        |  63 ++++++++-
 gnu/packages/elf.scm               |  48 ++++---
 gnu/packages/fontutils.scm         |   8 +-
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  60 ++++++---
 gnu/packages/networking.scm        |   2 +-
 gnu/packages/python.scm            |  51 ++++----
 gnu/packages/readline.scm          |  27 ++--
 gnu/packages/tcl.scm               |  14 +-
 gnu/packages/tls.scm               | 142 ++++++++++----------
 guix/build-system/meson.scm        | 200 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  71 ++++++++++
 guix/packages.scm                  |  29 +++++
 guix/utils.scm                     |  26 ++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 20 files changed, 728 insertions(+), 214 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm


base-commit: 92803cbef5affa3dbbf049262e1fcf290d8d8622

Comments

M June 14, 2021, 4:04 p.m. UTC | #1
Maxime Devos schreef op ma 14-06-2021 om 17:22 [+0200]:
>   opendht: Correct 'nettle' variable name in inputs.

This patch is not a cross-compilation fix.
It doesn't belong in this patch series.
Still a fix though.  I think it would address
the recent evaluation failures on ci.guix.gnu.org
for core-updates.
Mathieu Othacehe June 18, 2021, 7:55 a.m. UTC | #2
Hello Maxime,

I had a first look to this patchset, this is awesome work. I like how
you use G-exp in build expressions to fix cross-compilation issues.

I'd like to apply your patches to review them more closely, but I'm
having some troubles applying them from GNUS. Did you use "git
send-email" or another mechanism?

It would also be great if we could manage to have meson cross-compile
binaries for armhf/aarch64. As we do not have many substitutes for those
architectures, being able to cross-compile fully-featured images has
been a goal of mine for many years.

In the meantime, I applied the 35th patch hoping to fix Cuirass
evaluations on the core-updates branch.

Thanks,

Mathieu
Mathieu Othacehe June 18, 2021, 8:01 a.m. UTC | #3
> In the meantime, I applied the 35th patch hoping to fix Cuirass
> evaluations on the core-updates branch.

Turns out it is already fixed by
b4ad57ae3e5249ee7402b2ab3c41104ce9c01529 and core-updates evaluations
are still broken :(.

Mathieu
Ludovic Courtès June 18, 2021, 12:32 p.m. UTC | #4
Hi,

Mathieu Othacehe <othacehe@gnu.org> skribis:

> I'd like to apply your patches to review them more closely, but I'm
> having some troubles applying them from GNUS. Did you use "git
> send-email" or another mechanism?

Patches are attached, which makes it a bit trickier to apply them.
Unfortunately mumi seems to be unable to extract them via URLs like
<https://issues.guix.gnu.org/issue/49025/patch-set/0>.

Ludo’.
M June 18, 2021, 2:58 p.m. UTC | #5
Mathieu Othacehe schreef op vr 18-06-2021 om 09:55 [+0200]:
> Hello Maxime,
> 
> I had a first look to this patchset, this is awesome work. I like how
> you use G-exp in build expressions to fix cross-compilation issues.
> 
> I'd like to apply your patches to review them more closely, but I'm
> having some troubles applying them from GNUS. Did you use "git
> send-email" or another mechanism?

Some combination of "git send-email", "git format-patch --stdout --attach origin",
"git imap-send", manually fixing "References", "In-Reply-To" and "To" headers,
moving the mails to the ‘outbox’ of the e-mail client, trying to
flush the outbox, which didn't do anything and opening the mails in the outbox and
sending them individually.

I'll resend the patches with "git send-email", as a v2 (but the content is
identical).

> It would also be great if we could manage to have meson cross-compile
> binaries for armhf/aarch64. [...

I was thinking of cross-compiling of cross-compiling for the Hurd.
The glib-or-gtk-build-system would need cross-building support as well,
but it's ‘merely’ a variant of gnu-build-system with two extra phases,
so that should be easy.

Greetings,
Maxime.
M July 14, 2021, 11:12 a.m. UTC | #6
The following changes were made since the v5:

  * The 'configuration-port' parameter has been eliminated
  * #:target and #:build is set in meson-cross-build, such that
    'TARGET-strip' is used instead of 'strip'
  * #:dynamic-linker-cache? is set to to #f in meson-cross-build,
    as in gnu-cross-build
  * 'make-machine-alist' now supports 'arm-linux-gnueabihf'.
  * 'make-machine-alist' now has a generic fallback fake ‘CPU type’.
    Apparently, meson doesn't care what the value is and most
    software doesn't.  Now powerpc64le-linux-gnu is supported
    (tested with qemu) and also mips64le is supported (untested).

    All supported cross targets should now be supported by meson.
  * the new target-...? proedures always return booleans
  * added some docstrings
  * target-hurd? is moved to (guix utils)

Maxime Devos (22):
  utils: Define 'target-linux?' predicate.
  utils: Define 'target-hurd?' predicate.
  utils: Give 'target-mingw?' a docstring.
  utils: Define a target-x86-32? and target-x86-64? predicate.
  packages: Define this-package-input and this-package-native-input.
  net-base: Don't cross-compile.
  tzdata: Don't bother with cross-compiling.
  libgpg-error: Remove trailing #f from phases.
  libgpg-error: Prevent silent miscompilation some systems.
  libgpg-error: Fix cross-compilation error.
  python: Fix reference to input when cross-compiling.
  openssl: Remove trailing #t from phases.
  openssl: Make the #:phases argument a G-expression.
  openssl: Use G-exp machinery for referring to outputs.
  openssl: Move documentation instead of copying and deleting it.
  openssl: Move all man pages to separate output, not only man3.
  openssl: Extract logic for computing CONFIGURE_TARGET_ARCH.
  glib: Use a correct python in scripts when cross-compiling.
  glib: Verify the cross-compiled python is used in installed scripts.
  glib: Look up "tzdata" in 'native-inputs', not 'inputs'.
  libelf: Update configure script and config.guess and config.sub.
  build-system/meson: Support cross-compilation.

 Makefile.am                        |   1 +
 gnu/packages/admin.scm             |   5 +
 gnu/packages/base.scm              |   9 ++
 gnu/packages/bdw-gc.scm            |   4 +-
 gnu/packages/cross-base.scm        |   6 +-
 gnu/packages/elf.scm               |  44 +++---
 gnu/packages/glib.scm              |  34 ++++-
 gnu/packages/gnupg.scm             |  48 ++++---
 gnu/packages/hurd.scm              |  10 +-
 gnu/packages/make-bootstrap.scm    |   2 +-
 gnu/packages/python.scm            |   5 +-
 gnu/packages/tls.scm               | 136 ++++++++++---------
 guix/build-system/meson.scm        | 209 ++++++++++++++++++++++++++---
 guix/build/meson-configuration.scm |  56 ++++++++
 guix/packages.scm                  |  29 ++++
 guix/utils.scm                     |  38 ++++++
 tests/packages.scm                 |  34 +++++
 tests/utils.scm                    |  40 ++++++
 18 files changed, 575 insertions(+), 135 deletions(-)
 create mode 100644 guix/build/meson-configuration.scm