NetBSD Problem Report #57022

From www@netbsd.org  Sat Sep 24 08:58:45 2022
Return-Path: <www@netbsd.org>
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 0CBD91A923A
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 24 Sep 2022 08:58:45 +0000 (UTC)
Message-Id: <20220924085843.B99E91A923B@mollari.NetBSD.org>
Date: Sat, 24 Sep 2022 08:58:43 +0000 (UTC)
From: nia@pkgsrc.org
Reply-To: nia@pkgsrc.org
To: gnats-bugs@NetBSD.org
Subject: programs built with aarch64 toolchain want __fixdfti, which doesn't exist
X-Send-Pr-Version: www-1.0

>Number:         57022
>Category:       toolchain
>Synopsis:       programs built with aarch64 toolchain want __fixdfti, which doesn't exist
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 24 09:00:01 +0000 2022
>Closed-Date:    Sat Oct 22 07:48:28 +0000 2022
>Last-Modified:  Sun Oct 23 11:35:01 +0000 2022
>Originator:     nia
>Release:        NetBSD 9.0
>Organization:
The NetBSD Foundation
>Environment:
>Description:
pkgsrc bulk builds regularly run into problems along the lines of:

UnifiedSource-f2e18ffc-13.cpp:(.text+0x3fd0): undefined reference to `__fixdfti'

This is a softfloat function for converting a double to a signed 64-bit
int, rounding toward zero. It seems like something that should not be
required on aarch64?
>How-To-Repeat:
presumably write code that converts a double to a singed 64-bit int
>Fix:

>Release-Note:

>Audit-Trail:
From: Taylor R Campbell <riastradh@NetBSD.org>
To: nia@pkgsrc.org
Cc: 
Subject: Re: toolchain/57022: programs built with aarch64 toolchain want __fixdfti, which doesn't exist
Date: Sat, 24 Sep 2022 10:38:22 +0000

 > Date: Sat, 24 Sep 2022 09:00:01 +0000 (UTC)
 > From: nia@pkgsrc.org
 >=20
 > UnifiedSource-f2e18ffc-13.cpp:(.text+0x3fd0): undefined reference to `__f=
 ixdfti'
 >=20
 > This is a softfloat function for converting a double to a signed 64-bit
 > int, rounding toward zero. It seems like something that should not be
 > required on aarch64?
 > >How-To-Repeat:
 > presumably write code that converts a double to a singed 64-bit int

 This is actually for converting double (IEEE 754 binary64) to
 int128_t.

 Example:

         __int128_t
         foo(double x)
         {
                 return x;
         }

         0000000000000000 <foo>:
            0:	a9bf7bfd 	stp	x29, x30, [sp, #-16]!
            4:	910003fd 	mov	x29, sp
            8:	94000000 	bl	0 <__fixdfti>
                                 8: R_AARCH64_CALL26	__fixdfti
            c:	a8c17bfd 	ldp	x29, x30, [sp], #16
           10:	d65f03c0 	ret

 It's unclear to me whether this function is supposed to come from
 libgcc or compiler-rt.

 On x86, it comes from libgcc, via _fixdfdi.c -- note: di, not ti.
 Somehow _fixdfdi.c, which is just

         #define L_fixdfdi
         #include <libgcc2.c>,

 manages to define only __fixdfti and not __fixdfdi, via

         dist/libgcc/libgcc2.h:#define __fixdfdi __NDW(fixdf,)

 where I think we're catching the definition

         dist/libgcc/libgcc2.h:#define __NDW(a,b)      __ ## a ## ti ## b

 However, on aarch64 (and coldfire and earm and mips64 and mipsn64),
 _fixdfdi.c is excluded from libgcc by the following fragment in
 external/gpl3/gcc/lib/libgcc/Makefile.inc:

         .if ${LIBGCC_MACHINE_ARCH} !=3D "coldfire" && \
             empty(LIBGCC_MACHINE_ARCH:Mearm*) && \
             empty(LIBGCC_MACHINE_ARCH:Maarch64*) && \
             empty(LIBGCC_MACHINE_ARCH:Mmips64*) && \
             empty(LIBGCC_MACHINE_ARCH:Mmipsn64*)

         EXTRA_FUNC_SIZES=3D	sf df xf

         .if ${LIBGCC_MACHINE_ARCH} !=3D "x86_64" && \
             ${LIBGCC_MACHINE_ARCH} !=3D "i386" && \
             ${LIBGCC_MACHINE_ARCH} !=3D "ia64"
         EXTRA_FUNC_SIZES+=3D	tf
         .endif

         # non swfloat versions=20
         .for _p in _fix _fixuns
         . for _m in ${EXTRA_FUNC_SIZES}
         LIB2FUNCS_ALL+=3D	${_p}${_m}di
         . endfor
         .endfor

 In libc's compiler-rt, fixdfti.c is excluded everywhere by this
 fragment in lib/libc/compiler_rt/Makefile.inc:

         # only used for machines using IEEE 754 floating point formats
         .if ${MACHINE_ARCH} !=3D "vax"

         .if 0
         # Conflicts with soft-float
         GENERIC_SRCS+=3D \
                 comparedf2.c \
                 ...
                 fixdfti.c \
                 ...
         .endif

 So one of these needs to be wired up, it seems -- either libgcc or
 compiler-rt.  Which one?  I have no idea what to prefer.

From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57022 CVS commit: pkgsrc/www/webkit-gtk
Date: Sun, 25 Sep 2022 08:57:51 +0000

 Module Name:	pkgsrc
 Committed By:	nia
 Date:		Sun Sep 25 08:57:51 UTC 2022

 Modified Files:
 	pkgsrc/www/webkit-gtk: Makefile

 Log Message:
 webkit-gtk: Set USE_PKGSRC_GCC_(RUNTIME) when building on NetBSD 9

 We likely need this anyway since WebKit requires GCC 8 at minimum,
 but forcing pkgsrc libgcc to be used (and thus bypassing the one
 built with the custom build system in NetBSD that doesn't include
 __fixdfti on aarch64) may be a useful workaround for PR toolchain/57022


 To generate a diff of this commit:
 cvs rdiff -u -r1.237 -r1.238 pkgsrc/www/webkit-gtk/Makefile

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

From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57022 CVS commit: src/lib/libc
Date: Wed, 5 Oct 2022 10:28:19 +0000

 Module Name:	src
 Committed By:	nia
 Date:		Wed Oct  5 10:28:19 UTC 2022

 Modified Files:
 	src/lib/libc/arch/aarch64/softfloat: qp.c
 	src/lib/libc/compiler_rt: Makefile.inc

 Log Message:
 libc: switch aarch64 to use softfloat functions from compiler_rt

 The old definitions in qp.c being all grouped together in one file
 causes problems when static linking with libgcc (i.e. cc --static-libgcc)
 due to functions like __trunctfdf2 conflicting with libgcc, as seen in
 PR 57021

 We can also add some missing functions like __fixdfti for converting
 a double to an int128_t, the lack of which is currently preventing webkit
 from linking on aarch64, as seen in PR 57022

 Unclear to me if libc is the right place for these functions, but
 we can avoid breaking compatibility right now and maintain the status
 quo while avoiding some obvious immediate problems.
 nm output for libc shows no functions being removed by this change.


 To generate a diff of this commit:
 cvs rdiff -u -r1.3 -r1.4 src/lib/libc/arch/aarch64/softfloat/qp.c
 cvs rdiff -u -r1.40 -r1.41 src/lib/libc/compiler_rt/Makefile.inc

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

From: "Nia Alarie" <nia@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57022 CVS commit: pkgsrc/www/webkit-gtk
Date: Sat, 8 Oct 2022 11:06:36 +0000

 Module Name:	pkgsrc
 Committed By:	nia
 Date:		Sat Oct  8 11:06:36 UTC 2022

 Modified Files:
 	pkgsrc/www/webkit-gtk: Makefile distinfo
 	pkgsrc/www/webkit-gtk/patches: patch-Source_cmake_OptionsCommon.cmake

 Log Message:
 webkit-gtk: Attempt to fix the build on NetBSD 9 aarch64 by avoiding
 the compiler builtin __int128_t implementation

 related to PR toolchain/57022


 To generate a diff of this commit:
 cvs rdiff -u -r1.238 -r1.239 pkgsrc/www/webkit-gtk/Makefile
 cvs rdiff -u -r1.171 -r1.172 pkgsrc/www/webkit-gtk/distinfo
 cvs rdiff -u -r1.6 -r1.7 \
     pkgsrc/www/webkit-gtk/patches/patch-Source_cmake_OptionsCommon.cmake

 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: nia@NetBSD.org
State-Changed-When: Sat, 22 Oct 2022 07:48:28 +0000
State-Changed-Why:
A workaround for webkit is available, I think we don't want to
pull up the actual fix because it'll break strict compatibility
along the netbsd-9 branch.


From: "Benny Siegert" <bsiegert@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57022 CVS commit: [pkgsrc-2022Q3] pkgsrc/www/webkit-gtk
Date: Sun, 23 Oct 2022 11:30:34 +0000

 Module Name:	pkgsrc
 Committed By:	bsiegert
 Date:		Sun Oct 23 11:30:34 UTC 2022

 Modified Files:
 	pkgsrc/www/webkit-gtk [pkgsrc-2022Q3]: Makefile distinfo
 	pkgsrc/www/webkit-gtk/patches [pkgsrc-2022Q3]:
 	    patch-Source_cmake_OptionsCommon.cmake

 Log Message:
 Pullup ticket #6687 - requested by nia
 www/webkit-gtk: aarch64 build fix

 Revisions pulled up:
 - www/webkit-gtk/Makefile                                       1.239
 - www/webkit-gtk/distinfo                                       1.172
 - www/webkit-gtk/patches/patch-Source_cmake_OptionsCommon.cmake 1.7

 ---
    Module Name:	pkgsrc
    Committed By:	nia
    Date:		Sat Oct  8 11:06:36 UTC 2022

    Modified Files:
    	pkgsrc/www/webkit-gtk: Makefile distinfo
    	pkgsrc/www/webkit-gtk/patches: patch-Source_cmake_OptionsCommon.cmake

    Log Message:
    webkit-gtk: Attempt to fix the build on NetBSD 9 aarch64 by avoiding
    the compiler builtin __int128_t implementation

    related to PR toolchain/57022


 To generate a diff of this commit:
 cvs rdiff -u -r1.238 -r1.238.2.1 pkgsrc/www/webkit-gtk/Makefile
 cvs rdiff -u -r1.171 -r1.171.2.1 pkgsrc/www/webkit-gtk/distinfo
 cvs rdiff -u -r1.6 -r1.6.4.1 \
     pkgsrc/www/webkit-gtk/patches/patch-Source_cmake_OptionsCommon.cmake

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2022 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.