My favorites | Sign in
Logo
                
Search
for
Updated Mar 21, 2008 by thomasvl
TigerGcov  
Using gcov with Xcode 3 and Tiger.

Introduction

Normally to get code coverage working in Xcode, you turn on some flags and link to gcov (see CoverStory for a UI to gcov). Unfortunately it's not quite so easy using Xcode 3 if you want to link with the 10.4.sdk. The flags work fine, but the libgcov.a library does not. Fear not though, as there is an answer.

Details

We're being stymied by the following issues in Xcode 3 (and 3.1):

  1. Xcode 3 ignores the -isysroot option for .a files, and goes straight to /usr/lib/... for the .a files.
  2. Radar 5707772 - Xcode does not respect -isysroot setting when linking .a files
  3. The version of libgcov.a compiled in the MacOS10.4u.sdk that shipped with Xcode 3, links to symbols that aren't in the MacOS10.4u.sdk. Specifically _fcntl$UNIX2003, _open$UNIX2003, and _close$UNIX2003.
  4. Radar 5707470 - gcov broken with MacOS10.4.u.sdk

To fix this we include a fat version of the Tiger libgcov.a in TigerGcov (or you can download it directly from downloads). When the linker sees this version, it will link to it instead of the bad version in /usr/lib and then you will be able to run your app on both Tiger and Leopard. When Apple fixes these issues we can hopefully remove all this garbage and everything will be good.

Just make sure to add the path to this folder into the OTHER_LDFLAGS setting for your xcode target/project. You can see a demonstration of this in the debug-gcov config of the Google Toolbox for Mac target.

Please be aware that libgcov is covered under the following license:

Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
   2000, 2001, 2002, 2003, 2004, 2005  Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2, or (at your option) any later
version.

In addition to the permissions in the GNU General Public License, the
Free Software Foundation gives you unlimited permission to link the
compiled version of this file into combinations with other programs,
and to distribute those combinations without any restriction coming
from the use of this file.  (The General Public License restrictions
do apply in other respects; for example, they cover modification of
the file, and distribution when not linked into a combine
executable.)

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING.  If not, write to the Free
Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.

Sign in to add a comment