Re: Bug#1063446: libmozjs-115-dev: cannot call JS::CanonicalizeNaN(double) on mips64el
Simon McVittie <[email protected]> Thu, 8 Feb 2024 10:47:32 +0000
| Newsgroups | gmane.linux.debian.ports.mips |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 08 Feb 2024 at 10:37:33 +0000, Simon McVittie wrote:
> Simplified steps to reproduce:
> Try to compile the attached, with:
> g++ test.cpp -o test $(pkgconf --cflags --libs mozjs-115)
Oops, really attached now.
> I'm preparing a possible patch (but it will take a long time to test,
> because compiling mozjs on mips64el is extremely slow).
Untested patch attached. I'm trying to build with this change on eberlin.
smcv
test.cpp
(text/x-c++src, 742 B)
// Copyright 2024 Simon McVittie
// SPDX-License-Identifier: MIT
#include <cinttypes>
#include <cstdio>
#include <jsapi.h>
#include <js/Initialization.h>
int main(int argc, char** argv)
{
// Smoke-test
const char* reason = JS_InitWithFailureDiagnostic();
if (reason) {
std::fprintf(stderr, "Fatal error: %s\n", reason);
return 1;
}
JSContext* cx = JS_NewContext(32 * 1024 * 1024);
// https://bugs.debian.org/1063446
uint64_t u64;
double d = JS::CanonicalizeNaN(0.0/0.0);
static_assert(sizeof(u64) == sizeof(d));
memcpy(&u64, &d, sizeof(d));
std::printf("Representation of a canonicalized NaN: %" PRIx64 "\n", u64);
JS_DestroyContext(cx);
JS_ShutDown();
return 0;
}
UNTESTED-1063446.patch
(text/x-diff, 1.1 KB)
>From ac5a01642f111e88cb80aa54b1ee438b3bc6d07e Mon Sep 17 00:00:00 2001 From: Simon McVittie <[email protected]> Date: Thu, 8 Feb 2024 10:36:53 +0000 Subject: [PATCH] Export js::detail::CanonicalizedNaNBits on architectures that use it Otherwise the inline function JS::CanonicalizeNaN(double), which is called by gjs, cannot validly refer to it. Bug-Debian: https://bugs.debian.org/1063446 Signed-off-by: Simon McVittie <[email protected]> Gbp-Pq: Name Export-js-detail-CanonicalizedNaNBits-on-architectures-th.patch --- js/public/Value.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/public/Value.h b/js/public/Value.h index de8db0fed8..d934b59dd4 100644 --- a/js/public/Value.h +++ b/js/public/Value.h @@ -445,7 +445,7 @@ constexpr uint64_t CanonicalizedNaNSignificand = 0x8000000000000; #endif #if defined(JS_RUNTIME_CANONICAL_NAN) -extern uint64_t CanonicalizedNaNBits; +extern JS_PUBLIC_DATA uint64_t CanonicalizedNaNBits; #else constexpr uint64_t CanonicalizedNaNBits = mozilla::SpecificNaNBits<double, detail::CanonicalizedNaNSignBit,