From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31960 invoked by alias); 23 Apr 2012 18:03:25 -0000 Received: (qmail 31951 invoked by uid 22791); 23 Apr 2012 18:03:24 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Apr 2012 18:03:12 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3NI3B5p031360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Apr 2012 14:03:11 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3NI3Aga029134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 23 Apr 2012 14:03:10 -0400 From: Tom Tromey To: Pedro Alves Cc: Jan Kratochvil , gdb@sourceware.org Subject: Re: Will therefore GDB utilize C++ or not? References: <20120330161403.GA17891@host2.jankratochvil.net> <87aa2rjkb8.fsf@fleche.redhat.com> <4F832D5B.9030308@redhat.com> <87d374pzqt.fsf@fleche.redhat.com> Date: Mon, 23 Apr 2012 18:03:00 -0000 In-Reply-To: <87d374pzqt.fsf@fleche.redhat.com> (Tom Tromey's message of "Wed, 18 Apr 2012 14:10:50 -0600") Message-ID: <87ehrefhr5.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.95 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-04/txt/msg00187.txt.bz2 Tom> I think this relies on the idea that the C++ runtime dependency is Tom> unavoidably very heavy. And, in earlier discussions on the Archer list, Tom> I agreed with this idea without giving it too much thought. Tom> But, that seems to me to be an empirical question. We could measure the Tom> impact. Today I built gdbserver a number of different ways. In particular, I applied a few hacks, disabled all warnings, and used -fpermissive, so that I could build it with g++ as well. I'm appending my script, I can send the various hacks too if anybody needs them. They were trivial though. Here's the results. I did all builds on an x86-64 F16 box. For g++ I used -static-libstdc++; though it shouldn't pull in very much right now. I used a trunk gcc from today, since F16 doesn't apparently package libstdc++.a, but earlier runs with the system compiler were roughly similar. I threw in -fexceptions since I was curious what would happen. 344064 g++ -O2 331776 gcc -fexceptions -O2 331776 gcc -O2 311296 g++ -flto -O2 303104 g++ -Os 303104 gcc -flto -fexceptions -O2 303104 gcc -flto -O2 290816 gcc -fexceptions -Os 290816 gcc -Os 278528 g++ -flto -Os 270336 gcc -flto -fexceptions -Os 270336 gcc -flto -Os First, clearly, if you care about size you should be using -flto -Os. This is a clear win. Our default of -O2 is much worse. Second, g++ induces very little bloat on the current code base. It is about 3%. Now, I realize this is not necessarily indicative of the ultimate size increase. "Zero-cost" exceptions do in fact have a cost in the size of the executable. I failed to easily build an SJLJ compiler, so I didn't try to do any measurements of this. This process did discover a bad "return 1" in the middle of ax.c:gdb_eval_agent_expr. I think it should return expr_eval_unrecognized_opcode. Tom #!/bin/sh for comp in gcc g++; do if test $comp = gcc; then cc=$comp compflags= else cc='g++ -fpermissive' compflags='LDFLAGS=-static-libstdc++' fi for base in '' -flto; do for exc in '' -fexceptions; do if test $comp = g++ && test x$exc = x-fexceptions; then continue fi for opts in -O2 -Os; do echo ================================================================ flags=$(echo $base $exc $opts) echo ===== $flags echo make clean-local make CC="$cc" CFLAGS="$flags" WARN_CFLAGS= WERROR_CFLAGS= $compflags gdbserver f2=$(echo $comp $flags | sed -e 's/ /_/g') cp gdbserver gdbserver-$f2 done done done done