From owner-freebsd-arm@freebsd.org Wed Jan 11 16:01:52 2017 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8BB8CAB6DD for ; Wed, 11 Jan 2017 16:01:52 +0000 (UTC) (envelope-from rj@obsigna.com) Received: from mo6-p00-ob.smtp.rzone.de (mo6-p00-ob.smtp.rzone.de [IPv6:2a01:238:20a:202:5300::12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.smtp.rzone.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6A1971753 for ; Wed, 11 Jan 2017 16:01:52 +0000 (UTC) (envelope-from rj@obsigna.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1484150509; l=2566; s=domk; d=obsigna.com; h=In-Reply-To:To:References:Date:Subject:Mime-Version: Content-Transfer-Encoding:Content-Type:From; bh=BeisFHtTT7QbdykmwUMzZyIwG/XTXb81IHVnUyfx6LY=; b=j1nllA2GWoFcZqSugTBBFqROJAoepjFpWtwAum29/5b8/QEwIxQLXSJ7MuXZqMaYiH iDLqo5mXudiSr9NdGAApgwaIjQW5bXSmIIvBxcZ18ggfBxatfo6BMs/aWYlpvabUYskL OlJaTSGIBWPzYQwAXMNLvKW0VhXfPHFNjA8mk= X-RZG-AUTH: :O2kGeEG7b/pS1EK7WHa0hxqKZr4lnx6UhT0M0o35iAdWtoM07Gt3wQHFGhIh99LgMA== X-RZG-CLASS-ID: mo00 Received: from mail.obsigna.com (bb02ac17.virtua.com.br [187.2.172.23]) by smtp.strato.de (RZmta 39.11 DYNA|AUTH) with ESMTPSA id f08668t0BG1m85m (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate) for ; Wed, 11 Jan 2017 17:01:48 +0100 (CET) Received: from rolf.projectworld.net (rolf.projectworld.net [192.168.222.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.obsigna.com (Postfix) with ESMTPSA id 23E957506D97 for ; Wed, 11 Jan 2017 14:01:46 -0200 (BRST) From: "Dr. Rolf Jansen" Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.2 \(3259\)) Subject: Re: clang on armv6 incorrectly emits call to sincos() Date: Wed, 11 Jan 2017 14:01:45 -0200 References: To: freebsd-arm@freebsd.org In-Reply-To: Message-Id: <5DC099EB-CF9D-4BFB-9AA7-D53DF50B8064@obsigna.com> X-Mailer: Apple Mail (2.3259) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2017 16:01:52 -0000 > Am 11.01.2017 um 12:42 schrieb Jia-Shiun Li : >=20 > Hi all, >=20 > I was looking into build failure after graphviz been updated to = 2.40.1. On > amd64 it builds fine. But on armv6 aka rpi2 when linking, it = complained > about undefined reference to sincos. [1] >=20 > Turns out it was not graphviz but clang. >=20 > When compling with -ffast-math, clang folds adjancent calls to sin() = and > cos() into one call to sincos(), which FreeBSD does not have. Thus the > linking error. A minimal example source file is provided in [2]. = Commands > [3], and my environment. [4] >=20 > Think this optimization should be turned off for armv6 from base > clang/llvm, instead of patching individual ports or ports = infrastructure. > Or is it possibly due to crosscompiling world? I haven't tried if = natively > built world works. Ideas? I ran into the same issue when porting my software to armv6 (BeagleBone = Black). Since FreeBSD is missing many math functions, I anyway need to keep a = libm supplement for FreeBSD around. So, leaving -ffast-math in place, I = simply added to the supplement implementation:=20 #pragma mark =E2=80=A2=E2=80=A2=E2=80=A2 Implementation of Missing Math = Functions in FreeBSD =E2=80=A2=E2=80=A2=E2=80=A2 #ifdef __FreeBSD__ ... #elif defined(__arm__) void sincos(double x, double *rsin, double *rcos) { *rsin =3D sin(x); *rcos =3D cos(x); } #endif #endif My Header file of my libm FreeBSD supplement got: #ifdef __FreeBSD__ ... #elif defined(__arm__) // long double is double #define erfl(x) erf(x) #define powl(x,y) pow(x,y) #define tgammal(x) tgamma(x) #define csinl(z) csin(z) #define casinl(z) casin(z) #define ccosl(z) ccos(z) #define cacosl(z) cacos(z) #define ctanl(z) ctan(z) #define catanl(z) catan(z) #define cexpl(z) cexp(z) #define csinhl(z) csinh(z) #define casinhl(z) casinh(z) #define ccoshl(z) ccosh(z) #define cacoshl(z) cacosh(z) #define ctanhl(z) ctanh(z) #define catanhl(z) catanh(z) static inline long double complex cpowl(long double complex x, = long double complex y) { return cpow(x, y); } static inline long double complex clogl(long double complex z) { return clog(z); } #endif #endif I assume that for the FreeBSD project it is much easier to complete libm = instead of asking the upstream LLVM/clang project for rewriting the = optimizing behaviour, which may have unknown implications to many other = projects as well. Best regards Rolf