delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1999/08/13/23:44:58

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-developers-unsubscribe-archive-cygwin-developers=delorie DOT com AT sourceware DOT cygnus DOT com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sourceware DOT cygnus DOT com>
List-Help: <mailto:cygwin-developers-help AT sourceware DOT cygnus DOT com>,
<http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com
Message-Id: <199908140344.WAA10729@mercury.xraylith.wisc.edu>
To: cygwin-developers AT sourceware DOT cygnus DOT com
Subject: changing profiling in Cygwin
Date: Fri, 13 Aug 1999 22:44:21 -0500
From: Mumit Khan <khan AT xraylith DOT wisc DOT EDU>

The current code to do profiling has a few quirks that I'd like to fix, but 
there is a small timing issue with gcc and cygwin releases.

Here's how profiling works on a typical OS: you specify -pg, gcc links in
gcrt0.o as the first object file; gcrt0.o will normally invoke monstartup
at program startup, either via .init section if available or some other
means such as OS specific global constructor mechanism. It'll also provide 
a way to call mcleanup at termination. GCC doesn't need to do anything.

Cygwin profiling works in subtly different way -- gcrt0 doesn't use .init
since it's not available under win32 as such, and to call monstartup at
startup, GCC emits a call to monstartup when it compiles a function named
"main". This has some problems -- it only works when you do have main() 
that you yourself compiled; this loses for g77 for example where main() 
comes precompiled in a library; loses for windows applications that don't
have a user "main"; also you lose all the profiling from global 
constructors in C++.

I propose the following simple solution (and I have a working prototype
of course): undo GCC change to look for "main", and instead use 
constructor/destructor function attributes in GCC to kick off monstartup
at startup and mcleanup at termination.

This solution is clean, but it implies that Cygwin and GCC releases are
perfectly timed, which is unreasonable to expect. To fix this, we can
add a switch -mold-profile to be used with -pg to use Cygwin's current 
scheme and -pg alone will use the new scheme. Eventually, we'll deprecate 
-mold-profile and then remove it in due time.

Comments?

Regards,
Mumit

- Raw text -


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