|
Building profiling version of allegro fails with undefined reference to mcount |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I wanted to try and figure out why bitmap locking is so dreadfully slow in OpenGL on my laptop but I can't build the profiling version of allegro due to undefined references to mcount. I believe both the source modules and the library need to be linked with -pg for this to work correctly. I don't know where to look in the cmake files to fix this though. Any ideas? Quote:
1/* ... */
2
3Linking CXX shared library lib\allegro_monolith-profile-5.1.dll
4Creating library file: lib\liballegro_monolith-profile.dll.a
5CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x4): undefined reference to `mcount'
6CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x16): undefined reference to `mcount'
7CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x7): undefined reference to `mcount'
8CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x183): undefined reference to `mcount'
9CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x1f7): undefined reference to `mcount'
10CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x4ef): more undefined references to `mcount' follow
11collect2: ld returned 1 exit status
12mingw32-make[2]: *** [lib/allegro_monolith-profile-5.1.dll] Error 1
13mingw32-make[1]: *** [CMakeFiles/allegro_monolith.dir/all] Error 2
14mingw32-make: *** [all] Error 2
15
16c:\mingw\LIBS\A5GIT\allegro\build>
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
There is a Profile build type. Did you try it? "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Sorry, yes. I should have mentioned the cmake parameters I used : 1c:\ctwoplus\progcode\allegro5>cd %a5git%
2
3c:\mingw\LIBS\A5GIT\allegro\build>cmake -G "MinGW Makefiles" -DSHARED=On -DCMAKE_BUILD_TYPE=Profile -DWANT_DOCS=Off -DWANT_DEMO=Off -DWANT_EXAMPLES=Off -DWANT_MONOLITH=On ..
4-- Using MINGDIR: C:/mingw
5-- Allowing GCC/Clang to use SSE instructions
6-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
7-- Could NOT find OPENSL (missing: OPENSL_INCLUDE_DIR OPENSL_LIBRARY)
8WARNING: Dynamic loading will be disabled for FLAC as static library was found: C:/mingw/lib/libFLAC.a
9WARNING: Dynamic loading will be disabled for DUMB as static library was found: C:/mingw/lib/libdumb.a
10-- DLL name for C:/mingw/lib/libvorbisfile.dll.a: libvorbisfile-3.dll
11-- Configuring done
12-- Generating done
13-- Build files have been written to: C:/mingw/LIBS/A5GIT/allegro/build
14
15c:\mingw\LIBS\A5GIT\allegro\build>mingw32-make
16[ 0%] Building C object CMakeFiles/allegro_monolith.dir/src/allegro.c.obj
17
18/*...*/
19
20[ 99%] Building C object CMakeFiles/allegro_monolith.dir/addons/main/generic_main.c.obj
21Linking CXX shared library lib\allegro_monolith-profile-5.1.dll
22Creating library file: lib\liballegro_monolith-profile.dll.a
23CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x4): undefined reference to `mcount'
24CMakeFiles\allegro_monolith.dir/objects.a(allegro.c.obj):allegro.c:(.text+0x16): undefined reference to `mcount'
25CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x7): undefined reference to `mcount'
26CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x183): undefined reference to `mcount'
27CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x1f7): undefined reference to `mcount'
28CMakeFiles\allegro_monolith.dir/objects.a(bitmap.c.obj):bitmap.c:(.text+0x4ef): more undefined references to `mcount' follow
29collect2: ld returned 1 exit status
30mingw32-make[2]: *** [lib/allegro_monolith-profile-5.1.dll] Error 1
31mingw32-make[1]: *** [CMakeFiles/allegro_monolith.dir/all] Error 2
32mingw32-make: *** [all] Error 2
33
34c:\mingw\LIBS\A5GIT\allegro\build>
Yeah, I also tried it without the monolith and it fails the same way. Edit Quote:
393# Profiling.
394
395list(APPEND CMAKE_BUILD_CONFIGURATIONS Profile)
396if(COMPILER_GCC_OR_CLANG)
397 set(CMAKE_C_FLAGS_PROFILE "-pg"
398 CACHE STRING "profiling flags")
399 set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
400 CACHE STRING "profiling flags")
401 set(CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg"
402 CACHE STRING "profiling flags")
403 mark_as_advanced(
404 CMAKE_C_FLAGS_PROFILE
405 CMAKE_CXX_FLAGS_PROFILE
406 CMAKE_EXE_LINKER_FLAGS_PROFILE
407 )
408endif(COMPILER_GCC_OR_CLANG)
It sets a flag for the source modules and for the linker so I'm not sure what is wrong. Perhaps the library needs a separate linker parameter in cmake? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
There is a separate linker flag for shared libs iirc. -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
From Quote: On 12/12/2011 09:00 PM, Robert Dailey wrote: Quote: I need a version of CMAKE_EXE_LINKER_FLAGS for shared libraries. I need Use CMAKE_SHARED_LINKER_FLAGS. Strangely, this family of variables is Michael So we need to use CMAKE_SHARED_LINKER_FLAGS somewhere? Like in the profiling section above? cmake confuses me. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
Pretty much yeah. -- |
pkrcel
Member #14,001
February 2012
|
Edgar Reynaldo said: so we need to use CMAKE_SHARED_LINKER_FLAGS somewhere? Like in the profiling section above? cmake confuses me. You should use CMAKE_SHARED_LINKER_FLAGS instead of CMAKE_EXE_LINKER_FLAGS. Try to use the CMAKE_VERBOSE_MAKEFILE option so we see the actual link command passed to the command line (warning: LOTS of text). It is unlikely that Google shares your distaste for capitalism. - Derezo |
Thomas Fjellstrom
Member #476
June 2000
|
You could just pass: VERBOSE=1 to make. if you want to see the commands make runs. -- |
pkrcel
Member #14,001
February 2012
|
I think it does just the same....but I'll try it out It is unlikely that Google shares your distaste for capitalism. - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
pkrcel said: You should use CMAKE_SHARED_LINKER_FLAGS instead of CMAKE_EXE_LINKER_FLAGS. I would assume we still need CMAKE_EXE_LINKER_FLAGS though, as the examples and demos would all need to be linked with -pg. I got it to build by changing the above section from CMakeLists.txt to the below : 393# Profiling.
394
395list(APPEND CMAKE_BUILD_CONFIGURATIONS Profile)
396if(COMPILER_GCC_OR_CLANG)
397 set(CMAKE_C_FLAGS_PROFILE "-pg"
398 CACHE STRING "profiling flags")
399 set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE}"
400 CACHE STRING "profiling flags")
401 set(CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg"
402 CACHE STRING "profiling flags")
403 set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "-pg"
404 CACHE STRING "profiling flags")
405 mark_as_advanced(
406 CMAKE_C_FLAGS_PROFILE
407 CMAKE_CXX_FLAGS_PROFILE
408 CMAKE_EXE_LINKER_FLAGS_PROFILE
409 CMAKE_SHARED_LINKER_FLAGS_PROFILE
410 )
411endif(COMPILER_GCC_OR_CLANG)
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). Everything seems to build fine, all the demo, examples and library worked fine. When run, the exe's produce gmon.out like they're supposed to but gprof is giving me some messed up results, and doesn't even include the allegro functions in the profile, which I can't explain. I'm trying to upgrade my compiler as we speak, prob won't finish til tomorrow though. Yeah, the output from gprof is not making any sense at all. For example, I ran ex_threads and then ran gprof on it : 1Flat profile:
2
3Each sample counts as 0.01 seconds.
4 no time accumulated
5
6 % cumulative self self total
7 time seconds seconds calls Ts/call Ts/call name
8 0.00 0.00 0.00 26797 0.00 0.00 log_printf
9
10 % the percentage of the total running time of the
11time program used by this function.
12
13cumulative a running sum of the number of seconds accounted
14 seconds for by this function and those listed above it.
15
16 self the number of seconds accounted for by this
17seconds function alone. This is the major sort for this
18 listing.
19
20calls the number of times this function was invoked, if
21 this function is profiled, else blank.
22
23 self the average number of milliseconds spent in this
24ms/call function per call, if this function is profiled,
25 else blank.
26
27 total the average number of milliseconds spent in this
28ms/call function and its descendents per call, if this
29 function is profiled, else blank.
30
31name the name of the function. This is the minor sort
32 for this listing. The index shows the location of
33 the function in the gprof listing. If the index is
34 in parenthesis it shows where it would appear in
35 the gprof listing if it were to be printed.
36
37 Call graph (explanation follows)
38
39
40granularity: each sample hit covers 4 byte(s) no time propagated
41
42index % time self children called name
43 0.00 0.00 279/26797 animate_square [140]
44 0.00 0.00 2109/26797 gen_square [154]
45 0.00 0.00 24409/26797 thread_func [177]
46[2] 0.0 0.00 0.00 26797 log_printf [2]
47-----------------------------------------------
48
49 This table describes the call tree of the program, and was sorted by
50 the total amount of time spent in each function and its children.
51
52 Each entry in this table consists of several lines. The line with the
53 index number at the left hand margin lists the current function.
54 The lines above it list the functions that called this function,
55 and the lines below it list the functions this one called.
56 This line lists:
57 index A unique number given to each element of the table.
58 Index numbers are sorted numerically.
59 The index number is printed next to every function name so
60 it is easier to look up where the function in the table.
61
62 % time This is the percentage of the `total' time that was spent
63 in this function and its children. Note that due to
64 different viewpoints, functions excluded by options, etc,
65 these numbers will NOT add up to 100%.
66
67 self This is the total amount of time spent in this function.
68
69 children This is the total amount of time propagated into this
70 function by its children.
71
72 called This is the number of times the function was called.
73 If the function called itself recursively, the number
74 only includes non-recursive calls, and is followed by
75 a `+' and the number of recursive calls.
76
77 name The name of the current function. The index number is
78 printed after it. If the function is a member of a
79 cycle, the cycle number is printed between the
80 function's name and the index number.
81
82
83 For the function's parents, the fields have the following meanings:
84
85 self This is the amount of time that was propagated directly
86 from the function into this parent.
87
88 children This is the amount of time that was propagated from
89 the function's children into this parent.
90
91 called This is the number of times this parent called the
92 function `/' the total number of times the function
93 was called. Recursive calls to the function are not
94 included in the number after the `/'.
95
96 name This is the name of the parent. The parent's index
97 number is printed after it. If the parent is a
98 member of a cycle, the cycle number is printed between
99 the name and the index number.
100
101 If the parents of the function cannot be determined, the word
102 `<spontaneous>' is printed in the `name' field, and all the other
103 fields are blank.
104
105 For the function's children, the fields have the following meanings:
106
107 self This is the amount of time that was propagated directly
108 from the child into the function.
109
110 children This is the amount of time that was propagated from the
111 child's children to the function.
112
113 called This is the number of times the function called
114 this child `/' the total number of times the child
115 was called. Recursive calls by the child are not
116 listed in the number after the `/'.
117
118 name This is the name of the child. The child's index
119 number is printed after it. If the child is a
120 member of a cycle, the cycle number is printed
121 between the name and the index number.
122
123 If there are any cycles (circles) in the call graph, there is an
124 entry for the cycle-as-a-whole. This entry shows who called the
125 cycle (as parents) and the members of the cycle (as children.)
126 The `+' recursive calls entry shows the number of function calls that
127 were internal to the cycle, and the calls entry for each member shows,
128 for that member, how many times it was called from other members of
129 the cycle.
130
131Index by function name
132
133 [2] log_printf
Only log_printf is listed in the flat profile, and none of the allegro functions even show up! My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
You are using WinXP, right? There are some other profiler options but they tend to be Vista+. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
pkrcel
Member #14,001
February 2012
|
EDIT: well okay that should not matter at all. It is unlikely that Google shares your distaste for capitalism. - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
My laptop is Vista, my desktop is XP. I do my dev work on my laptop. What other profilers are you talking about SiegeLord? Allegro builds successfully, and both the source modules and the library are now linked with -pg, but gprof doesn't show any allegro functions in the flat profile. I don't get it, this used to work with allegro 4? What gives? Edit Anyone have any suggestions on what to replace gprof with? Or why gprof no longer works? I've read things that suggest gprof doesn't work with shared libraries but like I said this used to work with Allegro 4. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Arthur Kalliokoski
Second in Command
February 2005
|
Were the libraries also compiled with -pg? They all watch too much MSNBC... they get ideas. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Yes, that'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. So, anyone know any good profiling tools for Windows? My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Thomas Fjellstrom
Member #476
June 2000
|
LINKER_FLAGS aren't for compiling. lib source has to be compiled with -pg as well -- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Yup. It's there already. The flag I mentioned was for building the library, and fixed the issue with unresolved references to mcount. CMakeLists.txt said: set(CMAKE_C_FLAGS_PROFILE "-pg" CACHE STRING "profiling flags")
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
I tried compiling Allegro with profiling (i.e. -pg) but none of the examples ran after that treatment, so I'm not sure what is up. As for other profilers, I just tried Very Sleepy profiler and it picked up Allegro functions (note that I had to compile with -gdwarf-2 to get it to recognize the debug symbols. Perhaps the same will help your profile build?). "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Edgar Reynaldo
Major Reynaldo
May 2007
|
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't run either. codersnotes.com said: 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. 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't crash when run by itself though. The last release of VerySleepy was in November 2011 so I don'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't really want to get into. I would try CodeXL but that is Win7+. I couldn't get VerySleepy to work with -gdwarf-2 either. :/ My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
pkrcel
Member #14,001
February 2012
|
I've succeded in building gperftools in MSYS2...I'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. I don't know if I'm doing something useful but trying should not hurt, I guess. D'OH!gperftools on windows have been ported only to a minimal libTmalloc, no sight of the CPU profiler It is unlikely that Google shares your distaste for capitalism. - Derezo |
Edgar Reynaldo
Major Reynaldo
May 2007
|
YAPTDWOW. (Yet another profiler that doesn't work on windows) That's disappointing. I'm beginning to think it would be better to profile opengl on Linux and try to improve it's functioning there in the hopes of improving it on Windows too. :/ My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
pkrcel
Member #14,001
February 2012
|
Edgar Reynaldo said: I'm beginning to think it would be better to profile opengl on Linux and try to improve it's functioning there in the hopes of improving it on Windows too. :/ I have the same impression, but me personally can only unse a VM and I doubt that could help a lot. Nevertheless, the cumulative call stack could help....I discovered only now that I should have compiled with '-f-no-omit-frame-pointer' ... It is unlikely that Google shares your distaste for capitalism. - Derezo |
|