NetBSD Problem Report #56457

From tsutsui@ceres.dti.ne.jp  Sat Oct 16 16:36:11 2021
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EEBC61A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 16 Oct 2021 16:36:10 +0000 (UTC)
Message-Id: <202110161635.19GGZxiM027510@ceres.dti.ne.jp>
Date: Sun, 17 Oct 2021 01:35:59 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: pkgsrc/www/firefox 93.0 build fails on NetBSD/i386 9.2
X-Send-Pr-Version: 3.95

>Number:         56457
>Category:       pkg
>Synopsis:       pkgsrc/www/firefox 93.0 build fails on NetBSD/i386 9.2
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ryoon
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 16 16:40:00 +0000 2021
>Closed-Date:    Sat Oct 30 00:59:32 +0000 2021
>Last-Modified:  Sat Oct 30 00:59:32 +0000 2021
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.2
>Organization:
>Environment:
System: NetBSD optiplex 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
Building pkgsrc/www/firefox 93.0 fails on NetBSD/i386 9.2:

---
 :

gmake[3]: Entering directory '/s/obj.i386/pkgsrc/www/firefox/work.i386/build/modules/fdlibm/src'
mkdir -p '.deps/'
modules/fdlibm/src/e_acos.o
/s/obj.i386/pkgsrc/www/firefox/work.i386/.cwrapper/bin/c++ -std=gnu++17 -o e_acos.o -c  -I/s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/stl_wrappers -I/s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/system_wrappers -include /s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/config/gcc_hidden.h -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector-strong -DNDEBUG=1 -DTRIMMED=1 -DEXPORT_JS_API -DMOZ_HAS_MOZGLUE -I/s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/modules/fdlibm/src -I/s/obj.i386/pkgsrc/www/firefox/work.i386/build/modules/fdlibm/src -I/s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/include -I/usr/pkg/include/nspr -I/usr/pkg/include/nss -I/usr/pkg/include/nspr -I/s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/include/nss -I/usr/X11R7/include/pixman-1 -I/usr/pkg/include -DMOZILLA_CLIENT -include /s/obj.i386/pkgsrc/www/firefox/work.i386/build/mozilla-config.h -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/nspr -I/usr/X11R7/include -!
 I/usr/X11R7/include/libdrm -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/ffmpeg4 -I/usr/X11R7/include/freetype2 -I/usr/pkg/include/harfbuzz -Wall -Wempty-body -Wignored-qualifiers -Wpointer-arith -Wsign-compare -Wtype-limits -Wunreachable-code -Wno-invalid-offsetof -Wduplicated-cond -Wimplicit-fallthrough -Wno-error=maybe-uninitialized -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=coverage-mismatch -Wno-error=free-nonheap-object -Wno-error=unused-but-set-variable -Wformat -Wformat-overflow=2 -Wno-psabi -fno-sized-deallocation -fno-aligned-new -O2 -D_GLIBCXX_INCLUDE_NEXT_C_HEADERS -march=i586 -D_FORTIFY_SOURCE=2 -I/usr/pkg/include -I/usr/include -I/usr/pkg/include/nspr -I/usr/X11R7/include -I/usr/X11R7/include/libdrm -I/usr/pkg/include/glib-2.0 -I/usr/pkg/include/gio-unix-2.0 -I/usr/pkg/lib/glib-2.0/include -I/usr/pkg/include/ffmpeg4 -I/usr/X11R7/include/freetype2 -I/usr/pkg/include/harf!
 buzz -mstackrealign -march=i586 -fno-exceptions -fno-strict-al!
 iasing -Dunix -fPIC -DPIC -fno-rtti -ffunction-sections -fdata-sections -fno-exceptions -fno-math-errno -pthread -pipe -O2 -fomit-frame-pointer -funwind-tables -Wno-parentheses -Wno-sign-compare  -MD -MP -MF .deps/e_acos.o.pp   /s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/modules/fdlibm/src/e_acos.cpp
modules/fdlibm/src/e_acosh.o
In file included from /s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/modules/fdlibm/src/e_acos.cpp:44:0:
/s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/modules/fdlibm/src/math_private.h:34:21: error: conflicting declaration 'typedef __double_t double_t'
 typedef __double_t  double_t;
                     ^~~~~~~~
In file included from /usr/include/g++/cmath:45:0,
                 from /s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/system_wrappers/cmath:3,
                 from /s/obj.i386/pkgsrc/www/firefox/work.i386/build/dist/stl_wrappers/cmath:64,
                 from /s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/modules/fdlibm/src/e_acos.cpp:41:
/usr/include/math.h:51:21: note: previous declaration as 'typedef long double double_t'
 typedef long double double_t;
                     ^~~~~~~~
gmake[3]: *** [/s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/config/rules.mk:676: e_acos.o] Error 1
gmake[3]: Leaving directory '/s/obj.i386/pkgsrc/www/firefox/work.i386/build/modules/fdlibm/src'
gmake[2]: *** [/s/obj.i386/pkgsrc/www/firefox/work.i386/firefox-93.0/config/recurse.mk:72: modules/fdlibm/src/target-objects] Error 2

---

>How-To-Repeat:
Just build (make package) on pkgsrc/www/firefox 93.0 updated on 20211015:
 https://mail-index.netbsd.org/pkgsrc-changes/2021/10/15/msg242086.html

>Fix:
The problem is "__double_t" in firefox-93.0/modules/fdlibm/src/math_private.h
as the above error log says.

The __double_t typedef was introduced between firefox 92 and 93:
 https://github.com/mozilla/gecko-dev/commit/6ce4ce9c3b108076fbbde86a66cfecae01934148#diff-1ed1c2c00aa256114c0813311807f4b4b28e15b15e455c02708d30ffaba169db
---
/*
 * Emulate FreeBSD internal double types.
 * Adapted from https://github.com/freebsd/freebsd-src/search?q=__double_t
 */

typedef double      __double_t;
typedef __double_t  double_t;
---

As the above comment says, __double_t was derived from FreeBSD implementation:
 https://github.com/freebsd/freebsd-src/search?q=__double_t

I.e. machine depedent headers (sys/x86/include/_types.h etc.)
typedef MD __double_t:
---
typedef	double		__double_t;
typedef	float		__float_t;
---

and MI <lib/msun/src/math.h> typedefs __double_t as double_t:
---
typedef	__double_t	double_t;
typedef	__float_t	float_t;
---

However, the POSIX (and C99) explicitly defines double_t type
and it should be determined by pre-defined FLT_EVAL_METHOD:
 https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html

>> double_t
>>     A real-floating type at least as wide as double, and at least
>>     as wide as float_t.
>> 
>> If FLT_EVAL_METHOD equals 0, float_t and double_t shall be float
>> and double, respectively; if FLT_EVAL_METHOD equals 1, they shall
>> both be double; if FLT_EVAL_METHOD equals 2, they shall both be
>> long double; for other values of FLT_EVAL_METHOD, they are
>> otherwise implementation-defined.

I.e. no machine dependent definitions are necessary.

NetBSD's <math.h> follows the POSIX definitions:
 https://nxr.netbsd.org/xref/src/include/math.h?r=1.65#43
---
    43 #if ((_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE))
     44 #  if defined(__FLT_EVAL_METHOD__) && (__FLT_EVAL_METHOD__ - 0) == 0
     45 typedef double double_t;
     46 typedef float float_t;
     47 #  elif (__FLT_EVAL_METHOD__ - 0) == 1
     48 typedef double double_t;
     49 typedef double float_t;
     50 #  elif (__FLT_EVAL_METHOD__ - 0) == 2
     51 typedef long double double_t;
     52 typedef long double float_t;
     53 #  endif
     54 #endif
---

Linux glibc's <math.h> also has the similar definitions via <math/math.h>:

 https://sourceware.org/git/?p=glibc.git;a=blame;f=include/math.h;h=b4772d3d3b70b88a6f4bc5b9f4c1a5d229662347;hb=ae37d06c7d127817ba43850f0f898b793d42aea7
 https://sourceware.org/git/?p=glibc.git;a=blame;f=math/math.h;h=6b7ac7912279ff9b21f070ad757a1eaee27e71a7;hb=ae37d06c7d127817ba43850f0f898b793d42aea7
---
154	#ifdef __USE_ISOC99
155	/* Define the following typedefs.
156	
157	    float_t	floating-point type at least as wide as `float' used
158			to evaluate `float' expressions
159	    double_t	floating-point type at least as wide as `double' used
160			to evaluate `double' expressions
161	*/
162	# if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
163	typedef float float_t;
164	typedef double double_t;
165	# elif __GLIBC_FLT_EVAL_METHOD == 1
166	typedef double float_t;
167	typedef double double_t;
168	# elif __GLIBC_FLT_EVAL_METHOD == 2
169	typedef long double float_t;
170	typedef long double double_t;
171	# elif __GLIBC_FLT_EVAL_METHOD == 32
172	typedef _Float32 float_t;
173	typedef double double_t;
174	# elif __GLIBC_FLT_EVAL_METHOD == 33
175	typedef _Float32x float_t;
176	typedef _Float32x double_t;
177	# elif __GLIBC_FLT_EVAL_METHOD == 64
178	typedef _Float64 float_t;
179	typedef _Float64 double_t;
180	# elif __GLIBC_FLT_EVAL_METHOD == 65
181	typedef _Float64x float_t;
182	typedef _Float64x double_t;
183	# elif __GLIBC_FLT_EVAL_METHOD == 128
184	typedef _Float128 float_t;
185	typedef _Float128 double_t;
186	# elif __GLIBC_FLT_EVAL_METHOD == 129
187	typedef _Float128x float_t;
188	typedef _Float128x double_t;
189	# else
190	#  error "Unknown __GLIBC_FLT_EVAL_METHOD"
191	# endif
192	#endif
---

So the original definitions for double_t and __double_t
in the firefox-93.0/modules/fdlibm/src/math_private.h
(typedef'ing double_t as doubt unconditionally) are shortcomings
and it causes error as this PR on systems double_t is not double,
i.e. systems FLT_EVAL_METHOD != 0.

The __double_t is FreeBSD specific definition (that doesn't refer
FLT_EVAL_METHOD defined in the POSIX), so if the compiler is POSIX/C99
complient (and we can assume it on building firefox) it's enough to
have typedef of the FreeBSD specific __double_t as double_t.

With the following patch (as patch-modules_fdlibm_src_math__private.h)
builds both on NetBSD/amd64 9.2 and NetBSD/i386 9.2 work around:

---
$NetBSD$

- fix build on NetBSD/i386 9.2 (and other systems FLT_EVAL_METHOD != 0)

--- modules/fdlibm/src/math_private.h.orig	2021-09-27 22:47:42.000000000 +0000
+++ modules/fdlibm/src/math_private.h
@@ -30,8 +30,8 @@
  * Adapted from https://github.com/freebsd/freebsd-src/search?q=__double_t
  */

-typedef double      __double_t;
-typedef __double_t  double_t;
+#include <math.h>
+typedef double_t  __double_t;

 /*
  * The original fdlibm code used statements like:

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->ryoon
Responsible-Changed-By: bsiegert@NetBSD.org
Responsible-Changed-When: Sun, 17 Oct 2021 19:27:25 +0000
Responsible-Changed-Why:
Over to maintainer


From: "Ryo ONODERA" <ryoon@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/56457 CVS commit: pkgsrc/www/firefox
Date: Fri, 29 Oct 2021 16:46:04 +0000

 Module Name:	pkgsrc
 Committed By:	ryoon
 Date:		Fri Oct 29 16:46:04 UTC 2021

 Modified Files:
 	pkgsrc/www/firefox: distinfo
 Added Files:
 	pkgsrc/www/firefox/patches: patch-modules_fdlibm_src_math__private.h

 Log Message:
 firefox: Fix PR pkg/56457. Fix build under NetBSD/i386


 To generate a diff of this commit:
 cvs rdiff -u -r1.451 -r1.452 pkgsrc/www/firefox/distinfo
 cvs rdiff -u -r0 -r1.1 \
     pkgsrc/www/firefox/patches/patch-modules_fdlibm_src_math__private.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: ryoon@NetBSD.org
State-Changed-When: Sat, 30 Oct 2021 00:59:32 +0000
State-Changed-Why:
The patch has been applied. Thank you.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.