From owner-freebsd-questions@FreeBSD.ORG Tue Jun 19 14:44:16 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D7B3E106566B for ; Tue, 19 Jun 2012 14:44:16 +0000 (UTC) (envelope-from talon@lpthe.jussieu.fr) Received: from shiva.jussieu.fr (shiva.jussieu.fr [134.157.0.129]) by mx1.freebsd.org (Postfix) with ESMTP id 12FA98FC18 for ; Tue, 19 Jun 2012 14:44:15 +0000 (UTC) Received: from parthe.lpthe.jussieu.fr (parthe.lpthe.jussieu.fr [134.157.10.1]) by shiva.jussieu.fr (8.14.4/jtpda-5.4) with ESMTP id q5JEhg79064260 ; Tue, 19 Jun 2012 16:43:55 +0200 (CEST) X-Ids: 168 Received: from [192.168.1.10] (niobe.lpthe.jussieu.fr [134.157.10.41]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by parthe.lpthe.jussieu.fr (Postfix) with ESMTPSA id 0B7D51FF61; Tue, 19 Jun 2012 16:43:36 +0200 (CEST) From: Michel Talon Content-Type: multipart/signed; boundary="Apple-Mail=_22F47BFB-6755-4DB6-BF8A-8A64170FE97B"; protocol="application/pkcs7-signature"; micalg=sha1 Date: Tue, 19 Jun 2012 16:43:31 +0200 Message-Id: <402199FE-380B-41B6-866B-7D5D66C457D5@lpthe.jussieu.fr> To: FreeBSD Questions Mime-Version: 1.0 (Apple Message framework v1278) X-Mailer: Apple Mail (2.1278) X-Miltered: at jchkmail.jussieu.fr with ID 4FE0901E.000 by Joe's j-chkmail (http : // j-chkmail dot ensmp dot fr)! X-j-chkmail-Enveloppe: 4FE0901E.000/134.157.10.1/parthe.lpthe.jussieu.fr/parthe.lpthe.jussieu.fr/ X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Wojciech Puchar , David Brodbeck Subject: Re: Why Clang X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Jun 2012 14:44:16 -0000 --Apple-Mail=_22F47BFB-6755-4DB6-BF8A-8A64170FE97B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 David Brodbeck said: > Another way of looking at it is after 25 years of optimization GCC is > unable to beat a new compiler that's had almost none... Unfortunately this affirmation is blatantly false, recent gcc produce = code much faster than clang. I give here an example which i like, a monte = carlo computation for a spin lattice. Everything runs on my macbook. lilas% clang -v Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM = 3.0svn) Target: x86_64-apple-darwin11.4.0 lilas% clang -O4 test.c -lf2c lilas% time ./a.out ... real 0m2.359s user 0m2.341s sys 0m0.003s lilas% /usr/local/bin/gcc -v =85 gcc version 4.6.1 (GCC) lilas% /usr/local/bin/gcc -O3 test.c -lf2c lilas% time ./a.out =85 real 0m1.241s user 0m1.234s sys 0m0.003s So gcc gives an executable running twice faster than clang, basically, = when both compilers are run at maximal optimization. To show the effectiveness of the = optimizer, here is the running time without any optimization: lilas% /usr/local/bin/gcc test.c -lf2c lilas% time ./a.out =85 real 0m6.895s user 0m6.889s sys 0m0.005s What this demonstrates is that for programs which do real computations, = optimization is *very* important, and gcc is now very good (i have not shown the numbers = but they match the Intel compiler) while clang is at the level gcc was ten years ago. So i fully agree with = Wojciech Puchar, the move to clang is only driven by anti GPL propaganda which is frankly completely = stupid, since in any events, gcc does not contaminate the binaries it produces (except when using = contaminated accompanying libraries e.g. for C++). Of course, when compiling FreeBSD kernel or similar = programs which do little computation there is no harm using clang. I suspect that the price is higher for = programs like mencoder which require the highest efficiency. I will not comment on the better error messages coming from clang, this = could be a more serious argument. -- Michel Talon talon@lpthe.jussieu.fr --Apple-Mail=_22F47BFB-6755-4DB6-BF8A-8A64170FE97B--