From owner-svn-src-all@freebsd.org Sat Nov 2 16:59:54 2019 Return-Path: Delivered-To: svn-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 64EC41AC1D2; Sat, 2 Nov 2019 16:59:54 +0000 (UTC) (envelope-from dim@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4754zt21s1z3QBH; Sat, 2 Nov 2019 16:59:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0CF7F26620; Sat, 2 Nov 2019 16:59:54 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xA2Gxr5S048602; Sat, 2 Nov 2019 16:59:53 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xA2Gxrh1048600; Sat, 2 Nov 2019 16:59:53 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911021659.xA2Gxrh1048600@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 2 Nov 2019 16:59:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354255 - in head/lib: libc/gen msun/src X-SVN-Group: head X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in head/lib: libc/gen msun/src X-SVN-Commit-Revision: 354255 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 02 Nov 2019 16:59:54 -0000 Author: dim Date: Sat Nov 2 16:59:53 2019 New Revision: 354255 URL: https://svnweb.freebsd.org/changeset/base/354255 Log: Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from :1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 MFC after: 1 week Modified: head/lib/libc/gen/isnan.c head/lib/msun/src/math.h head/lib/msun/src/s_isnan.c Modified: head/lib/libc/gen/isnan.c ============================================================================== --- head/lib/libc/gen/isnan.c Sat Nov 2 15:08:19 2019 (r354254) +++ head/lib/libc/gen/isnan.c Sat Nov 2 16:59:53 2019 (r354255) @@ -43,6 +43,13 @@ */ #ifdef PIC +/* + * Because math.h defines __isnan and __isnanf as aliases for compatibility with + * glibc and CUDA, we have to undefine them here to avoid redefinition errors. + */ +#undef __isnan +#undef __isnanf + __weak_reference(__isnan, isnan); __weak_reference(__isnanf, isnanf); Modified: head/lib/msun/src/math.h ============================================================================== --- head/lib/msun/src/math.h Sat Nov 2 15:08:19 2019 (r354254) +++ head/lib/msun/src/math.h Sat Nov 2 16:59:53 2019 (r354255) @@ -215,6 +215,12 @@ __inline_isnanl(__const long double __x) } /* + * Define the following aliases, for compatibility with glibc and CUDA. + */ +#define __isnan __inline_isnan +#define __isnanf __inline_isnanf + +/* * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and * isinf() as functions taking double. C99, and the subsequent POSIX revisions * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating Modified: head/lib/msun/src/s_isnan.c ============================================================================== --- head/lib/msun/src/s_isnan.c Sat Nov 2 15:08:19 2019 (r354254) +++ head/lib/msun/src/s_isnan.c Sat Nov 2 16:59:53 2019 (r354255) @@ -45,6 +45,12 @@ isnan(double d) } #endif /* !PIC */ +/* + * Because math.h defines __isnanf as an alias for compatibility with glibc and + * CUDA, we have to undefine it here to avoid redefinition errors. + */ +#undef __isnanf + int __isnanf(float f) {