From owner-dev-commits-src-all@freebsd.org Tue Mar 9 20:23:10 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A5A0156F267; Tue, 9 Mar 2021 20:23:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dw68t4My5z4vpG; Tue, 9 Mar 2021 20:23:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8902722711; Tue, 9 Mar 2021 20:23:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 129KNAwA069015; Tue, 9 Mar 2021 20:23:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 129KNAKt069014; Tue, 9 Mar 2021 20:23:10 GMT (envelope-from git) Date: Tue, 9 Mar 2021 20:23:10 GMT Message-Id: <202103092023.129KNAKt069014@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: e91ff79b2811 - stable/12 - Build lib/msun tests with compiler builtins disabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e91ff79b2811798a70826fe43a2fb7cb006f3fa1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Mar 2021 20:23:10 -0000 The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=e91ff79b2811798a70826fe43a2fb7cb006f3fa1 commit e91ff79b2811798a70826fe43a2fb7cb006f3fa1 Author: Dimitry Andric AuthorDate: 2021-02-23 20:03:32 +0000 Commit: Dimitry Andric CommitDate: 2021-03-09 20:18:43 +0000 Build lib/msun tests with compiler builtins disabled This forces the compiler to emit calls to libm functions, instead of possibly substituting pre-calculated results at compile time, which should help to actually test those functions. Reviewed by: emaste, arichardson, ngie Differential Revision: https://reviews.freebsd.org/D28577 (cherry picked from commit cf97d2a1dab8f2cddc4466fe64d37818339c73be) riscv: Add a soft-float implementation of fabs() We could just use a C implementation using __builtin_fabs(), but using this assembly version guarantees that there is no additional prolog/epilog code. Additionally, clang generates worse code for masking off the top bit than GCC: https://bugs.llvm.org/show_bug.cgi?id=49377. This fixes the RISCV64 softfloat world build after cf97d2a1dab8. That commit added -fno-builtin to the msun tests which resulted in the first references to fabs (previously the compiler inlined all calls). Reviewed By: dim Reported by: mjg Differential Revision: https://reviews.freebsd.org/D28994 (cherry picked from commit 524b018d200408bed5eb0d2b892db5b9fb46808b) riscv: Fix whitespace issues in fabs added in 524b018d2004 (cherry picked from commit 066dab17e7a4a78d43dbcef8119960ddc8090a73) --- lib/libc/riscv/gen/fabs.S | 11 +++++++++-- lib/msun/tests/Makefile | 4 ++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/libc/riscv/gen/fabs.S b/lib/libc/riscv/gen/fabs.S index 44249252e9c1..036d50eddf90 100644 --- a/lib/libc/riscv/gen/fabs.S +++ b/lib/libc/riscv/gen/fabs.S @@ -1,5 +1,6 @@ /*- * Copyright (c) 2015-2017 Ruslan Bukin + * Copyright (c) 2021 Alex Richardson * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -10,6 +11,9 @@ * Computer Laboratory as part of the CTSRD Project, with support from the * UK Higher Education Innovation Fund (HEIF). * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -35,9 +39,12 @@ #include __FBSDID("$FreeBSD$"); -#ifdef __riscv_float_abi_double ENTRY(fabs) +#ifdef __riscv_float_abi_double fabs.d fa0, fa0 +#else + slli a0, a0, 1 + srli a0, a0, 1 +#endif ret END(fabs) -#endif diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile index cd60f7c71a15..91d32517143f 100644 --- a/lib/msun/tests/Makefile +++ b/lib/msun/tests/Makefile @@ -18,6 +18,10 @@ CFLAGS+= -I${TESTSRC:H}/libc/gen CFLAGS+= -D__HAVE_LONG_DOUBLE .endif +# Avoid builtins, to force the compiler to emit calls to the libm +# functions, and not calculate any results in advance. +CFLAGS+= -fno-builtin + NETBSD_ATF_TESTS_C= acos_test NETBSD_ATF_TESTS_C+= asin_test NETBSD_ATF_TESTS_C+= atan_test