From 366ee54830b3889c0bac89b034d6b3198edc6e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20G=C3=BCnther?= Date: Mon, 7 Jul 2014 16:20:39 +0200 Subject: [PATCH] DVB media addon: Fix debug build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Compiling dvb.media_addon with DEBUG on fails with error message: generated/objects/haiku/x86/debug_1/add-ons/media/media-add-ons/dvb/ MediaFormat.o: In function `av_log2_c': /boot/home/Development/haiku-a4/ generated/build_packages/ffmpeg-0.10.2-r1a4-x86-gcc2-2012-08-30/common/ include/libavutil/common.h:80: undefined reference to `ff_log2_tab' collect2: ld returned 1 exit status" - Research done to narrow down the solution space: - ff_log2_tab is a array that is nowhere needed in the dvb.media_addon - ff_log2_tab is defined as an extern array in the ffmpeg header file libavutil/common.h - ff_log2_tab is used in the inline function av_log2_c (libavutil/common.h) which doesn't get optimized away when compiling with debug information - MediaFormat.cpp needs only some Codec-IDs from the ffmpeg header file avcodec.h - The following fixes were tried: - Trying to eliminate unused debug symbols with compilation flag -feliminate-unused-debug-types (see gcc documentation http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Debugging-Options.html#Debugging-Options) by adding the following lines to UserBuildConfig AppendToConfigVar C++FLAGS : HAIKU_TOP src : -feliminate-unused-debug-types : global ; AppendToConfigVar CCFLAGS : HAIKU_TOP src : -feliminate-unused-debug-types : global ; -> Failed, because flag -feliminate-unused-debug-types is not supported by GCC 2.95.3 - Trying to eliminate unused debug symbols in the linker stage -> This worked, by removing the LINKFLAG "-Xlinker --no-undefined" when linking all objects into the dvb.media_addon we are getting our addon with debug symbols. - Final solution: - Instead of adding/removing flags, we just add the missing implementation for the ff_log2_tab array in MediaFormat.cpp. This -feels- the seems to be the cleanest solution as it is more obvious what's goin' on compared to hiding the solution in the Jamfile. Signed-off-by: Colin Günther --- src/add-ons/media/media-add-ons/dvb/MediaFormat.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/add-ons/media/media-add-ons/dvb/MediaFormat.cpp b/src/add-ons/media/media-add-ons/dvb/MediaFormat.cpp index 024af500e8..9b7566213c 100644 --- a/src/add-ons/media/media-add-ons/dvb/MediaFormat.cpp +++ b/src/add-ons/media/media-add-ons/dvb/MediaFormat.cpp @@ -30,7 +30,14 @@ #define UINT64_C(c) (c ## ULL) extern "C" { #include "avcodec.h" -} + +#ifdef DEBUG + // Needed to fix debug build, otherwise the linker complains about + // "undefined reference to `ff_log2_tab'" + const uint8_t ff_log2_tab[256] = {0}; +#endif + +} // extern "C" void PrintFormat(const media_format &format)