Skip to contentSkip to conversation

compile error : about declaration of ‘pthread_attr_setaffinity_np’

PATCH taeung 2 participants 2 messages Feb 24, 2015 – Feb 28, 2015 perf events

lore
Share & tools
lore

taeung

author
#0 lore raw

Hi, Namhyung

After I pulled new changed source codes from 'perf/core' branch (https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git)
,when I compiled perf I've had a problem with error messages as below.

(I'm using as below
system : Ubuntu 14.04.2 LTS 64-bit
kernel version : 3.13.0-40-generic)

==================
taeung ~/git/tip/tools/perf
:> make -j4

...(omitted)

In file included from bench/futex-hash.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,

                   ^
In file included from bench/futex.h:72:0,
                 from bench/futex-hash.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of ‘pthread_attr_setaffinity_np’ was here
 extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
            ^

make[3]: *** [bench/futex-hash.o] Error 1
make[2]: *** [bench] Error 2
make[2]: *** Waiting for unfinished jobs....

...(omitted)

==================

But I modified 'tools/perf/config/feature-checks/Makefile' as Jirka said (https://lkml.org/lkml/2015/1/12/216)
so I was able to compile perf.

tools/perf/config/feature-checks/Makefile +1 -1
index b32ff33..42ac05a 100644
@@ -49,7 +49,7 @@ test-hello.bin:
        $(BUILD)
 
 test-pthread-attr-setaffinity-np.bin:
-       $(BUILD) -D_GNU_SOURCE -Werror -lpthread
+       $(BUILD) -Werror -lpthread
 
 test-stackprotector-all.bin:
        $(BUILD) -Werror -fstack-protector-all

Is this patch right ?

Thanks,
Taeung

maintainer
#1 lore raw

(Adding Arnaldo and Jiri to CC.)

Quoted 1 line · taeung

Hi, Namhyung

Hi Taeung,

Quoted 19 lines

After I pulled new changed source codes from 'perf/core' branch
(https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git)
,when I compiled perf I've had a problem with error messages as below.

(I'm using as below
system : Ubuntu 14.04.2 LTS 64-bit
kernel version : 3.13.0-40-generic)

==================
taeung ~/git/tip/tools/perf
:> make -j4

...(omitted)

In file included from bench/futex-hash.c:17:0:
bench/futex.h:73:19: error: conflicting types for ‘pthread_attr_setaffinity_np’
static inline int pthread_attr_setaffinity_np(pthread_attr_t *attr,

Quoted 7 lines
                   ^
In file included from bench/futex.h:72:0,
                 from bench/futex-hash.c:17:
/usr/include/pthread.h:407:12: note: previous declaration of
‘pthread_attr_setaffinity_np’ was here
 extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr,
            ^

This means it failed to find pthread_attr_setaffinity_np() on the feature test (so HAVE_PTHREAD_ATTR_SETAFFINITY_NP is not defined) but it's actually available on your system.

Quoted 11 lines

make[3]: *** [bench/futex-hash.o] Error 1
make[2]: *** [bench] Error 2
make[2]: *** Waiting for unfinished jobs....

...(omitted)

==================

But I modified 'tools/perf/config/feature-checks/Makefile' as Jirka said
(https://lkml.org/lkml/2015/1/12/216)
so I was able to compile perf.

No Jiri's advice was to add -lpthread, not remove _GNU_SOURCE define. I guess adding -pthread instead of -lpthread might help..

Quoted 18 lines
tools/perf/config/feature-checks/Makefile +1 -1
index b32ff33..42ac05a 100644
@@ -49,7 +49,7 @@ test-hello.bin:
        $(BUILD)
 
 test-pthread-attr-setaffinity-np.bin:
-       $(BUILD) -D_GNU_SOURCE -Werror -lpthread
+       $(BUILD) -Werror -lpthread
 
 test-stackprotector-all.bin:
        $(BUILD) -Werror -fstack-protector-all
Quoted 1 line

Is this patch right ?

I don't think so. You'd better to find out the reason of the failure in the feature test.

Thanks,
Namhyung