From owner-freebsd-hackers@freebsd.org Tue Jun 30 13:20:01 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3AF5B98F965 for ; Tue, 30 Jun 2015 13:20:01 +0000 (UTC) (envelope-from hans@beastielabs.net) Received: from testsoekris.hotsoft.nl (unknown [IPv6:2001:888:1227:0:200:24ff:fec9:5934]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EDD851963 for ; Tue, 30 Jun 2015 13:20:00 +0000 (UTC) (envelope-from hans@beastielabs.net) Received: from beastie.hotsoft.nl (beastie.hotsoft.nl [IPv6:2001:888:1227:0:219:d1ff:fee8:91eb]) by testsoekris.hotsoft.nl (8.14.7/8.14.7) with ESMTP id t5UDJubt070610; Tue, 30 Jun 2015 15:19:56 +0200 (CEST) (envelope-from hans@beastielabs.net) Message-ID: <5592977C.2030304@beastielabs.net> Date: Tue, 30 Jun 2015 15:19:56 +0200 From: Hans Ottevanger User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Marcin Cieslak CC: freebsd-hackers@freebsd.org Subject: Re: Build for profiling? Got //usr/lib/libc_p.a(sbrk.po): undefined reference to symbol '_end' References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2015 13:20:01 -0000 On 06/30/15 10:19, Marcin Cieslak wrote: > I am trying to compile https://github.com/sass/libsass instrumented > for profiling. As far as I understand this does not work with clang, > so I am trying with gcc version 4.8.5 20150212 (prerelease) > (FreeBSD Ports Collection). > Profiling with -pg was added to clang a few years ago by Roman Divacky, with a bit of my help. It is not (yet) documented AFAIK and don't know about the situation upstream. See also the mailing list thread starting here: https://lists.freebsd.org/pipermail/freebsd-toolchain/2011-January/000075.html > This is a shared library in C++ that gets loaded by node (www/node). > > I have a world built with profiling libraries, I have additionally > ran "make install INSTALL_PIC_ARCHIVE=yes" in lib/libc, lib/msun > and lib/libcxxrt directories (the latter probably not needed). > > Here's config.log output: > > configure:3344: checking whether the C++ compiler works > configure:3366: g++48 -pg -g conftest.cpp >&5 > /usr/local/bin/ld: //usr/lib/libc_p.a(sbrk.po): undefined reference to symbol '_end' > //lib/libc.so.7: error adding symbols: DSO missing from command line > collect2: error: ld returned 1 exit status > configure:3370: $? = 1 > configure:3408: result: no > configure: failed program was: > | /* confdefs.h */ > | #define PACKAGE_NAME "libsass" > | #define PACKAGE_TARNAME "libsass" > | #define PACKAGE_VERSION "3.2.5-9-gbe07-dirty" > | #define PACKAGE_STRING "libsass 3.2.5-9-gbe07-dirty" > | #define PACKAGE_BUGREPORT "support@moovweb.com" > | #define PACKAGE_URL "" > | #define PACKAGE "libsass" > | #define VERSION "3.2.5-9-gbe07-dirty" > | /* end confdefs.h. */ > | > | int > | main () > | { > | > | ; > | return 0; > | } > Maybe adding an extra -lc_p helps. Keep in mind that time spent in libraries that are dynamically linked will not turn up in your profile. If I want profiling results from the standard libraries I explicitly link (statically, because they are .a archives) with the profiled libs, e.g. using -lc++_p -lm_p -lc_p (with clang). Kind regards, Hans Ottevanger Eindhoven, Netherlands www.beastielabs.net