1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
[[!meta copyright="Copyright © 2012, 2013 Free Software Foundation, Inc."]]
[[!meta license="""[[!toggle id="license" text="GFDL 1.2+"]][[!toggleable
id="license" text="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license
is included in the section entitled [[GNU Free Documentation
License|/fdl]]."]]"""]]
[[!meta title="libpthread as glibc addon"]]
[[!tag open_issue_glibc open_issue_libpthread]]
This page lists all the notes, issues, etc, only about compiling libpthread
as addon for glibc, *not* for general libpthread issues.
# Building
To build libpthread as glibc addon, copy libpthread inside the glibc tree,
and then tell glibc's configure to use it:
$ cp /path/to/libpthread libpthread
$ ./configure [...] --enable-add-ons=[...],libpthread
Currently, it is build like that in Debian since eglibc 2.13-31.
# Issues and notes
### `bits/` headers not used
Recompiling glibc (e.g. on a Debian system) and running the
`check-local-headers` test, `check-local-headers.out` shows:
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/pthread.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/thread-attr.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/mutex-attr.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/mutex.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/condition-attr.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/condition.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/rwlock-attr.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/rwlock.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/barrier-attr.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/barrier.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/thread-specific.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/once.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/cancelation.h
*** $(common-objpfx)elf/tst-thrlock.o: uses /usr/include/i386-gnu/bits/pthread-np.h
This happens because these headers are in the `bits/` subdirectory in
`sysdeps/generic` -- a `generic` sysdep is used only for the top-level
`sysdeps` directory in glibc.
### Use of hurd's libihash
libpthread makes use of the ihash hurd library, as also glibc's
`check-local-headers` test shows:
*** $(common-objpfx)libpthread/pt-alloc.o: uses /usr/include/hurd/ihash.h
Possible alternatives: [[hurd/libihash]].
### Executable stack
Running glibc's `check-execstack` test gives in `check-execstack.out`:
$BUILDDIR/libpthread/libpthread.so.phdr: *** executable stack signaled
### Extra PLT references
Running glibc's `check-localplt` test gives in `check-localplt.out`:
Extra PLT reference: libpthread.so: pthread_detach
Extra PLT reference: libpthread.so: pthread_mutex_lock
Extra PLT reference: libpthread.so: pthread_mutexattr_settype
Extra PLT reference: libpthread.so: pthread_rwlock_rdlock
Extra PLT reference: libpthread.so: _pthread_spin_lock
Extra PLT reference: libpthread.so: pthread_attr_setstacksize
Extra PLT reference: libpthread.so: pthread_attr_getstacksize
Extra PLT reference: libpthread.so: pthread_attr_getstackaddr
Extra PLT reference: libpthread.so: pthread_attr_setstackaddr
Extra PLT reference: libpthread.so: pthread_exit
Extra PLT reference: libpthread.so: pthread_getspecific
Extra PLT reference: libpthread.so: __mutex_lock_solid
Extra PLT reference: libpthread.so: pthread_mutex_unlock
Extra PLT reference: libpthread.so: pthread_setcanceltype
Extra PLT reference: libpthread.so: pthread_key_create
Extra PLT reference: libpthread.so: pthread_cond_wait
Extra PLT reference: libpthread.so: pthread_rwlock_wrlock
Extra PLT reference: libpthread.so: pthread_once
Extra PLT reference: libpthread.so: pthread_cond_broadcast
Extra PLT reference: libpthread.so: pthread_setspecific
Extra PLT reference: libpthread.so: __pthread_get_cleanup_stack
Extra PLT reference: libpthread.so: pthread_rwlock_unlock
Extra PLT reference: libpthread.so: pthread_create
Extra PLT reference: libpthread.so: pthread_mutex_init
Extra PLT reference: libpthread.so: pthread_mutexattr_init
Extra PLT reference: libpthread.so: __mutex_unlock_solid
Extra PLT reference: libpthread.so: pthread_mutexattr_destroy
Extra PLT reference: libpthread.so: pthread_setcancelstate
### `bits/posix_opt.h`
`bits/posix_opt.h` is the glibc header defining the various
supported/unsupported `_POSIX_*` defines (e.g. `_POSIX_THREADS`, etc).
Currently, glibc's `sysdeps/mach/hurd/bits/posix_opt.h` is patched in Debian
to add all the defines advertizing thread-related support.
An idea to avoid this would be to follow what is done in NPTL, and do the
following:
- in glibc: leave `sysdeps/mach/hurd/bits/posix_opt.h` with *no*
thread-related macros at all.
- in libpthread: provide `sysdeps/mach/hurd/bits/posix_opt.h` which would
be a copy of glibc's `sysdeps/mach/hurd/bits/posix_opt.h` with also the thread
macros.
This approach would have the drawback that changes in the glibc header must be
mirrored also in the libpthread version, but with the advantage that defines
according to supported features in libpthread can be added in libpthread's own
version (and glibc would pick it automatically).
### Tests
The (few) existing tests are not built (thus neither run) just like other tests
in glibc.
### `gai_misc.h`
A pthread version of `gai_misc.h` must be provided by libpthread (just like
NPTL provides one), either in `sysdeps/mach/hurd` or `sysdeps/pthread`
(better).
Currently, it is provided in glibc itself in Debian.
|