<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Building profiling version of allegro fails with undefined reference to mcount</title>
		<link>http://www.allegro.cc/forums/view/614254</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Fri, 23 May 2014 12:04:48 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I wanted to try and figure out why bitmap locking is so dreadfully slow in OpenGL on my laptop but I can&#39;t build the profiling version of allegro due to undefined references to mcount. </p><p>I believe both the source modules and the library need to be linked with -pg for this to work correctly. I don&#39;t know where to look in the cmake files to fix this though. Any ideas?</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span><span class="c">/* ... */</span>
<span class="number">  2</span>
<span class="number">  3</span>Linking CXX shared library lib\allegro_monolith-profile-5.1.dll
<span class="number">  4</span>Creating library file: lib\liballegro_monolith-profile.dll.a
<span class="number">  5</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>allegro.c.obj<span class="k2">)</span><span class="k2">:</span>allegro.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x4</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number">  6</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x16): undefined reference to `mcount'</span>
<span class="number">  7</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>bitmap.c.obj<span class="k2">)</span><span class="k2">:</span>bitmap.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x7</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number">  8</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x183): undefined reference to `mcount'</span>
<span class="number">  9</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>bitmap.c.obj<span class="k2">)</span><span class="k2">:</span>bitmap.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x1f7</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number"> 10</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x4ef): more undefined references to `mcount'</span> follow
<span class="number"> 11</span>collect2: ld returned <span class="n">1</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a> status
<span class="number"> 12</span>mingw32-make<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">:</span> <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>lib<span class="k3">/</span>allegro_monolith-profile-5.1.dll<span class="k2">]</span> Error <span class="n">1</span>
<span class="number"> 13</span>mingw32-make<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">:</span> <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>CMakeFiles<span class="k3">/</span>allegro_monolith.dir<span class="k3">/</span>all<span class="k2">]</span> Error <span class="n">2</span>
<span class="number"> 14</span>mingw32-make: <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>all<span class="k2">]</span> Error <span class="n">2</span>
<span class="number"> 15</span>
<span class="number"> 16</span>c:\mingw\LIBS\A5GIT\allegro\build&gt;
</div></div><p>
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 14 May 2014 10:36:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is a Profile build type. Did you try it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 14 May 2014 21:12:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sorry, yes. I should have mentioned the cmake parameters I used :</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">  1</span>c:\ctwoplus\progcode\allegro5&gt;cd %a5git%
<span class="number">  2</span>
<span class="number">  3</span>c:\mingw\LIBS\A5GIT\allegro\build&gt;cmake <span class="k3">-</span>G <span class="s">"MinGW Makefiles"</span> <span class="k3">-</span>DSHARED<span class="k3">=</span>On <span class="k3">-</span>DCMAKE_BUILD_TYPE<span class="k3">=</span>Profile <span class="k3">-</span>DWANT_DOCS<span class="k3">=</span>Off <span class="k3">-</span>DWANT_DEMO<span class="k3">=</span>Off <span class="k3">-</span>DWANT_EXAMPLES<span class="k3">=</span>Off <span class="k3">-</span>DWANT_MONOLITH<span class="k3">=</span>On ..
<span class="number">  4</span><span class="k3">-</span><span class="k3">-</span> Using MINGDIR: C:<span class="k3">/</span>mingw
<span class="number">  5</span><span class="k3">-</span><span class="k3">-</span> Allowing GCC<span class="k3">/</span>Clang to use SSE instructions
<span class="number">  6</span><span class="k3">-</span><span class="k3">-</span> Could NOT find PkgConfig <span class="k2">(</span>missing:  PKG_CONFIG_EXECUTABLE<span class="k2">)</span>
<span class="number">  7</span><span class="k3">-</span><span class="k3">-</span> Could NOT find OPENSL <span class="k2">(</span>missing:  OPENSL_INCLUDE_DIR OPENSL_LIBRARY<span class="k2">)</span>
<span class="number">  8</span>WARNING: Dynamic loading will be disabled <span class="k1">for</span> FLAC as <span class="k1">static</span> library was found: C:<span class="k3">/</span>mingw<span class="k3">/</span>lib<span class="k3">/</span>libFLAC.a
<span class="number">  9</span>WARNING: Dynamic loading will be disabled <span class="k1">for</span> DUMB as <span class="k1">static</span> library was found: C:<span class="k3">/</span>mingw<span class="k3">/</span>lib<span class="k3">/</span>libdumb.a
<span class="number"> 10</span><span class="k3">-</span><span class="k3">-</span> DLL name <span class="k1">for</span> C:<span class="k3">/</span>mingw<span class="k3">/</span>lib<span class="k3">/</span>libvorbisfile.dll.a: libvorbisfile-3.dll
<span class="number"> 11</span><span class="k3">-</span><span class="k3">-</span> Configuring done
<span class="number"> 12</span><span class="k3">-</span><span class="k3">-</span> Generating done
<span class="number"> 13</span><span class="k3">-</span><span class="k3">-</span> Build files have been written to: C:<span class="k3">/</span>mingw<span class="k3">/</span>LIBS<span class="k3">/</span>A5GIT<span class="k3">/</span>allegro<span class="k3">/</span>build
<span class="number"> 14</span>
<span class="number"> 15</span>c:\mingw\LIBS\A5GIT\allegro\build&gt;mingw32-make
<span class="number"> 16</span><span class="k2">[</span>  <span class="n">0</span>%<span class="k2">]</span> Building C object CMakeFiles<span class="k3">/</span>allegro_monolith.dir<span class="k3">/</span>src<span class="k3">/</span>allegro.c.obj
<span class="number"> 17</span>
<span class="number"> 18</span><span class="c">/*...*/</span>
<span class="number"> 19</span>
<span class="number"> 20</span><span class="k2">[</span> <span class="n">99</span>%<span class="k2">]</span> Building C object CMakeFiles<span class="k3">/</span>allegro_monolith.dir<span class="k3">/</span>addons<span class="k3">/</span>main<span class="k3">/</span>generic_main.c.obj
<span class="number"> 21</span>Linking CXX shared library lib\allegro_monolith-profile-5.1.dll
<span class="number"> 22</span>Creating library file: lib\liballegro_monolith-profile.dll.a
<span class="number"> 23</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>allegro.c.obj<span class="k2">)</span><span class="k2">:</span>allegro.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x4</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number"> 24</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x16): undefined reference to `mcount'</span>
<span class="number"> 25</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>bitmap.c.obj<span class="k2">)</span><span class="k2">:</span>bitmap.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x7</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number"> 26</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x183): undefined reference to `mcount'</span>
<span class="number"> 27</span>CMakeFiles\allegro_monolith.dir<span class="k3">/</span>objects.a<span class="k2">(</span>bitmap.c.obj<span class="k2">)</span><span class="k2">:</span>bitmap.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x1f7</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `mcount<span class="s">'</span>
<span class="number"> 28</span><span class="s">CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x4ef): more undefined references to `mcount'</span> follow
<span class="number"> 29</span>collect2: ld returned <span class="n">1</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_298.html" target="_blank">exit</a> status
<span class="number"> 30</span>mingw32-make<span class="k2">[</span><span class="n">2</span><span class="k2">]</span><span class="k2">:</span> <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>lib<span class="k3">/</span>allegro_monolith-profile-5.1.dll<span class="k2">]</span> Error <span class="n">1</span>
<span class="number"> 31</span>mingw32-make<span class="k2">[</span><span class="n">1</span><span class="k2">]</span><span class="k2">:</span> <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>CMakeFiles<span class="k3">/</span>allegro_monolith.dir<span class="k3">/</span>all<span class="k2">]</span> Error <span class="n">2</span>
<span class="number"> 32</span>mingw32-make: <span class="k3">*</span><span class="k3">*</span><span class="k3">*</span> <span class="k2">[</span>all<span class="k2">]</span> Error <span class="n">2</span>
<span class="number"> 33</span>
<span class="number"> 34</span>c:\mingw\LIBS\A5GIT\allegro\build&gt;
</div></div><p>

Yeah, I also tried it without the monolith and it fails the same way.</p><p>Edit<br />I looked through CMakeLists.txt and I found this :
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
</p><div class="source-code"><div class="toolbar"><span class="name">CMakeLists.txt</span><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 393</span><span class="p"># Profiling.</span>
<span class="number"> 394</span>
<span class="number"> 395</span>list<span class="k2">(</span>APPEND CMAKE_BUILD_CONFIGURATIONS Profile<span class="k2">)</span>
<span class="number"> 396</span><span class="k1">if</span><span class="k2">(</span>COMPILER_GCC_OR_CLANG<span class="k2">)</span>
<span class="number"> 397</span>    set<span class="k2">(</span>CMAKE_C_FLAGS_PROFILE <span class="s">"-pg"</span>
<span class="number"> 398</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 399</span>    set<span class="k2">(</span>CMAKE_CXX_FLAGS_PROFILE <span class="s">"${CMAKE_C_FLAGS_PROFILE}"</span>
<span class="number"> 400</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 401</span>    set<span class="k2">(</span>CMAKE_EXE_LINKER_FLAGS_PROFILE <span class="s">"-pg"</span>
<span class="number"> 402</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 403</span>    mark_as_advanced<span class="k2">(</span>
<span class="number"> 404</span>        CMAKE_C_FLAGS_PROFILE
<span class="number"> 405</span>        CMAKE_CXX_FLAGS_PROFILE
<span class="number"> 406</span>        CMAKE_EXE_LINKER_FLAGS_PROFILE
<span class="number"> 407</span>        <span class="k2">)</span>
<span class="number"> 408</span>endif<span class="k2">(</span>COMPILER_GCC_OR_CLANG<span class="k2">)</span>
</div></div><p>
</p></div></div><p>
It sets a flag for the source modules and for the linker so I&#39;m not sure what is wrong. Perhaps the library needs a separate linker parameter in cmake?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 14 May 2014 22:21:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There is a separate linker flag for shared libs iirc.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 14 May 2014 22:31:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>From<br /><a href="http://www.cmake.org/pipermail/cmake/2011-December/048040.html">http://www.cmake.org/pipermail/cmake/2011-December/048040.html</a>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
On 12/12/2011 09:00 PM, Robert Dailey wrote:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> I need a version of CMAKE_EXE_LINKER_FLAGS for shared libraries. I need<br /> to specify /NODEFAULTLIB for a shared library (DLL) that I&#39;m building,<br /> but it doesn&#39;t seem that CMAKE_EXE_LINKER_FLAGS is used by shared<br /> library projects generated by CMake for visual studio.<br /> <br /> Any suggestions?<br /> </p></div></div><p>Use CMAKE_SHARED_LINKER_FLAGS. Strangely, this family of variables is<br />missing from the docs...</p><p>Michael
</p></div></div><p>

So we need to use CMAKE_SHARED_LINKER_FLAGS somewhere? Like in the profiling section above? cmake confuses me. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 14 May 2014 22:55:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Pretty much yeah.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 14 May 2014 23:13:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/614254/1000736#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> so we need to use CMAKE_SHARED_LINKER_FLAGS somewhere? Like in the profiling section above? cmake confuses me. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p></div></div><p>You should use CMAKE_SHARED_LINKER_FLAGS instead of CMAKE_EXE_LINKER_FLAGS.</p><p>Try to use the CMAKE_VERBOSE_MAKEFILE option so we see the <i>actual</i> link command passed to the command line (warning: LOTS of text).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Thu, 15 May 2014 01:14:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You could just pass: VERBOSE=1 to make. if you want to see the commands make runs.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Thu, 15 May 2014 04:19:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I think it does just the same....but I&#39;ll try it out <img src="http://www.allegro.cc/forums/smileys/grin.gif" alt=";D" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Thu, 15 May 2014 11:23:05 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/614254/1000739#target">pkrcel</a> said:</div><div class="quote"><p>
You should use CMAKE_SHARED_LINKER_FLAGS instead of CMAKE_EXE_LINKER_FLAGS.
</p></div></div><p>
I would assume we still need CMAKE_EXE_LINKER_FLAGS though, as the examples and demos would all need to be linked with -pg.</p><p>I got it to build by changing the above section from CMakeLists.txt to the below :
</p><div class="source-code"><div class="toolbar"><span class="name">CMakeLists.txt</span><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 393</span><span class="p"># Profiling.</span>
<span class="number"> 394</span>
<span class="number"> 395</span>list<span class="k2">(</span>APPEND CMAKE_BUILD_CONFIGURATIONS Profile<span class="k2">)</span>
<span class="number"> 396</span><span class="k1">if</span><span class="k2">(</span>COMPILER_GCC_OR_CLANG<span class="k2">)</span>
<span class="number"> 397</span>    set<span class="k2">(</span>CMAKE_C_FLAGS_PROFILE <span class="s">"-pg"</span>
<span class="number"> 398</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 399</span>    set<span class="k2">(</span>CMAKE_CXX_FLAGS_PROFILE <span class="s">"${CMAKE_C_FLAGS_PROFILE}"</span>
<span class="number"> 400</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 401</span>    set<span class="k2">(</span>CMAKE_EXE_LINKER_FLAGS_PROFILE <span class="s">"-pg"</span>
<span class="number"> 402</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 403</span>    set<span class="k2">(</span>CMAKE_SHARED_LINKER_FLAGS_PROFILE <span class="s">"-pg"</span>
<span class="number"> 404</span>        CACHE STRING <span class="s">"profiling flags"</span><span class="k2">)</span>
<span class="number"> 405</span>    mark_as_advanced<span class="k2">(</span>
<span class="number"> 406</span>        CMAKE_C_FLAGS_PROFILE
<span class="number"> 407</span>        CMAKE_CXX_FLAGS_PROFILE
<span class="number"> 408</span>        CMAKE_EXE_LINKER_FLAGS_PROFILE
<span class="number"> 409</span>        CMAKE_SHARED_LINKER_FLAGS_PROFILE
<span class="number"> 410</span>        <span class="k2">)</span>
<span class="number"> 411</span>endif<span class="k2">(</span>COMPILER_GCC_OR_CLANG<span class="k2">)</span>
</div></div><p>

I kept CMAKE_EXE_LINKER_FLAGS_PROFILE and added CMAKE_SHARED_LINKER_FLAGS_PROFILE as -pg and added it to the mark_as_advanced section below (I have no idea what that does).</p><p>Everything seems to build fine, all the demo, examples and library worked fine. When run, the exe&#39;s produce gmon.out like they&#39;re supposed to but gprof is giving me some messed up results, and doesn&#39;t even include the allegro functions in the profile, which I can&#39;t explain. I&#39;m trying to upgrade my compiler as we speak, prob won&#39;t finish til tomorrow though.</p><p>Yeah, the output from gprof is not making any sense at all. For example, I ran ex_threads and then ran gprof on it :</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number">   1</span>Flat profile:
<span class="number">   2</span>
<span class="number">   3</span>Each sample counts as <span class="n">0</span>.<span class="n">01</span> seconds.
<span class="number">   4</span> no <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> accumulated
<span class="number">   5</span>
<span class="number">   6</span>  %   cumulative   self              self     total           
<span class="number">   7</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a>   seconds   seconds    calls  Ts<span class="k3">/</span>call  Ts<span class="k3">/</span>call  name    
<span class="number">   8</span>  <span class="n">0</span>.<span class="n">00</span>      <span class="n">0</span>.<span class="n">00</span>     <span class="n">0</span>.<span class="n">00</span>    <span class="n">26797</span>     <span class="n">0</span>.<span class="n">00</span>     <span class="n">0</span>.<span class="n">00</span>  log_printf
<span class="number">   9</span>
<span class="number">  10</span> %         the percentage of the total running <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> of the
<span class="number">  11</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a>       program used by <span class="k1">this</span> function.
<span class="number">  12</span>
<span class="number">  13</span>cumulative a running sum of the number of seconds accounted
<span class="number">  14</span> seconds   <span class="k1">for</span> by <span class="k1">this</span> function <span class="k1">and</span> those listed above it.
<span class="number">  15</span>
<span class="number">  16</span> self      the number of seconds accounted <span class="k1">for</span> by <span class="k1">this</span>
<span class="number">  17</span>seconds    function alone.  This is the major sort <span class="k1">for</span> <span class="k1">this</span>
<span class="number">  18</span>           listing.
<span class="number">  19</span>
<span class="number">  20</span>calls      the number of <a href="http://www.delorie.com/djgpp/doc/libc/libc_822.html" target="_blank">times</a> <span class="k1">this</span> function was invoked, <span class="k1">if</span>
<span class="number">  21</span>           <span class="k1">this</span> function is profiled, <span class="k1">else</span> blank.
<span class="number">  22</span> 
<span class="number">  23</span> self      the average number of milliseconds spent in <span class="k1">this</span>
<span class="number">  24</span>ms<span class="k3">/</span>call    function per call, <span class="k1">if</span> <span class="k1">this</span> function is profiled,
<span class="number">  25</span>     <span class="k1">else</span> blank.
<span class="number">  26</span>
<span class="number">  27</span> total     the average number of milliseconds spent in <span class="k1">this</span>
<span class="number">  28</span>ms<span class="k3">/</span>call    function <span class="k1">and</span> its descendents per call, <span class="k1">if</span> <span class="k1">this</span> 
<span class="number">  29</span>     function is profiled, <span class="k1">else</span> blank.
<span class="number">  30</span>
<span class="number">  31</span>name       the name of the function.  This is the minor sort
<span class="number">  32</span>           <span class="k1">for</span> <span class="k1">this</span> listing. The <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> shows the location of
<span class="number">  33</span>     the function in the gprof listing. If the <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> is
<span class="number">  34</span>     in parenthesis it shows where it would appear in
<span class="number">  35</span>     the gprof listing <span class="k1">if</span> it were to be printed.
<span class="number">  36</span>
<span class="number">  37</span>         Call graph <span class="k2">(</span>explanation follows<span class="k2">)</span>
<span class="number">  38</span>
<span class="number">  39</span>
<span class="number">  40</span>granularity: each sample hit covers <span class="n">4</span> byte<span class="k2">(</span>s<span class="k2">)</span> no <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> propagated
<span class="number">  41</span>
<span class="number">  42</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> % <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a>    self  children    called     name
<span class="number">  43</span>                <span class="n">0</span>.<span class="n">00</span>    <span class="n">0</span>.<span class="n">00</span>     <span class="n">279</span><span class="k3">/</span><span class="n">26797</span>       animate_square <span class="k2">[</span><span class="n">140</span><span class="k2">]</span>
<span class="number">  44</span>                <span class="n">0</span>.<span class="n">00</span>    <span class="n">0</span>.<span class="n">00</span>    <span class="n">2109</span><span class="k3">/</span><span class="n">26797</span>       gen_square <span class="k2">[</span><span class="n">154</span><span class="k2">]</span>
<span class="number">  45</span>                <span class="n">0</span>.<span class="n">00</span>    <span class="n">0</span>.<span class="n">00</span>   <span class="n">24409</span><span class="k3">/</span><span class="n">26797</span>       thread_func <span class="k2">[</span><span class="n">177</span><span class="k2">]</span>
<span class="number">  46</span><span class="k2">[</span><span class="n">2</span><span class="k2">]</span>      <span class="n">0</span>.<span class="n">0</span>    <span class="n">0</span>.<span class="n">00</span>    <span class="n">0</span>.<span class="n">00</span>   <span class="n">26797</span>         log_printf <span class="k2">[</span><span class="n">2</span><span class="k2">]</span>
<span class="number">  47</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span><span class="k3">-</span>
<span class="number">  48</span>
<span class="number">  49</span> This table describes the call tree of the program, <span class="k1">and</span> was sorted by
<span class="number">  50</span> the total amount of <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> spent in each function <span class="k1">and</span> its children.
<span class="number">  51</span>
<span class="number">  52</span> Each entry in <span class="k1">this</span> table consists of several lines.  The <a href="http://www.allegro.cc/manual/line"><span class="a">line</span></a> with the
<span class="number">  53</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> number at the left hand margin lists the current function.
<span class="number">  54</span> The lines above it list the functions that called <span class="k1">this</span> function,
<span class="number">  55</span> <span class="k1">and</span> the lines below it list the functions <span class="k1">this</span> one called.
<span class="number">  56</span> This <a href="http://www.allegro.cc/manual/line"><span class="a">line</span></a> lists:
<span class="number">  57</span>     <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>  A unique number given to each element of the table.
<span class="number">  58</span>    Index numbers are sorted numerically.
<span class="number">  59</span>    The <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> number is printed next to every function name so
<span class="number">  60</span>    it is easier to look up where the function in the table.
<span class="number">  61</span>
<span class="number">  62</span>     % <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a>  This is the percentage of the `total<span class="s">' time that was spent</span>
<span class="number">  63</span><span class="s">    in this function and its children.  Note that due to</span>
<span class="number">  64</span><span class="s">    different viewpoints, functions excluded by options, etc,</span>
<span class="number">  65</span><span class="s">    these numbers will NOT add up to 100%.</span>
<span class="number">  66</span><span class="s"></span>
<span class="number">  67</span><span class="s">     self  This is the total amount of time spent in this function.</span>
<span class="number">  68</span><span class="s"></span>
<span class="number">  69</span><span class="s">     children  This is the total amount of time propagated into this</span>
<span class="number">  70</span><span class="s">    function by its children.</span>
<span class="number">  71</span><span class="s"></span>
<span class="number">  72</span><span class="s">     called  This is the number of times the function was called.</span>
<span class="number">  73</span><span class="s">    If the function called itself recursively, the number</span>
<span class="number">  74</span><span class="s">    only includes non-recursive calls, and is followed by</span>
<span class="number">  75</span><span class="s">    a `+'</span> <span class="k1">and</span> the number of recursive calls.
<span class="number">  76</span>
<span class="number">  77</span>     name  The name of the current function.  The <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> number is
<span class="number">  78</span>    printed after it.  If the function is a member of a
<span class="number">  79</span>    cycle, the cycle number is printed between the
<span class="number">  80</span>    function<span class="s">'s name and the index number.</span>
<span class="number">  81</span><span class="s"></span>
<span class="number">  82</span><span class="s"></span>
<span class="number">  83</span><span class="s"> For the function'</span>s parents, the fields have the following meanings:
<span class="number">  84</span>
<span class="number">  85</span>     self  This is the amount of <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> that was propagated directly
<span class="number">  86</span>    from the function into <span class="k1">this</span> parent.
<span class="number">  87</span>
<span class="number">  88</span>     children  This is the amount of <a href="http://www.delorie.com/djgpp/doc/libc/libc_821.html" target="_blank">time</a> that was propagated from
<span class="number">  89</span>    the function<span class="s">'s children into this parent.</span>
<span class="number">  90</span><span class="s"></span>
<span class="number">  91</span><span class="s">     called  This is the number of times this parent called the</span>
<span class="number">  92</span><span class="s">    function `/'</span> the total number of <a href="http://www.delorie.com/djgpp/doc/libc/libc_822.html" target="_blank">times</a> the function
<span class="number">  93</span>    was called.  Recursive calls to the function are <span class="k1">not</span>
<span class="number">  94</span>    included in the number after the `<span class="k3">/</span><span class="s">'.</span>
<span class="number">  95</span><span class="s"></span>
<span class="number">  96</span><span class="s">     name  This is the name of the parent.  The parent'</span>s <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a>
<span class="number">  97</span>    number is printed after it.  If the parent is a
<span class="number">  98</span>    member of a cycle, the cycle number is printed between
<span class="number">  99</span>    the name <span class="k1">and</span> the <a href="http://www.delorie.com/djgpp/doc/libc/libc_470.html" target="_blank">index</a> number.
<span class="number"> 100</span>
<span class="number"> 101</span> If the parents of the function cannot be determined, the word
<span class="number"> 102</span> `<span class="k3">&lt;</span>spontaneous&gt;<span class="s">' is printed in the `name'</span> field, <span class="k1">and</span> all the other
<span class="number"> 103</span> fields are blank.
<span class="number"> 104</span>
<span class="number"> 105</span> For the function<span class="s">'s children, the fields have the following meanings:</span>
<span class="number"> 106</span><span class="s"></span>
<span class="number"> 107</span><span class="s">     self  This is the amount of time that was propagated directly</span>
<span class="number"> 108</span><span class="s">    from the child into the function.</span>
<span class="number"> 109</span><span class="s"></span>
<span class="number"> 110</span><span class="s">     children  This is the amount of time that was propagated from the</span>
<span class="number"> 111</span><span class="s">    child'</span>s children to the function.
<span class="number"> 112</span>
<span class="number"> 113</span>     called  This is the number of <a href="http://www.delorie.com/djgpp/doc/libc/libc_822.html" target="_blank">times</a> the function called
<span class="number"> 114</span>    <span class="k1">this</span> child `<span class="k3">/</span><span class="s">' the total number of times the child</span>
<span class="number"> 115</span><span class="s">    was called.  Recursive calls by the child are not</span>
<span class="number"> 116</span><span class="s">    listed in the number after the `/'</span>.
<span class="number"> 117</span>
<span class="number"> 118</span>     name  This is the name of the child.  The child<span class="s">'s index</span>
<span class="number"> 119</span><span class="s">    number is printed after it.  If the child is a</span>
<span class="number"> 120</span><span class="s">    member of a cycle, the cycle number is printed</span>
<span class="number"> 121</span><span class="s">    between the name and the index number.</span>
<span class="number"> 122</span><span class="s"></span>
<span class="number"> 123</span><span class="s"> If there are any cycles (circles) in the call graph, there is an</span>
<span class="number"> 124</span><span class="s"> entry for the cycle-as-a-whole.  This entry shows who called the</span>
<span class="number"> 125</span><span class="s"> cycle (as parents) and the members of the cycle (as children.)</span>
<span class="number"> 126</span><span class="s"> The `+'</span> recursive calls entry shows the number of function calls that
<span class="number"> 127</span> were internal to the cycle, <span class="k1">and</span> the calls entry <span class="k1">for</span> each member shows,
<span class="number"> 128</span> <span class="k1">for</span> that member, how many <a href="http://www.delorie.com/djgpp/doc/libc/libc_822.html" target="_blank">times</a> it was called from other members of
<span class="number"> 129</span> the cycle.
<span class="number"> 130</span>
<span class="number"> 131</span>Index by function name
<span class="number"> 132</span>
<span class="number"> 133</span>   <span class="k2">[</span><span class="n">2</span><span class="k2">]</span> log_printf
</div></div><p>
Only log_printf is listed in the flat profile, and none of the allegro functions even show up!
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 15 May 2014 12:30:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You are using WinXP, right? There are some other profiler options but they tend to be Vista+.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Thu, 15 May 2014 17:20:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><s>Do all the files contain debugging symbols? I am unsure the profile flags include &#39;-g&#39;</s></p><p>EDIT: well okay that should not matter at all. <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Thu, 15 May 2014 18:23:24 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My laptop is Vista, my desktop is XP. I do my dev work on my laptop. What other profilers are you talking about SiegeLord?</p><p>Allegro builds successfully, and both the source modules and the library are now linked with -pg, but gprof doesn&#39;t show any allegro functions in the flat profile. I don&#39;t get it, this used to work with allegro 4? What gives?</p><p><u>Edit</u><br />Submitted a patch to AD.</p><p>Anyone have any suggestions on what to replace gprof with? Or why gprof no longer works? I&#39;ve read things that suggest gprof doesn&#39;t work with shared libraries but like I said this used to work with Allegro 4.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 19 May 2014 03:33:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Were the libraries also <i>compiled</i> with -pg?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 19 May 2014 09:44:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, that&#39;s what the CMAKE_SHARED_LINKER_FLAGS_PROFILE patch was for. And the output from gprof is still useless. It says there were 6 calls to main, which is ridiculous and obviously wrong.</p><p>So, anyone know any good profiling tools for Windows?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 19 May 2014 10:04:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>LINKER_FLAGS aren&#39;t for <i>compiling</i>. lib source has to be compiled with -pg as well
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 19 May 2014 10:11:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yup. It&#39;s there already. The flag I mentioned was for building the library, and fixed the issue with unresolved references to mcount.</p><div class="quote_container"><div class="title">CMakeLists.txt said:</div><div class="quote"><p>
 set(CMAKE_C_FLAGS_PROFILE &quot;-pg&quot; CACHE STRING &quot;profiling flags&quot;)
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Mon, 19 May 2014 10:24:29 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried compiling Allegro with profiling (i.e. <span class="source-code"><span class="k3">-</span>pg</span>) but none of the examples ran after that treatment, so I&#39;m not sure what is up.</p><p>As for other profilers, I just tried <a href="http://www.codersnotes.com/sleepy">Very Sleepy</a> profiler and it picked up Allegro functions (note that I had to compile with <span class="source-code"><span class="k3">-</span>gdwarf-2</span> to get it to recognize the debug symbols. Perhaps the same will help your profile build?).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Tue, 20 May 2014 06:16:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I tried VerySleepy last night, and when I tried to attach to a process or launch a new one it just quit, and the program didn&#39;t run either.</p><div class="quote_container"><div class="title"><a href="http://www.codersnotes.com/sleepy">codersnotes.com</a> said:</div><div class="quote"><p>
Support for GCC/mingw. You can now profile executables with embedded DWARF2 data and it should work. No special options are required for this, just compile with “-g” to make sure you have symbols present. You may also wish to use “-fno-omit-frame-pointer” to ensure correct callstacks, although Sleepy will generally work either way. You don’t need to use “-pg” or any rubbish. It can even walk correct stacks between a Microsoft DLL into a GCC one, which was harder than you’d think.
</p></div></div><p>
I tried to profile a simple test program with these directions, using -g and -fno-omit-frame-pointer and every time I try to launch the program from verysleepy the program crashes and VerySleepy quits. My test program doesn&#39;t crash when run by itself though. The last release of VerySleepy was in November 2011 so I don&#39;t have high hopes for a fix unless I figure out what is wrong by myself, but that is another whole project in itself which I don&#39;t really want to get into.</p><p>I would try CodeXL but that is Win7+.</p><p>I couldn&#39;t get VerySleepy to work with -gdwarf-2 either. :/
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 20 May 2014 10:27:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve succeded in building <a href="https://code.google.com/p/gperftools/">gperftools</a> in MSYS2...I&#39;ll try to play around with the CPU profiler on your example Bitmaplocking.cpp rebuilding it in 32bits exe with all the deps statically linked in.</p><p>I don&#39;t <b>know</b> if I&#39;m doing something useful but trying should not hurt, I guess. <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><h2>D&#39;OH!</h2><p>

gperftools on windows have been ported only to a minimal libTmalloc, no sight of the CPU profiler <img src="http://www.allegro.cc/forums/smileys/lipsrsealed.gif" alt=":-X" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Thu, 22 May 2014 16:42:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>YAPTDWOW. (Yet another profiler that doesn&#39;t work on windows) <img src="http://www.allegro.cc/forums/smileys/tongue.gif" alt=":P" /></p><p>That&#39;s disappointing. I&#39;m beginning to think it would be better to profile opengl on Linux and try to improve it&#39;s functioning there in the hopes of improving it on Windows too. :/
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 23 May 2014 04:55:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/614254/1001049#target">Edgar Reynaldo</a> said:</div><div class="quote"><p> I&#39;m beginning to think it would be better to profile opengl on Linux and try to improve it&#39;s functioning there in the hopes of improving it on Windows too. :/ </p></div></div><p>I have the same impression, but me personally can only unse a VM and I doubt that could help a lot.</p><p>Nevertheless, the cumulative call stack could help....I discovered only now that I should have compiled with &#39;<tt>-f-no-omit-frame-pointer</tt>&#39; ...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (pkrcel)</author>
		<pubDate>Fri, 23 May 2014 12:04:48 +0000</pubDate>
	</item>
</rss>
