NetBSD Problem Report #58326

From www@netbsd.org  Sun Jun  9 14:23:23 2024
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)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits)
	 client-signature RSA-PSS (2048 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id E8BBF1A9238
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  9 Jun 2024 14:23:22 +0000 (UTC)
Message-Id: <20240609142321.BF2991A923A@mollari.NetBSD.org>
Date: Sun,  9 Jun 2024 14:23:21 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: hppa libm is missing fma(3)
X-Send-Pr-Version: www-1.0

>Number:         58326
>Notify-List:    tsutsui@NetBSD.org
>Category:       port-hppa
>Synopsis:       hppa libm is missing fma(3)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-hppa-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jun 09 14:25:00 +0000 2024
>Closed-Date:    Sat Sep 20 07:04:28 +0000 2025
>Last-Modified:  Sat Sep 20 07:04:28 +0000 2025
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetBSD/hppa Fmadation
>Environment:
>Description:
libm on hppa is missing the fma(3) fused multiply-add functions.  They're not defined as static inlines or builtins by the header file and they're not defined as symbols in libm.
>How-To-Repeat:
$ cat fma.c
#include <math.h>
#include <stdio.h>

volatile double x = 3, y = 4, z = 5;

int
main(void)
{

	printf("%a\n", fma(x, y, z));
	fflush(stdout);
	return ferror(stdout);
}
$ /home/riastradh/netbsd/current/obj.hppa/tooldir/bin/hppa--netbsd-gcc -g -O2 --sysroot=/home/riastradh/netbsd/current/obj.hppa/destdir.hppa   -o fma fma.c 
/home/riastradh/netbsd/current/obj.hppa/tooldir/bin/../lib/gcc/hppa--netbsd/10.5.0/../../../../hppa--netbsd/bin/ld: /tmp/riastradh/ccczEczb.o: in function `main':
/tmp/riastradh/fma.c:10: undefined reference to `fma'
collect2: error: ld returned 1 exit status

>Fix:
Yes, please!

Probably just a matter of adding

COMMON_SRCS+=	s_fma.c s_fmaf.c s_fmal.c

to src/lib/libm/Makefile but we should also have some automatic tests for fma to verify it worked.

>Release-Note:

>Audit-Trail:
From: Taylor R Campbell <riastradh@NetBSD.org>
To: gnats-bugs@netbsd.org, netbsd-bugs@NetBSD.org
Cc: 
Subject: Re: port-hppa/58326: hppa libm is missing fma(3)
Date: Sun, 9 Jun 2024 15:05:01 +0000

 Looks like PA-RISC 1.1 doesn't have a fused multiply-add instruction,
 just a confusing FMPYADD which does a multiply and an add at the same
 time but on unrelated inputs, so we'll have to use the portable C
 versions.  (PA-RISC 2.0 has FMPYFADD.)

State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Wed, 19 Feb 2025 00:24:17 +0000
State-Changed-Why:
Fixed in HEAD by the following commit.  Committer requested pullup, but
note that we usually build packages against x.0 (e.g., 10.0) so it won't
help to fix the usual TNF build of packages that require fma.

Module Name:    src
Committed By:   tsutsui
Date:           Sat Feb 15 09:00:38 UTC 2025

Modified Files:
        src/lib/libm: Makefile

Log Message:
libm: Add missing fma(3) and variants for hppa.

Fixes a build error on pkgsrc/lang/python312. Ok'ed by skrll@.
Should be pulled up to netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.240 -r1.241 src/lib/libm/Makefile


Module Name:    src
Committed By:   tsutsui
Date:           Sat Feb 15 10:47:52 UTC 2025

Modified Files:
        src/lib/libm: m.hppa.expsym

Log Message:
libm: Also add fma(3) and variants to expected symbols for hppa.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libm/m.hppa.expsym


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: riastradh@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: port-hppa/58326 (hppa libm is missing fma(3))
Date: Thu, 20 Feb 2025 01:32:40 +0900

 > State-Changed-Why:
 > Fixed in HEAD by the following commit.  Committer requested pullup, but
 > note that we usually build packages against x.0 (e.g., 10.0) so it won't
 > help to fix the usual TNF build of packages that require fma.

 (Un)fortunately there is no TNF build of hppa binary packages:
  https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/

 Building ninja on qemu running NetBSD/hppa 10.1 seems to have
 some problems, so we need a real build machine for it.

 ---
 Izumi Tsutsui

State-Changed-From-To: needs-pullups->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Sat, 20 Sep 2025 07:04:28 +0000
State-Changed-Why:
pull up done.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.