From nobody@FreeBSD.org  Tue Jul 19 21:57:40 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 12D99106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jul 2011 21:57:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 026268FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jul 2011 21:57:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p6JLvdNV048399
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 19 Jul 2011 21:57:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p6JLvdR7048398;
	Tue, 19 Jul 2011 21:57:39 GMT
	(envelope-from nobody)
Message-Id: <201107192157.p6JLvdR7048398@red.freebsd.org>
Date: Tue, 19 Jul 2011 21:57:39 GMT
From: Alex Samorukov <samm@os2.kiev.ua>
To: freebsd-gnats-submit@FreeBSD.org
Subject: dtrace library is linked with a wrong flags on -CURRENT
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         159046
>Category:       kern
>Synopsis:       [dtrace] [patch] dtrace library is linked with a wrong flags on -CURRENT
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    rwatson
>State:          patched
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jul 19 22:00:20 UTC 2011
>Closed-Date:    
>Last-Modified:  Mon Nov 28 22:40:09 UTC 2011
>Originator:     Alex Samorukov
>Release:        9.0-CURRENT
>Organization:
netart
>Environment:
FreeBSD test9.local 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Tue Jul 19 22:51:31 CEST 2011     root@test9.local:/usr/obj/usr/src/sys/DTRACE  amd64

>Description:
/usr/src/cddl/lib/drti/Makefile contain correct $PICFLAG to link drti.o with -fpic. The problem is that this macros is not defined, because wrong include is used: bsd.prog.mk instead of bsd.lib.mk (where this macros is defined). 

>How-To-Repeat:
try to build userland dtrace app on 9-CURRENT. It will fail:

usr/bin/ld: php.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC

>Fix:
--- Makefile.orig       2011-07-19 23:53:43.000000000 +0200
+++ Makefile    2011-07-19 23:56:32.000000000 +0200
@@ -18,4 +18,4 @@
                -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \
                -DPIC ${PICFLAG}
 
-.include <bsd.prog.mk>
+.include <bsd.lib.mk>


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->rwatson 
Responsible-Changed-By: rwatson 
Responsible-Changed-When: Wed Jul 20 17:12:27 UTC 2011 
Responsible-Changed-Why:  
Claim ownership of this PR; I've had my hands in userspace DTrace. 

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

From: Scott Lystig Fritchie <slfritchie@snookles.com>
To: bug-followup@FreeBSD.org, samm@os2.kiev.ua
Cc:  
Subject: Re: kern/159046: [dtrace] [patch] dtrace library is linked with a wrong flags on -CURRENT
Date: Sat, 26 Nov 2011 14:08:06 -0600

 Hi, I would like to chime in with an "I agree" for the fix that Alex
 proposed for this ticket.  If the details of Alex's fix aren't
 sufficient, I humbly ask & hope that a workaround is available & applied
 in time for 9.0-RELEASE.
 
 Background: I've been working on adding USDT probes to the Erlang
 virtual machine.  Using FreeBSD 9.0RC1 and 9.0RC2, I've had no problems
 creating USDT probes for the VM itself but a big problem with creating a
 USDT probe for use in a shared library.
 
 The probe definition is quite simple, as is the compilation recipe.  It
 all works well under Solaris 10.  With the FreeBSD 9.0 release
 candidates, things go bad at build time in the "make" output shown
 below.  dtrace.c is a small piece of glue code required for the Erlang
 virtual machine and is compiled with -fPIC.  The output of "dtrace -G",
 dtrace_user.o, apparently is not created PIC-style?
 
     gcc -c -o ../priv/obj/x86_64-unknown-freebsd9.0/dtrace.o -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement  -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -g -O2 -fPIC [various -I flags omitted] dtrace.c
     dtrace -G -C \
       -s ./dtrace_user.d \
       -o ../priv/obj/x86_64-unknown-freebsd9.0/dtrace_user.o ../priv/obj/x86_64-unknown-freebsd9.0/dtrace.o
     gcc -shared -o ../priv/lib/x86_64-unknown-freebsd9.0/dtrace.so ../priv/obj/x86_64-unknown-freebsd9.0/dtrace.o ../priv/obj/x86_64-unknown-freebsd9.0/dtrace_user.o 
     /usr/bin/ld: ../priv/obj/x86_64-unknown-freebsd9.0/dtrace_user.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
     ../priv/obj/x86_64-unknown-freebsd9.0/dtrace_user.o: could not read symbols: Bad value
     gmake[4]: *** [../priv/lib/x86_64-unknown-freebsd9.0/dtrace.so] Error 1
 
 I retried building this piece of code after:
 
     * Installing FreeBSD 9.0RC2
     * Configuring a 64-bit AMD kernel for using DTRACE, install, reboot
     * After applying the 1 line patch suggested by Alex in this PR
     * Do the "make buildworld", reboot, mergemaster, etc. dance
     * Rebuild Erlang
 
 Make used the same sequence of gcc -c, dtrace -G, and gcc -shared
 commands, but without error this time.  And the USDT probe inside that
 shared library works correctly.
 
 -Scott

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/159046: commit references a PR
Date: Mon, 28 Nov 2011 10:01:47 +0000 (UTC)

 Author: rwatson
 Date: Mon Nov 28 10:01:36 2011
 New Revision: 228057
 URL: http://svn.freebsd.org/changeset/base/228057
 
 Log:
   Change the Makefile in cddl/lib/drti to use bsd.lib.mk instead of
   bsd.prog.mk -- we need to compile PIC, which requires a library build.
   With this change, USDT (userspace DTrace probes) work from within
   shared libraries.
   
   PR:		kern/159046
   Submitted by:	Alex Samorukov <samm at os2.kiev.ua>
   Comments by:	Scott Lystig Fritchie <slfritchie at snookles.com>
   MFC after:	3 days
 
 Modified:
   head/cddl/lib/drti/Makefile
 
 Modified: head/cddl/lib/drti/Makefile
 ==============================================================================
 --- head/cddl/lib/drti/Makefile	Mon Nov 28 09:54:41 2011	(r228056)
 +++ head/cddl/lib/drti/Makefile	Mon Nov 28 10:01:36 2011	(r228057)
 @@ -18,4 +18,4 @@ CFLAGS+=	-I${.CURDIR}/../../../sys/cddl/
  		-I${OPENSOLARIS_SYS_DISTDIR}/uts/common \
  		-DPIC ${PICFLAG}
  
 -.include <bsd.prog.mk>
 +.include <bsd.lib.mk>
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: rwatson 
State-Changed-When: Mon Nov 28 10:11:26 UTC 2011 
State-Changed-Why:  
Patch committed to 10-CURRENT; I will wait the normal 3-day timeout and then 
request MFCs to stable/9 and releng/9.0.  It would be quite useful if someone 
could confirm that USDT with libraries "just works" with 10.x as of today, so 
that we can have confidence that 9.0 will ship with this working. 

Sorry about the long delay in getting this committed -- I've been rather 
over-committed for the past few months but am attempting to catch up! 



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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/159046: commit references a PR
Date: Mon, 28 Nov 2011 15:09:46 +0000 (UTC)

 Author: rwatson
 Date: Mon Nov 28 15:09:31 2011
 New Revision: 228073
 URL: http://svn.freebsd.org/changeset/base/228073
 
 Log:
   Merge r228057 from head to stable/9:
   
     Change the Makefile in cddl/lib/drti to use bsd.lib.mk instead of
     bsd.prog.mk -- we need to compile PIC, which requires a library build.
     With this change, USDT (userspace DTrace probes) work from within
     shared libraries.
   
     PR:             kern/159046
     Submitted by:   Alex Samorukov <samm at os2.kiev.ua>
     Comments by:    Scott Lystig Fritchie <slfritchie at snookles.com>
   
   Approved by:	re (xxx)
 
 Modified:
   stable/9/cddl/lib/drti/Makefile
 Directory Properties:
   stable/9/cddl/lib/drti/   (props changed)
 
 Modified: stable/9/cddl/lib/drti/Makefile
 ==============================================================================
 --- stable/9/cddl/lib/drti/Makefile	Mon Nov 28 14:58:51 2011	(r228072)
 +++ stable/9/cddl/lib/drti/Makefile	Mon Nov 28 15:09:31 2011	(r228073)
 @@ -18,4 +18,4 @@ CFLAGS+=	-I${.CURDIR}/../../../sys/cddl/
  		-I${OPENSOLARIS_SYS_DISTDIR}/uts/common \
  		-DPIC ${PICFLAG}
  
 -.include <bsd.prog.mk>
 +.include <bsd.lib.mk>
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/159046: commit references a PR
Date: Mon, 28 Nov 2011 22:32:10 +0000 (UTC)

 Author: rwatson
 Date: Mon Nov 28 22:30:19 2011
 New Revision: 228107
 URL: http://svn.freebsd.org/changeset/base/228107
 
 Log:
   Merge r228057 from head to releng/9.0:
   
     Change the Makefile in cddl/lib/drti to use bsd.lib.mk instead of
     bsd.prog.mk -- we need to compile PIC, which requires a library build.
     With this change, USDT (userspace DTrace probes) work from within
     shared libraries.
   
     PR:             kern/159046
     Submitted by:   Alex Samorukov <samm at os2.kiev.ua>
     Comments by:    Scott Lystig Fritchie <slfritchie at snookles.com>
   
   Approved by:	re (bz)
 
 Modified:
   releng/9.0/cddl/lib/drti/Makefile
 Directory Properties:
   releng/9.0/cddl/lib/drti/   (props changed)
 
 Modified: releng/9.0/cddl/lib/drti/Makefile
 ==============================================================================
 --- releng/9.0/cddl/lib/drti/Makefile	Mon Nov 28 22:24:22 2011	(r228106)
 +++ releng/9.0/cddl/lib/drti/Makefile	Mon Nov 28 22:30:19 2011	(r228107)
 @@ -18,4 +18,4 @@ CFLAGS+=	-I${.CURDIR}/../../../sys/cddl/
  		-I${OPENSOLARIS_SYS_DISTDIR}/uts/common \
  		-DPIC ${PICFLAG}
  
 -.include <bsd.prog.mk>
 +.include <bsd.lib.mk>
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
