Sunday, December 01, 2019

Fails to build devel/spidermonkey60 on mips64el/loongson

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEiKQfd6o81mjI+LWALell7WOCXJMFAl3jkocACgkQLell7WOC
XJMtig/+OggtocpKDOwL4l7eufh3OQ6+jeitpOORVGW/0h4gLZBT5c0KoWQsNk+r
scDdY6F115QEuy5G9EGglqse7JCXslglQokJTieO/Aer2wJuLpcxU5AfojkpPGh1
wRUygto+0Re0ODpl7c47UGuY86eYu2YhWIrUFp5nNjUBQ6S0nVvr7kSMryRcqea+
P+OHrEuaQdHUDJqM2ObD2B1qMVsd9XtiT8rGFKTf8CyIrrbk2cqVO7AWfvlwLvA7
Ftz4dz/EZQfrrFTzPCs+eV4dpocAppldnk78+nF1KAGrlfq+5m8hlxH/X61lIfQ3
3HbpFGW29Wu7u2cfvHweik8QVzeVw+v2UDZD/EUvtEIDbvhZoV91kV/NWQQW6jrw
Mwfeows8SylazoXoMZh/TL6CT3IV+oVAhd4omIZcPv6HoN+AEuu6fDGVPts9tCmX
VimLa3iSLTimH/Efck6cwNlx5kqoeSYL8Cy4rQo8PJOcpr2yX7S5Vme1+MYUG4CZ
5aGPnX6iwxjufk0sdDYDz1XnbbzTp78CQ91aFtll+LphztA4rUri75blMYNy+b6H
kbZZFynngLsS5c01DUmRsRx4Scl/uD7cXGr3GnpXXgcM2fgMbs9bvN/6DENGrl3H
wNkR1zVz7sLo62f1wi3hJ+2nNhWGGJjiTjRezi2Eql5AqrvuGD0=
=BzMD
-----END PGP SIGNATURE-----
Hi Ports maintainers,

I'm having trouble to get devel/spidermonkey60 to build on mips64el.
The initial problem was the following error:

------8<------
usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/jit/mips64/LIR-mips64.h:17:45:
error: no matching function for call to 'js::jit::LInstructionHelper<1,
1, 0>::LInstructionHelper()'
explicit LUnbox(const LAllocation& input) { setOperand(0, input); }
------8<------

It turned out that JIT was not well supported on MIPS as suggested in
the Debian bug[1], and the solution is to disable JIT on MIPS[2]. I
added it to the configure args and get passed this issue. Probably this
patch[7] should be applied.

However the second issue is more complicated. The error message is the
following:

------8<------
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/wasm/WasmSignalHandlers.cpp:101:26:
error: 'ucontext_t' {aka 'struct sigcontext'} has no member named
'sc_rsp'; did you mean 'sc_mask'?
#define RSP_sig(p) ((p)->sc_rsp)
^~~~~~
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/wasm/WasmSignalHandlers.cpp:450:19:
note: in expansion of macro 'RSP_sig'
#define SP_sig(p) RSP_sig(p)
^~~~~~~
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/wasm/WasmSignalHandlers.cpp:481:37:
note: in expansion of macro 'SP_sig'
return reinterpret_cast<uint8_t*>(SP_sig(context));
^~~~~~
In file included from
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/js/src/Unified_cpp_js_src41.cpp:2:
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/wasm/WasmSignalHandlers.cpp:
In function 'uint8_t* ContextToLR(ucontext_t*)':
/usr/ports/pobj/spidermonkey-60.8.0/firefox-60.8.0/js/src/wasm/WasmSignalHandlers.cpp:451:19:
error: 'R31_sig' was not declared in this scope
#define LR_sig(p) R31_sig(p)
------8<------

It seems that some members are missing from "struct sigcontext". The
relevant code from Firefox can be found at [3], which assumes some
members are available on OpenBSD. However, it turns out they are
available for some archs (e.g. AMD64[4]), but it's not for MIPS64[5].
The latest version of Firefox provides a more fine-grained check of
symbols for OpenBSD archs[6] but still assumes some symbols to be
available for all archs which are missing in MIPS64. And I'm not sure
about how this can be handled properly.

On the other hand, I think this target is dragged in as an indirect
dependency of Emacs because I think it needs gjs and WASM may not be
required. Is there a way to disable compiling the WASM part?


[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908486
[2]
https://salsa.debian.org/gnome-team/mozjs60/blob/debian/master/debian/rules#L42
[3]
https://hg.mozilla.org/mozilla-central/file/e33efdb3e1517d521deb949de3fcd6d9946ea440/js/src/wasm/WasmSignalHandlers.cpp#l103
[4]
https://github.com/openbsd/src/blob/b66614995ab119f75167daaa7755b34001836821/sys/arch/amd64/include/signal.h#L54
[5]
https://github.com/openbsd/src/blob/b66614995ab119f75167daaa7755b34001836821/sys/arch/mips64/include/signal.h#L56
[6]
https://hg.mozilla.org/mozilla-central/file/8504d70d827261346737af1cbe9b96acf6756b6d/js/src/wasm/WasmSignalHandlers.cpp#l80
[7] Patch for disabling JIT on MIPS* archs:

Index: Makefile
===================================================================
RCS file: /cvs/ports/devel/spidermonkey60/Makefile,v
retrieving revision 1.12
diff -u -p -r1.12 Makefile
--- Makefile 26 Sep 2019 13:00:21 -0000 1.12
+++ Makefile 1 Dec 2019 10:12:07 -0000
@@ -78,6 +78,12 @@ CONFIGURE_ARGS = --disable-debug \
# /usr/bin/ld.lld: error: undefined symbol:
std::__1::basic_ostream<char, std::__1::char_traits<char>
>::operator<<(unsigned long long)
CONFIGURE_ARGS += --disable-js-shell

+# Build failure on mips64{,el}. Related bug on Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=908486
+# error: no matching function for call to
'js::jit::LInstructionHelper<1, 1, 0>::LInstructionHelper()'
+.if ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
+CONFIGURE_ARGS += --disable-ion
+.endif
+
SO_VERSION = ${LIBmozjs-${MOZILLA_VERSION}_VERSION}
SUBST_VARS += SO_VERSION

cvs server: Diffing patches
cvs server: Diffing pkg

No comments:

Post a Comment