From Nehal@shaw.ca  Mon Nov 29 19:38:19 2004
Return-Path: <Nehal@shaw.ca>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8A33916A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Nov 2004 19:38:19 +0000 (GMT)
Received: from shaw.ca (S0106000ae6ceb225.vf.shawcable.net [70.68.12.33])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 43AF943D4C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Nov 2004 19:38:19 +0000 (GMT)
	(envelope-from Nehal@shaw.ca)
Received: from Nehal.Home (somebody@localhost [127.0.0.1])
	by shaw.ca (8.13.1/8.13.1) with ESMTP id iATJcXbW022816
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 29 Nov 2004 11:38:33 -0800 (PST)
	(envelope-from Nehal@Nehal.Home)
Received: (from Nehal@localhost)
	by Nehal.Home (8.13.1/8.13.1/Submit) id iATJcX0o022815;
	Mon, 29 Nov 2004 11:38:33 -0800 (PST)
	(envelope-from Nehal)
Message-Id: <200411291938.iATJcX0o022815@Nehal.Home>
Date: Mon, 29 Nov 2004 11:38:33 -0800 (PST)
From: Nehal <nehalmistry@gmx.net>
Reply-To: Nehal <nehalmistry@gmx.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: gcc doesn't link correctly if -pg specified
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         74531
>Category:       gnu
>Synopsis:       gcc doesn't link correctly if -pg specified
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 29 19:40:03 GMT 2004
>Closed-Date:    Mon Aug 16 13:29:17 UTC 2010
>Last-Modified:  Mon Aug 16 13:29:17 UTC 2010
>Originator:     Nehal Mistry
>Release:        FreeBSD 5.3-RELEASE i386
>Organization:
>Environment:
System: FreeBSD Nehal.Home 5.3-RELEASE FreeBSD 5.3-RELEASE #0: Fri Nov 5 04:19:18 UTC 2004 root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386


	
>Description:
compiling the attached test normally with:
    gcc prof_test.c `sdl11-config --cflags --libs`
works fine. but if you want to add profiling support with:
    gcc -pg prof_test.c `sdl11-config --cflags --libs`
it will give a bunch of linking errors. adding '-lc' will 
fix the linking errors, but will core dump when run because of
the linking order. adding '-lpthread -lc' is the only way to 
have it link and run without any problems.

i believe this is a bug, i don't see how profiling should
change the behaviour of linking.
	
>How-To-Repeat:
try to compile the attached test with:
gcc -pg prof_test.c `sdl11-config --cflags --libs`
	
>Fix:

	

--- prof_test.c begins here ---

#include "SDL11/SDL.h"

int main()
{
    SDL_Init(SDL_INIT_TIMER);

    return 0;
}
--- prof_test.c ends here ---


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: gavin 
State-Changed-When: Wed Jun 13 13:08:45 UTC 2007 
State-Changed-Why:  
Have asked for feedback 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74531 

From: Gavin Atkinson <gavin@FreeBSD.org>
To: bug-followup@FreeBSD.org
Cc: Nehal <nehalmistry@gmx.net>
Subject: Re: gnu/74531: gcc doesn't link correctly if -pg specified
Date: Wed, 13 Jun 2007 14:08:37 +0100

 The example in the PR still fails in the same way on RELENG_6.  I don't
 know if what the submitter wants to do is valid though.
 
 To submitter: Did you ever get to the bottom of this?

From: Nehal Mistry <nehalmistry@gmx.net>
To: Gavin Atkinson <gavin@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: gnu/74531: gcc doesn't link correctly if -pg specified
Date: Wed, 13 Jun 2007 10:27:33 -0700

 No unfortunately. I couldn't figure it out. It isn't a big deal so 
 I just worked around it.
 
 However I'm not sure how the command can become invalid by simply 
 adding the -pg flag. And it only happens for this particular test.
State-Changed-From-To: feedback->open 
State-Changed-By: gavin 
State-Changed-When: Thu Jul 5 17:38:07 UTC 2007 
State-Changed-Why:  
Feedback was received 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74531 
State-Changed-From-To: open->closed 
State-Changed-By: vwe 
State-Changed-When: Mon Aug 16 13:26:31 UTC 2010 
State-Changed-Why:  
This wasn't a gcc bug, but a runtime library bug. I'm sure it's been fixed for RELENG_7 between 7.1-R and 7.2-R and for 8-CURRENT (and up) as I was experiencing the same. 
If somebody need some deeper insight, it would take me 2 hours to find the commit that fixed this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74531 
>Unformatted:
