Bug 115068 - build failure: CPU_ZERO, CPU_SET undefined
Summary: build failure: CPU_ZERO, CPU_SET undefined
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (other bugs)
Version First Reported In: 1.3.5
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-25 14:33 UTC by Rex Dieter
Modified: 2006-06-11 12:32 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
fix configure's sched_setaffinity check (408 bytes, patch)
2005-10-25 15:38 UTC, Rex Dieter
Details
CPU_SET/CPU_ZERO fix (669 bytes, patch)
2005-10-25 15:58 UTC, Rex Dieter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rex Dieter 2005-10-25 14:33:03 UTC
Version:           1.3.4 (using KDE KDE 3.4.3)
Installed from:    RedHat RPMs
Compiler:          gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5) redhat 9, redhat enterprise 3
OS:                Linux

Perhaps a kernel-2.4.x thing?


if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../amarok/src/amarokcore -I../../amarok/src/amarokcore -I../../amarok/src/analyzers -I../../amarok/src/engine -I../../amarok/src/plugin -I../../amarok/src/statusbar -I/usr/include/kde/arts -I/usr/include/taglib -I../../amarok/src/sqlite   -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include   
-DQT_THREAD_SUPPORT  -D_REENTRANT  -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -DNDEBUG -DNO_DEBUG -O2 -O2 -march=i386 -mcpu=i686 -Wformat-security -Wmissing-format-attribute -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT app.o -MD -MP -MF ".deps/app.Tpo" -c -o app.o ap
p.cpp; \
then mv -f ".deps/app.Tpo" ".deps/app.Po"; else rm -f ".deps/app.Tpo"; exit 1; fi

app.cpp: In member function `void App::fixHyperThreading()':
app.cpp:408: `cpu_set_t' undeclared (first use this function)
app.cpp:408: (Each undeclared identifier is reported only once for each 
   function it appears in.)
app.cpp:408: parse error before `;' token
app.cpp:409: `mask' undeclared (first use this function)
app.cpp:409: `CPU_ZERO' undeclared (first use this function)
app.cpp:410: `CPU_SET' undeclared (first use this function)
Comment 1 Rex Dieter 2005-10-25 14:34:55 UTC
$rpm -q glibc
glibc-2.3.2-27.9.7.2.legacy
Comment 2 Rex Dieter 2005-10-25 14:51:28 UTC
ON rhel3, build fails similarly: (but at leaste CPU_ZERO/CPU_SET is defined)
glibc-2.3.2-95.33

make[1]: Entering directory `/home/rdieter/BUILD/amarok-1.3.4/amarok/src'
if g++ -DHAVE_CONFIG_H -I. -I. -I../.. -I../../amarok/src/amarokcore -I../../amarok/src/amarokcore -I../../amarok/src/analyzers -I../../amarok/src/engine -I../../amarok/src/plugin -I../../amarok/src/statusbar -I/usr/include/kde/arts -I/usr/include/taglib -I../../amarok/src/sqlite   -I/usr/include/kde -I/usr/lib/qt-3.3/include -I/usr/X11R6/include   -DQT_THREAD_SUPPORT  -D_REENTRANT  -Wno-long-long -Wundef -ansi -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -Wchar-subscripts -Wall -W -Wpointer-arith -DNDEBUG -DNO_DEBUG -O2 -O2 -pipe -march=i386 -mcpu=i686 -Wformat-security -Wmissing-format-attribute -Wno-non-virtual-dtor -fno-exceptions -fno-check-new -fno-common -DQT_CLEAN_NAMESPACE -DQT_NO_ASCII_CAST -DQT_NO_STL -DQT_NO_COMPAT -DQT_NO_TRANSLATION  -MT app.o -MD -MP -MF ".deps/app.Tpo" -c -o app.o app.cpp; \
then mv -f ".deps/app.Tpo" ".deps/app.Po"; else rm -f ".deps/app.Tpo"; exit 1; fi
app.cpp: In member function `void App::fixHyperThreading()':
app.cpp:412: invalid conversion from `unsigned int' to `const cpu_set_t*'
/usr/include/sched.h:77: too many arguments to function `int 
   sched_setaffinity(int, const cpu_set_t*)'
app.cpp:412: at this point in file
Comment 3 Rex Dieter 2005-10-25 14:55:27 UTC
ON rhel3, sched_setaffinity accepts 2 arguments, from /usr/include/sched.h:

/* Set the CPU affinity for a task */
extern int sched_setaffinity (__pid_t __pid, __const cpu_set_t *__mask)
     __THROW;
 
Comment 4 Rex Dieter 2005-10-25 15:04:26 UTC
Looks like a broken test for set_affinity.  

test.c contains (stolen from configure):
#include <sched.h>
      
int main ()
{ 
   cpu_set_t mask;
   CPU_ZERO( &mask );
   CPU_SET( 0, &mask );
   sched_setaffinity( 0, sizeof(mask), &mask );
  return 0;
}


 The test seemingly passes using gcc:

gcc -c -std=iso9899:1990 -W -Wall -Wchar-subscripts -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -DNDEBUG -O2  -O2 -pipe -march=i386 -mcpu=i686 -Wformat-security -D_BSD_SOURCE test.c
test.c: In function `main':
test.c:6: warning: implicit declaration of function `CPU_ZERO'
test.c:7: warning: implicit declaration of function `CPU_SET'
test.c:8: warning: implicit declaration of function `sched_setaffinity'

Not sure about the implicit declaration

but not when using g++,
$ g++ -c -std=iso9899:1990 -W -Wall -Wchar-subscripts -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wformat-security -D_BSD_SOURCE test.c       
test.c: In function `int main()':
test.c:8: invalid conversion from `unsigned int' to `const cpu_set_t*'
/usr/include/sched.h:77: too many arguments to function `int 
   sched_setaffinity(int, const cpu_set_t*)'
test.c:8: at this point in file

Comment 5 Rex Dieter 2005-10-25 15:19:58 UTC
Turns out the affinity test fails to with gcc, but only if _GNU_SOURCE is defined.  OK, so my workaround will simply be to add -D_GNU_SOURCE to CFLAGS and CXXFLAGS.
Comment 6 Rex Dieter 2005-10-25 15:38:36 UTC
Created attachment 13149 [details]
fix configure's sched_setaffinity check

add 
#define _GNU_SOURCE
to sched_setaffinity check.
Comment 7 Mark Kretschmann 2005-10-25 15:39:36 UTC
These are two unrelated issues. The second issue (on rhel3) is solved in 
amaroK 1.3.5, which was released today.

First issue we don't have a solution for at this point. Must be a rare glibc 
version.
Comment 8 Rex Dieter 2005-10-25 15:55:23 UTC
sched_setaffinity confirmed fixed in 1.3.5
Comment 9 Rex Dieter 2005-10-25 15:56:13 UTC
back to original CPU_ZERO/CPU_SET undefined issue, still present in 1.3.5
Comment 10 Rex Dieter 2005-10-25 15:58:35 UTC
Created attachment 13150 [details]
CPU_SET/CPU_ZERO fix

add checks for CPU_SET/CPU_ZERO:
defined(CPU_ZERO) && defined(CPU_SET)
before calling them.
Comment 11 Mark Kretschmann 2005-10-25 16:43:49 UTC
SVN commit 474112 by markey:

Fix build issue on some Linux kernel 2.4 distros. (BR 115068)

Patch by Rex Dieter <rdieter@math.unl.edu>

BUG: 115068



 M  +5 -0      ChangeLog  
 M  +3 -3      src/app.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #474111:474112
@@ -21,6 +21,11 @@
       of each song until amaroK is restarted.
 
 
+VERSION 1.3.6:
+  BUGFIXES:
+    * Fix build issue on some Linux kernel 2.4 distros. (BR 115068)
+
+
 VERSION 1.3.5:
   BUGFIXES:
     * Fixed a build issue.
--- trunk/extragear/multimedia/amarok/src/app.cpp #474111:474112
@@ -385,7 +385,7 @@
 
     DEBUG_BLOCK
 
-    #ifdef __linux__ 
+    #ifdef __linux__
     debug() << "SCHEDAFFINITY_SUPPORT enabled. Testing to see if HT fix should be enabled..." << endl;
     QString line;
     uint cpuCount = 0;
@@ -404,12 +404,12 @@
         debug() << "CPU with active HyperThreading detected. Enabling WORKAROUND.\n";
 
         // If the library is new enough try and call sched_setaffinity.
-        #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,3) 
+        #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,3) && defined(CPU_ZERO) && defined(CPU_SET)
         cpu_set_t mask;
         CPU_ZERO( &mask ); // Initializes all the bits in the mask to zero
         CPU_SET( 0, &mask ); // Sets only the bit corresponding to cpu
         #ifdef SCHEDAFFINITY_SUPPORT
-        if ( sched_setaffinity( 0, sizeof(mask), &mask ) == -1 ) 
+        if ( sched_setaffinity( 0, sizeof(mask), &mask ) == -1 )
         #else  //SCHEDAFFINITY_SUPPORT
         if ( sched_setaffinity( 0, &mask ) == -1 )
         #endif //SCHEDAFFINITY_SUPPORT
Comment 12 Mark Kretschmann 2005-10-25 16:44:44 UTC
SVN commit 474114 by markey:

Backport fix.

CCBUG: 115068 



 M  +5 -0      ChangeLog  
 M  +3 -3      src/app.cpp  


--- branches/stable/extragear/multimedia/amarok/ChangeLog #474113:474114
@@ -3,6 +3,11 @@
 (C) 2002-2005 the amaroK authors.
 
 
+VERSION 1.3.6:
+  BUGFIXES:
+    * Fix build issue on some Linux kernel 2.4 distros. (BR 115068)
+
+
 VERSION 1.3.5:
   BUGFIXES:
     * Fixed a build issue.
--- branches/stable/extragear/multimedia/amarok/src/app.cpp #474113:474114
@@ -385,7 +385,7 @@
 
     DEBUG_BLOCK
 
-    #ifdef __linux__ 
+    #ifdef __linux__
     debug() << "SCHEDAFFINITY_SUPPORT enabled. Testing to see if HT fix should be enabled..." << endl;
     QString line;
     uint cpuCount = 0;
@@ -404,12 +404,12 @@
         debug() << "CPU with active HyperThreading detected. Enabling WORKAROUND.\n";
 
         // If the library is new enough try and call sched_setaffinity.
-        #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,3) 
+        #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2,3) && defined(CPU_ZERO) && defined(CPU_SET)
         cpu_set_t mask;
         CPU_ZERO( &mask ); // Initializes all the bits in the mask to zero
         CPU_SET( 0, &mask ); // Sets only the bit corresponding to cpu
         #ifdef SCHEDAFFINITY_SUPPORT
-        if ( sched_setaffinity( 0, sizeof(mask), &mask ) == -1 ) 
+        if ( sched_setaffinity( 0, sizeof(mask), &mask ) == -1 )
         #else  //SCHEDAFFINITY_SUPPORT
         if ( sched_setaffinity( 0, &mask ) == -1 )
         #endif //SCHEDAFFINITY_SUPPORT
Comment 13 Michal Wazgird 2005-11-09 22:28:19 UTC
This error (cpu_set undeclared) returns on compilation of sources of 1.3.6. So it looks that it's not fixed again.

$ rpm -q glibc
glibc-2.3.2-14mdk
$ uname -r
2.6.12-oci5.mdk
Comment 14 Rex Dieter 2005-11-10 03:21:20 UTC
Michal, post the error, cause I doubt the same error can happen since the code in question is now enclosed by
#if defined(CPU_ZERO) && defined(CPU_SET)

#endif
Comment 15 Ian Monroe 2005-11-10 06:32:11 UTC
No actually it isn't, we tweaked it to work on another system and changed how it was doing the check. Little did we know there are systems which have the function but don't have the CPU_ZERO macro. :S Now we test pretty much everything in SVN trunk.