From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org) by nuthatch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1FyRmk-0007Qe-Qp for garchives@archives.gentoo.org; Thu, 06 Jul 2006 11:12:43 +0000 Received: from robin.gentoo.org (localhost [127.0.0.1]) by robin.gentoo.org (8.13.7/8.13.6) with SMTP id k66BAMJT002299; Thu, 6 Jul 2006 11:10:22 GMT Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.180]) by robin.gentoo.org (8.13.7/8.13.6) with ESMTP id k66B3UUS014172 for ; Thu, 6 Jul 2006 11:03:31 GMT Received: by py-out-1112.google.com with SMTP id d42so2504152pyd for ; Thu, 06 Jul 2006 04:03:29 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=pdxl3gdO7gRpJt91bVafsD57tnkBbnDHamEQpu3Ww8K/vKHElb2PeV2co9ry72duJBD4YJtWlm1jayXscTlCQeGV+8kEnGIOgGK7mHGvLfNbDdecBC9f9oyu2CA8bmYAGEaEBhN1n5JU82Bj3FTPi+pd6au0O0B+876JuorzhUs= Received: by 10.35.88.18 with SMTP id q18mr692130pyl; Thu, 06 Jul 2006 04:03:29 -0700 (PDT) Received: by 10.35.130.14 with HTTP; Thu, 6 Jul 2006 04:03:29 -0700 (PDT) Message-ID: Date: Thu, 6 Jul 2006 13:03:29 +0200 From: "Ioannis Aslanidis" To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] Replacing cpu-feature USE flags In-Reply-To: <200607061252.33028@enterprise.flameeyes.is-a-geek.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Disposition: inline References: <200607061252.33028@enterprise.flameeyes.is-a-geek.org> X-MIME-Autoconverted: from base64 to 8bit by robin.gentoo.org id k66B3UUS014172 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by robin.gentoo.org id k66BAMLJ002299 X-Archives-Salt: 21b5bb03-da31-4db2-a2fb-6594201fcedd X-Archives-Hash: 6fb2311d120055cc067d086431d12805 Thought: I like it :) On 7/6/06, Diego 'Flameeyes' Petten=C3=B2 wrote: > So, I've been drafting this up in my blog[1], and it is a simple way to > replace the CPU feature useflags. Let's try to summarise: > > Right now we have mmx, 3dnow, 3dnowex, sse, sse2 and so on useflags pre= sent in > the tree, almost never used to get new dependencies, but usually used t= o > supply econf switches. > > This works as long as the user enable the flags, but for AMD64 the stor= y was, > until now, that we simply enabled them when they worked, because we had= some > minimum support available. Unfortunately this became a problem with the > introduction of nocona, because that is an amd64-like system but with n= o > 3dnow. And there is the problem that sse3 is supported only in later ve= rsions > of Athlon64 and so on. > > To try to clean up this mess, and to make it simpler to work in > cross-compilation, I thought of using the definitions created by the C > Preprocessor (CPP) by default for the given CFLAGS. Basically when > using -march=3Dathlon64, the preprocessor will enable a few definitions= that > tells the availability of MMX, 3dNOW, SSE and so on... if we wrap that > around, we can use it to know if it's the case of enabling something or= not. > This is customisable by the user by setting the CFLAGS themselves. If o= ne does > not want MMX instructions to be generated, but still want the rest of > Athlon64 optimisations, it's simply the matter of > using "-march=3Dathlon64 -mno-mmx". > > So, rather than the functions proposed in [1], I've sampled today the > following function: > > has_cpuset() { > local def hasfeat > > while [[ -n $1 ]]; do > case $1 in > mmx) > def=3D"__MMX__" ;; > 3dnow) > def=3D"__3dNOW__" ;; > 3dnowex) > def=3D"__3dNOW_A__" ;; > sse) > def=3D"__SSE__" ;; > sse2) > def=3D"__SSE2__" ;; > sse3) > def=3D"__SSE3__" ;; > altivec) > def=3D"__ALTIVEC__" ;; > *) > ewarn "Instruction set $1 not supported." > die "Instruction set not supported." > esac > > echo | $(tc-getCC) ${CFLAGS} -dM -E - 2>/dev/null | grep -q ${de= f} || > hasfeat=3D"no" > shift > done > > if [[ ${hasfeat} =3D=3D "no" ]]; then > return 1 > else > return 0 > fi > } > > that can be tested easily with the following code: > > yesno() { > if "$@"; then > echo "yes" > else > echo "no" > fi > } > > echo "Does it have 3dnow mmx sse2?" > yesno has_cpuset 3dnow mmx sse2 > echo "Does it have mmx sse sse3?" > yesno has_cpuset mmx sse sse3 > echo "Does it have altivec?" > yesno has_cpuset altivec > > > Note that you need to set your CFLAGS corretly or it will, by default,= tell > you that everything is disabled. > > Thoughts? Comments? > > SPARC team: I'd like to know if VIS does a similar thing, would make si= mpler > for instance its handling in xine-lib ebuild. > > [1] > http://farragut.flameeyes.is-a-geek.org/articles/2006/06/24/crazy-idea-= an-alternative-to-cpu-features-useflags > -- > Diego "Flameeyes" Petten=C3=B2 - http://farragut.flameeyes.is-a-geek.or= g/ > Gentoo/Alt lead, Gentoo/FreeBSD, Video, AMD64, Sound, PAM, KDE > > > --=20 Ioannis Aslanidis 0xB9B11F4E --=20 gentoo-dev@gentoo.org mailing list