www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2001/12/24/10:14:10

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f
Sender: rich AT phekda DOT freeserve DOT co DOT uk
Message-ID: <3C2721D9.48915EAE@phekda.freeserve.co.uk>
Date: Mon, 24 Dec 2001 12:38:49 +0000
From: Richard Dawe <rich AT phekda DOT freeserve DOT co DOT uk>
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.19 i586)
X-Accept-Language: de,fr
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: Building a profiled version of libc
References: <200112021239 DOT NAA08303 AT lws256 DOT lu DOT erisoft DOT se>
Reply-To: djgpp-workers AT delorie DOT com

Hello.

Martin Stromberg wrote:
> Ok. What if we have gcc-profile.opt and gcc-noprofile.opt and let
> "make" do "cp gcc-profile.opt gcc.opt; make clean; make; cp
> gcc-noprofile.opt gcc.opt; make clean; make;"? Or add a target
> "profile" that builds a profiling libc or something like that?

It might be cleaner to add something like this to src/makefile.inc:

    PROFILE ?= 0

    ifeq ($(PROFILE), 1)
    PROFILE_CFLAGS=-pg
    endif

and then use PROFILE_GCCOPTS in the XGCC, etc. rules, e.g.:

XGCC = $(CROSS_GCC) $(GCC_OPT) -I. -I- -isystem $(TOP)/../../include
$(CFLAGS)
$(PROFILE_CFLAGS)
XLGCC = $(CROSS_GCC) $(GCCL_OPT) -I. -I- -isystem $(TOP)/../../include
$(CFLAGS) $(PROFILE_CFLAGS)

We can't just add -pg to CFLAGS, because we don't want the non-profiling
gcc compile to use -pg:

XNOPGGCC = $(CROSS_GCC) $(shell sed -f $(TOP)/../noprof.sed
$(TOP)/../gcc.opt) -I. -I- -isystem $(TOP)/../../include $(CFLAGS)

With this you could get a profiling library like so:

    cd src; make clean && make PROFILE=1

Another choice is to choose the options file depending on the setting of
PROFILE. I think this approach may be better, because then all compiler
options would be taken from files, rather than being modified by
environment variables. E.g.:

    ifeq ($(PROFILE),1)
    GCC_OPT_FILE=gcc-pg.opt
    else
    GCC_OPT_FILE=gcc.opt
    endif

    GCCL_OPT_FILE=gcc-l.opt

and replace all uses of $(TOP)/../gcc*.opt with the appropriate variable.

Bye, Rich =]

-- 
Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ]

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019