From owner-svn-src-head@freebsd.org Fri Aug 4 01:52:13 2017 Return-Path: Delivered-To: svn-src-head@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 B4B59DBDF5F; Fri, 4 Aug 2017 01:52:13 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail106.syd.optusnet.com.au (mail106.syd.optusnet.com.au [211.29.132.42]) by mx1.freebsd.org (Postfix) with ESMTP id 7A699747CE; Fri, 4 Aug 2017 01:52:12 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail106.syd.optusnet.com.au (Postfix) with ESMTPS id E77823C2246; Fri, 4 Aug 2017 11:35:16 +1000 (AEST) Date: Fri, 4 Aug 2017 11:35:16 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Joerg Sonnenberger cc: Bruce Evans , Ngie Cooper , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r321969 - in head/sys/boot: arm/at91/libat91 arm/ixp425/boot2 i386/boot2 In-Reply-To: <20170803124627.GB2734@britannica.bec.de> Message-ID: <20170804111543.V1186@besplex.bde.org> References: <201708030527.v735R5dg041043@repo.freebsd.org> <20170803173421.C2203@besplex.bde.org> <20170803124627.GB2734@britannica.bec.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=VbSHBBh9 c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=nW5l7S2qks2DyJoO6NEA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 01:52:13 -0000 On Thu, 3 Aug 2017, Joerg Sonnenberger wrote: > On Thu, Aug 03, 2017 at 05:53:43PM +1000, Bruce Evans wrote: >> Freestanding versions (static and otherwise) cause problems with builtins. >> -ffreestanding turns off all builtins. The static memcpy used to be >> ifdefed so as to use __builtin_memcpy instead of the static one if the >> compiler is gcc. That apparently broke with gcc-4.2, since the builtin >> will call libc memcpy() in some cases, although memcpy() is unavailable >> in the freestanding case. > > GCC always had a requirement that freestanding environment must provide > certain functions (memcpy, memmove, memset, memcmp). At least memcpy and > memset are regulary used for certain code constructs. While most calls > will be inlined, it is not required. I had forgotten about that bug. boot2 doesn't have many fancy code constructs, but it might have struct copying and gcc uses memcpy for copying large structs. clang-4.0 has the same bug. Testing showed 1 bug nearby: for newer CPUs, it generates large code with several movups's for small struct copies. The bug is that -Os doesn't turn this off. But boot2 uses -march=i386 which does turn this off. For not so new CPUs like core2 where movups is slower than movaps but movaps is unusable because the structs might not be aligned, it normally generates large code with moves through integer registers, but -Os works to turn this off. The change for gcc-4.2 was apparently to support this. The static memcpy is not quite compatible, but is close enough and you can check this in the generated code. The problem is that it should be re-checked for every change in the source code and compiler. Bruce