Bug#1061250: gjs FTCBFS: cxx.run always fails cross compilation

2024-01-21 Thread Helmut Grohne
Hi Simon,

On Sun, Jan 21, 2024 at 03:50:17PM +, Simon McVittie wrote:
> On Sun, 21 Jan 2024 at 12:56:49 +0100, Helmut Grohne wrote:
> > +if meson.is_cross_build()
> 
> In my experience, this function call is usually the wrong tool:
> I think it would likely be more in line with what upstream wants if
> it was based on "if not meson.can_run_host_binaries()", so that if we
> happen to be able to run host binaries (via i386-on-amd64, binfmt_misc
> or an explicitly configured EXE wrapper), the check will still be done.

Thank you for pointing at meson.can_run_host_binaries(). I concur that
this is what we want here. I shall remember this for future patches.

I concur that is_cross_build rarely is what we want and in numerous
places, I have proposed discarding such checks. In this case, the check
was already there and I have merely shifted it around subtly changing
the semantics such that it won't attempt to do the sanity check during
cross compilation.

> Does cxx.run() work as though we were doing a native build if Meson is
> run with a cross-file that configures an EXE wrapper, similar to
> ?
> I hope that it will.

That would also be my expectation.

> gjs is neither installable nor useful without GObject-Introspection, so
> on any architecture where we would consider cross-compiling gjs, we almost
> certainly already have qemu-user available.

Whils this is true in principle, the way you have integrated qemu into
gir, this fact is not exposed to the build system. Just because
g-ir-scanner uses qemu, does not imply that a crossfile has set this up
(while it still probably would be useful to set this up).

> > +warning('''This is a cross build. A check that a minimal
> > +SpiderMonkey program executes will not be performed. Before shipping GJS, 
> > you
> > +should check that it does not crash on startup, since building 
> > SpiderMonkey with
> > +the wrong configuration may cause that.''' + recommended_configuration)
> 
> This might still be a good idea even if an EXE wrapper is enough to
> resolve the build failure, but I'd prefer to take this sort of thing
> upstream rather than applying it unilaterally.

Yes, the bug is tagged upstream and resolving it upstream is what I
preferred - even if it takes longer that way.

Do you think this needs further improvement beyond replacing
is_cross_build with can_run_host_binaries?

Helmut



Bug#1061250: gjs FTCBFS: cxx.run always fails cross compilation

2024-01-21 Thread Simon McVittie
On Sun, 21 Jan 2024 at 12:56:49 +0100, Helmut Grohne wrote:
> +if meson.is_cross_build()

In my experience, this function call is usually the wrong tool:
I think it would likely be more in line with what upstream wants if
it was based on "if not meson.can_run_host_binaries()", so that if we
happen to be able to run host binaries (via i386-on-amd64, binfmt_misc
or an explicitly configured EXE wrapper), the check will still be done.

Does cxx.run() work as though we were doing a native build if Meson is
run with a cross-file that configures an EXE wrapper, similar to
?
I hope that it will.

gjs is neither installable nor useful without GObject-Introspection, so
on any architecture where we would consider cross-compiling gjs, we almost
certainly already have qemu-user available.

> +warning('''This is a cross build. A check that a minimal
> +SpiderMonkey program executes will not be performed. Before shipping GJS, you
> +should check that it does not crash on startup, since building SpiderMonkey 
> with
> +the wrong configuration may cause that.''' + recommended_configuration)

This might still be a good idea even if an EXE wrapper is enough to
resolve the build failure, but I'd prefer to take this sort of thing
upstream rather than applying it unilaterally.

Thanks,
smcv



Bug#1061250: gjs FTCBFS: cxx.run always fails cross compilation

2024-01-21 Thread Helmut Grohne
Source: gjs
Version: 1.78.2-2
Tags: patch upstream
User: debian-cr...@lists.debian.org
Usertags: ftcbfs

gjs fails to cross build from source, because meson.build uses
cxx.run().  While meson.build also considers a failure from cxx.run()
with a warning when cross compiling, that code never goes into effect,
because cxx.run() aborts meson execution during cross compilation. I'm
proposing the attached patch to skip cxx.run() when cross compiling
(with the previous warning). This allows the build to continue until it
runs into #1060838, which hopefully is to be fixed elsewhere.

Helmut
--- gjs-1.78.2.orig/meson.build
+++ gjs-1.78.2/meson.build
@@ -258,7 +258,15 @@
 # Check if a minimal SpiderMonkey program compiles, links, and runs. If not,
 # it's most likely the case that SpiderMonkey was configured incorrectly, for
 # example by building mozglue as a shared library.
-minimal_program = cxx.run('''
+recommended_configuration = ''' Check the recommended configuration:
+https://github.com/spidermonkey-embedders/spidermonkey-embedding-examples/blob/esr91/docs/Building%20SpiderMonkey.md'''
+if meson.is_cross_build()
+warning('''This is a cross build. A check that a minimal
+SpiderMonkey program executes will not be performed. Before shipping GJS, you
+should check that it does not crash on startup, since building SpiderMonkey with
+the wrong configuration may cause that.''' + recommended_configuration)
+else
+minimal_program = cxx.run('''
 #include 
 int main(void) {
 if (!JS_Init()) return 1;
@@ -266,24 +274,17 @@
 return 0;
 }
 ''',
-args: debug_arg, dependencies: spidermonkey,
-name: 'SpiderMonkey sanity check')
-
-recommended_configuration = ''' Check the recommended configuration:
-https://github.com/spidermonkey-embedders/spidermonkey-embedding-examples/blob/esr91/docs/Building%20SpiderMonkey.md'''
-if not minimal_program.compiled()
-error('''A minimal SpiderMonkey program
+args: debug_arg, dependencies: spidermonkey,
+name: 'SpiderMonkey sanity check')
+if not minimal_program.compiled()
+error('''A minimal SpiderMonkey program
 could not be compiled or linked. Most likely you should build it with a
 different configuration.''' + recommended_configuration)
-elif meson.is_cross_build()
-warning('''This is a cross build. A check that a minimal
-SpiderMonkey program executes will not be performed. Before shipping GJS, you
-should check that it does not crash on startup, since building SpiderMonkey with
-the wrong configuration may cause that.''' + recommended_configuration)
-elif minimal_program.returncode() != 0
-error('''A minimal SpiderMonkey program
+elif minimal_program.returncode() != 0
+error('''A minimal SpiderMonkey program
 failed to execute. Most likely you should build it with a different
 configuration.''' + recommended_configuration)
+endif
 endif
 
 have_printf_alternative_int = cc.compiles('''