Makefile 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
  2. # This file is part of the GNU C Library.
  3. # The GNU C Library is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU Lesser General Public
  5. # License as published by the Free Software Foundation; either
  6. # version 2.1 of the License, or (at your option) any later version.
  7. # The GNU C Library is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. # Lesser General Public License for more details.
  11. # You should have received a copy of the GNU Lesser General Public
  12. # License along with the GNU C Library; if not, write to the Free
  13. # Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. # 02111-1307 USA.
  15. #
  16. # Sub-makefile for NPTL portion of the library.
  17. #
  18. subdir := nptl
  19. headers := pthread.h semaphore.h bits/semaphore.h
  20. extra-libs := libpthread
  21. extra-libs-others := $(extra-libs)
  22. install-lib-ldscripts := libpthread.so
  23. routines = alloca_cutoff forward libc-lowlevellock libc-cancellation
  24. shared-only-routines = forward
  25. libpthread-routines = init vars events version \
  26. pthread_create pthread_exit pthread_detach \
  27. pthread_join pthread_tryjoin pthread_timedjoin \
  28. pthread_self pthread_equal pthread_yield \
  29. pthread_getconcurrency pthread_setconcurrency \
  30. pthread_getschedparam pthread_setschedparam \
  31. pthread_setschedprio \
  32. pthread_attr_init pthread_attr_destroy \
  33. pthread_attr_getdetachstate pthread_attr_setdetachstate \
  34. pthread_attr_getguardsize pthread_attr_setguardsize \
  35. pthread_attr_getschedparam pthread_attr_setschedparam \
  36. pthread_attr_getschedpolicy pthread_attr_setschedpolicy \
  37. pthread_attr_getinheritsched \
  38. pthread_attr_setinheritsched \
  39. pthread_attr_getscope pthread_attr_setscope \
  40. pthread_attr_getstackaddr pthread_attr_setstackaddr \
  41. pthread_attr_getstacksize pthread_attr_setstacksize \
  42. pthread_attr_getstack pthread_attr_setstack \
  43. pthread_getattr_np \
  44. pthread_mutex_init pthread_mutex_destroy \
  45. pthread_mutex_lock pthread_mutex_trylock \
  46. pthread_mutex_timedlock pthread_mutex_unlock \
  47. pthread_mutexattr_init pthread_mutexattr_destroy \
  48. pthread_mutexattr_getpshared \
  49. pthread_mutexattr_setpshared \
  50. pthread_mutexattr_gettype pthread_mutexattr_settype \
  51. pthread_rwlock_init pthread_rwlock_destroy \
  52. pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
  53. pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
  54. pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
  55. pthread_rwlock_unlock \
  56. pthread_rwlockattr_init pthread_rwlockattr_destroy \
  57. pthread_rwlockattr_getpshared \
  58. pthread_rwlockattr_setpshared \
  59. pthread_rwlockattr_getkind_np \
  60. pthread_rwlockattr_setkind_np \
  61. pthread_cond_init pthread_cond_destroy \
  62. pthread_cond_wait pthread_cond_timedwait \
  63. pthread_cond_signal pthread_cond_broadcast \
  64. old_pthread_cond_init old_pthread_cond_destroy \
  65. old_pthread_cond_wait old_pthread_cond_timedwait \
  66. old_pthread_cond_signal old_pthread_cond_broadcast \
  67. pthread_condattr_init pthread_condattr_destroy \
  68. pthread_condattr_getpshared pthread_condattr_setpshared \
  69. pthread_condattr_getclock pthread_condattr_setclock \
  70. pthread_spin_init pthread_spin_destroy \
  71. pthread_spin_lock pthread_spin_trylock \
  72. pthread_spin_unlock \
  73. pthread_barrier_init pthread_barrier_destroy \
  74. pthread_barrier_wait \
  75. pthread_barrierattr_init pthread_barrierattr_destroy \
  76. pthread_barrierattr_getpshared \
  77. pthread_barrierattr_setpshared \
  78. pthread_key_create pthread_key_delete \
  79. pthread_getspecific pthread_setspecific \
  80. pthread_sigmask pthread_kill \
  81. pthread_cancel pthread_testcancel \
  82. pthread_setcancelstate pthread_setcanceltype \
  83. pthread_once \
  84. old_pthread_atfork pthread_atfork \
  85. pthread_getcpuclockid \
  86. pthread_clock_gettime pthread_clock_settime \
  87. sem_init sem_destroy \
  88. sem_open sem_close sem_unlink \
  89. sem_getvalue \
  90. sem_wait sem_trywait sem_timedwait sem_post \
  91. cleanup cleanup_defer cleanup_compat \
  92. cleanup_defer_compat unwind \
  93. pt-longjmp pt-cleanup\
  94. cancellation \
  95. lowlevellock \
  96. pt-vfork \
  97. ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
  98. ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
  99. ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \
  100. ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
  101. ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
  102. ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
  103. ptw-sigwait \
  104. pt-raise pt-system \
  105. flockfile ftrylockfile funlockfile \
  106. sigaction \
  107. herrno res pt-allocrtsig \
  108. pthread_kill_other_threads \
  109. pthread_getaffinity pthread_setaffinity \
  110. pthread_attr_getaffinity pthread_attr_setaffinity \
  111. cleanup_routine unwind-forcedunwind
  112. # pthread_setuid pthread_seteuid pthread_setreuid \
  113. # pthread_setresuid \
  114. # pthread_setgid pthread_setegid pthread_setregid \
  115. # pthread_setresgid
  116. libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
  117. libpthread-static-only-routines = pthread_atfork
  118. CFLAGS-pthread_atfork.c = -DNOT_IN_libc
  119. # Since cancellation handling is in large parts handled using exceptions
  120. # we have to compile some files with exception handling enabled, some
  121. # even with asynchronous unwind tables.
  122. # init.c contains sigcancel_handler().
  123. CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
  124. # The unwind code itself,
  125. CFLAGS-unwind.c = -fexceptions
  126. CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
  127. # The following three functions must be async-cancel safe.
  128. CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
  129. CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
  130. CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
  131. # These are internal functions which similar functionality as setcancelstate
  132. # and setcanceltype.
  133. CFLAGS-cancellation.c = -fasynchronous-unwind-tables
  134. CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
  135. # Calling pthread_exit() must cause the registered cancel handlers to
  136. # be executed. Therefore exceptions have to be thrown through this
  137. # function.
  138. CFLAGS-pthread_exit.c = -fexceptions
  139. # Among others, __pthread_unwind is forwarded. This function must handle
  140. # exceptions.
  141. CFLAGS-forward.c = -fexceptions
  142. # The following are cancellation points. Some of the functions can
  143. # block and therefore temporarily enable asynchronous cancellation.
  144. # Those must be compiled asynchronous unwind tables.
  145. CFLAGS-pthread_testcancel.c = -fexceptions
  146. CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
  147. CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
  148. CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
  149. -fasynchronous-unwind-tables
  150. CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
  151. CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  152. CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
  153. CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
  154. # These are the function wrappers we have to duplicate here.
  155. CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
  156. CFLAGS-lockf.c = -fexceptions
  157. CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
  158. CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
  159. CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
  160. CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
  161. CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
  162. CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
  163. CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
  164. CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
  165. CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
  166. CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
  167. CFLAGS-pt-system.c = -fexceptions
  168. # Don't generate deps for calls with no sources. See sysdeps/unix/Makefile.
  169. omit-deps = $(unix-syscalls:%=ptw-%)
  170. tests = tst-attr1 tst-attr2 tst-attr3 \
  171. tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
  172. tst-mutex7 tst-mutex8 tst-mutex9 tst-mutex5a tst-mutex7a \
  173. tst-spin1 tst-spin2 tst-spin3 \
  174. tst-cond1 tst-cond2 tst-cond3 tst-cond4 tst-cond5 tst-cond6 tst-cond7 \
  175. tst-cond8 tst-cond9 tst-cond10 tst-cond11 tst-cond12 tst-cond13 \
  176. tst-cond14 tst-cond15 tst-cond16 tst-cond17 tst-cond18 tst-cond19 \
  177. tst-cond20 tst-cond21 \
  178. tst-rwlock1 tst-rwlock2 tst-rwlock3 tst-rwlock4 tst-rwlock5 \
  179. tst-rwlock6 tst-rwlock7 tst-rwlock8 tst-rwlock9 tst-rwlock10 \
  180. tst-rwlock11 tst-rwlock12 tst-rwlock13 tst-rwlock14 \
  181. tst-once1 tst-once2 tst-once3 tst-once4 \
  182. tst-key1 tst-key2 tst-key3 tst-key4 \
  183. tst-sem1 tst-sem2 tst-sem3 tst-sem4 tst-sem5 tst-sem6 tst-sem7 \
  184. tst-sem8 tst-sem9 \
  185. tst-barrier1 tst-barrier2 tst-barrier3 tst-barrier4 \
  186. tst-align tst-align2 \
  187. tst-basic1 tst-basic2 tst-basic3 tst-basic4 tst-basic5 tst-basic6 \
  188. tst-kill1 tst-kill2 tst-kill3 tst-kill4 tst-kill5 tst-kill6 \
  189. tst-raise1 \
  190. tst-join1 tst-join2 tst-join3 tst-join4 tst-join5 \
  191. tst-detach1 \
  192. tst-eintr1 tst-eintr2 tst-eintr3 tst-eintr4 tst-eintr5 \
  193. tst-tsd1 tst-tsd2 tst-tsd3 tst-tsd4 tst-tsd5 \
  194. tst-tls1 tst-tls2 \
  195. tst-fork1 tst-fork2 tst-fork3 tst-fork4 \
  196. tst-atfork1 \
  197. tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \
  198. tst-cancel6 tst-cancel7 tst-cancel8 tst-cancel9 tst-cancel10 \
  199. tst-cancel11 tst-cancel12 tst-cancel13 tst-cancel14 tst-cancel15 \
  200. tst-cancel16 tst-cancel17 tst-cancel18 tst-cancel19 tst-cancel20 \
  201. tst-cancel21 tst-cancel22 tst-cancel23 \
  202. tst-cleanup0 tst-cleanup1 tst-cleanup2 tst-cleanup3 tst-cleanup4 \
  203. tst-flock1 tst-flock2 \
  204. tst-signal1 tst-signal2 tst-signal3 tst-signal4 tst-signal5 \
  205. tst-signal6 \
  206. tst-exec1 tst-exec2 tst-exec3 tst-exec4 \
  207. tst-exit1 tst-exit2 tst-exit3 \
  208. tst-stdio1 tst-stdio2 \
  209. tst-stack1 tst-stack2 tst-stack3 \
  210. tst-unload \
  211. tst-dlsym1 \
  212. tst-sysconf \
  213. tst-locale1 tst-locale2 \
  214. tst-umask1 \
  215. tst-popen1 \
  216. tst-clock1 \
  217. tst-context1 \
  218. tst-sched1 \
  219. tst-backtrace1 \
  220. tst-oddstacklimit \
  221. tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
  222. tst-getpid1 tst-getpid2
  223. xtests = tst-setuid1 tst-setuid1-static
  224. # Files which must not be linked with libpthread.
  225. tests-nolibpthread = tst-unload
  226. # This sets the stack resource limit to 1023kb, which is not a multiple
  227. # of the page size since every architecture's page size is > 1k.
  228. tst-oddstacklimit-ENV = ; ulimit -s 1023;
  229. distribute = eintr.c tst-cleanup4aux.c
  230. gen-as-const-headers = pthread-errnos.sym
  231. LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst
  232. include ../Makeconfig
  233. ifeq ($(have-forced-unwind),yes)
  234. tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
  235. tst-cancelx6 tst-cancelx7 tst-cancelx8 tst-cancelx9 tst-cancelx10 \
  236. tst-cancelx11 tst-cancelx12 tst-cancelx13 tst-cancelx14 tst-cancelx15 \
  237. tst-cancelx16 tst-cancelx17 tst-cancelx18 tst-cancelx20 tst-cancelx21 \
  238. tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \
  239. tst-oncex3 tst-oncex4
  240. endif
  241. ifeq ($(build-shared),yes)
  242. tests += tst-atfork2 tst-tls3 tst-tls4 tst-tls5 tst-_res1 tst-fini1
  243. tests-nolibpthread += tst-fini1
  244. ifeq ($(have-z-execstack),yes)
  245. tests += tst-execstack
  246. endif
  247. endif
  248. modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
  249. tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
  250. tst-tls5modd tst-tls5mode tst-tls5modf \
  251. tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod
  252. extra-objs += $(addsuffix .os,$(strip $(modules-names))) tst-cleanup4aux.o
  253. test-extras += $(modules-names)
  254. test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
  255. tst-atfork2mod.so-no-z-defs = yes
  256. tst-tls3mod.so-no-z-defs = yes
  257. tst-tls5mod.so-no-z-defs = yes
  258. tst-tls5moda.so-no-z-defs = yes
  259. tst-tls5modb.so-no-z-defs = yes
  260. tst-tls5modc.so-no-z-defs = yes
  261. tst-tls5modd.so-no-z-defs = yes
  262. tst-tls5mode.so-no-z-defs = yes
  263. tst-tls5modf.so-no-z-defs = yes
  264. $(test-modules): $(objpfx)%.so: $(objpfx)%.os $(common-objpfx)shlib.lds
  265. $(build-module)
  266. ifeq ($(build-shared),yes)
  267. # Build all the modules even when not actually running test programs.
  268. tests: $(test-modules)
  269. endif
  270. ifeq ($(build-shared),yes)
  271. # Set the `multidir' variable by grabbing the variable from the compiler.
  272. # We do it once and save the result in a generated makefile.
  273. -include $(objpfx)multidir.mk
  274. $(objpfx)multidir.mk: $(common-objpfx)config.make
  275. $(make-target-directory)
  276. dir=`$(CC) $(CFLAGS) $(CPPFLAGS) -print-multi-directory`; \
  277. echo "multidir := $$dir" > $@T
  278. mv -f $@T $@
  279. crti-objs := crti.o
  280. crtn-objs := crtn.o
  281. ifneq (,$(patsubst .,,$(multidir)))
  282. generated-dirs := $(firstword $(subst /, , $(multidir)))
  283. crti-objs += $(multidir)/crti.o
  284. crtn-objs += $(multidir)/crtn.o
  285. omit-deps += $(multidir)/crti $(multidir)/crtn
  286. $(objpfx)$(multidir):
  287. mkdir $@
  288. endif
  289. extra-objs += $(crti-objs) $(crtn-objs)
  290. omit-deps += crti crtn
  291. CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
  292. endif
  293. CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
  294. CFLAGS-ftrylockfile.c = -D_IO_MTSAFE_IO
  295. CFLAGS-funlockfile.c = -D_IO_MTSAFE_IO
  296. link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
  297. $(common-objpfx)libc.a
  298. ifeq ($(build-static),yes)
  299. tests-static += tst-locale1 tst-locale2
  300. xtests-static += tst-setuid1-static
  301. endif
  302. # These tests are linked with libc before libpthread
  303. tests-reverse += tst-cancel5 tst-cancel23 tst-vfork1x tst-vfork2x
  304. include ../Rules
  305. ifeq (yes,$(build-shared))
  306. # Make sure these things are built in the `make lib' pass so they can be used
  307. # to run programs during the `make others' pass.
  308. lib-noranlib: $(addprefix $(objpfx),$(extra-objs))
  309. # What we install as libpthread.so for programs to link against is in fact a
  310. # link script. It contains references for the various libraries we need.
  311. # The libpthread.so object is not complete since some functions are only
  312. # defined in libpthread_nonshared.a.
  313. # We need to use absolute paths since otherwise local copies (if they exist)
  314. # of the files are taken by the linker.
  315. install: $(inst_libdir)/libpthread.so
  316. $(inst_libdir)/libpthread.so: $(common-objpfx)format.lds \
  317. $(objpfx)libpthread.so$(libpthread.so-version) \
  318. $(inst_libdir)/$(patsubst %,$(libtype.oS),\
  319. $(libprefix)pthread) \
  320. $(+force)
  321. (echo '/* GNU ld script';\
  322. echo ' Use the shared library, but some functions are only in';\
  323. echo ' the static library, so try that secondarily. */';\
  324. cat $<; \
  325. echo 'GROUP ( $(slibdir)/libpthread.so$(libpthread.so-version)' \
  326. '$(libdir)/$(patsubst %,$(libtype.oS),$(libprefix)pthread)'\
  327. ')' \
  328. ) > $@.new
  329. mv -f $@.new $@
  330. endif
  331. # 'pthread_self' is a simple memory or register load. Setting up the
  332. # stack frame is more work than the actual operation. Disable the
  333. # frame creation entirely. This will help applications which call the
  334. # function frequently to get a thread-specific handle.
  335. CFLAGS-pthread_self.os += -fomit-frame-pointer
  336. # Run the cancellation and cleanup tests also for the modern, exception-based
  337. # implementation. For this we have to pass the -fexceptions parameter.
  338. CFLAGS-tst-cancelx2.c += -fexceptions
  339. CFLAGS-tst-cancelx3.c += -fexceptions
  340. CFLAGS-tst-cancelx4.c += -fexceptions
  341. CFLAGS-tst-cancelx5.c += -fexceptions
  342. CFLAGS-tst-cancelx6.c += -fexceptions
  343. CFLAGS-tst-cancelx7.c += -fexceptions
  344. CFLAGS-tst-cancelx8.c += -fexceptions
  345. CFLAGS-tst-cancelx9.c += -fexceptions
  346. CFLAGS-tst-cancelx10.c += -fexceptions
  347. CFLAGS-tst-cancelx11.c += -fexceptions
  348. CFLAGS-tst-cancelx12.c += -fexceptions
  349. CFLAGS-tst-cancelx13.c += -fexceptions
  350. CFLAGS-tst-cancelx14.c += -fexceptions
  351. CFLAGS-tst-cancelx15.c += -fexceptions
  352. CFLAGS-tst-cancelx16.c += -fexceptions
  353. CFLAGS-tst-cancelx17.c += -fexceptions
  354. CFLAGS-tst-cancelx18.c += -fexceptions
  355. CFLAGS-tst-cancelx20.c += -fexceptions -fasynchronous-unwind-tables
  356. CFLAGS-tst-cancelx21.c += -fexceptions -fasynchronous-unwind-tables
  357. CFLAGS-tst-cleanupx0.c += -fexceptions -fasynchronous-unwind-tables
  358. CFLAGS-tst-cleanupx1.c += -fexceptions -fasynchronous-unwind-tables
  359. CFLAGS-tst-cleanupx2.c += -fexceptions
  360. CFLAGS-tst-cleanupx3.c += -fexceptions
  361. CFLAGS-tst-cleanupx4.c += -fexceptions
  362. CFLAGS-tst-oncex3.c += -fexceptions
  363. CFLAGS-tst-oncex4.c += -fexceptions
  364. CFLAGS-tst-align.c += $(stack-align-test-flags)
  365. tst-cancel7-ARGS = --command "$(built-program-cmd)"
  366. tst-cancelx7-ARGS = $(tst-cancel7-ARGS)
  367. tst-umask1-ARGS = $(objpfx)tst-umask1.temp
  368. $(objpfx)tst-atfork2: $(libdl) $(shared-thread-library)
  369. LDFLAGS-tst-atfork2 = -rdynamic
  370. tst-atfork2-ENV = MALLOC_TRACE=$(objpfx)tst-atfork2.mtrace
  371. $(objpfx)tst-atfork2mod.so: $(shared-thread-library)
  372. tests: $(objpfx)tst-stack3-mem
  373. tst-stack3-ENV = MALLOC_TRACE=$(objpfx)tst-stack3.mtrace
  374. $(objpfx)tst-stack3-mem: $(objpfx)tst-stack3.out
  375. $(common-objpfx)malloc/mtrace $(objpfx)tst-stack3.mtrace > $@
  376. generated += tst-stack3-mem tst-stack3.mtrace
  377. $(objpfx)tst-cleanup4: $(objpfx)tst-cleanup4aux.o $(shared-thread-library)
  378. $(objpfx)tst-cleanupx4: $(objpfx)tst-cleanup4aux.o $(shared-thread-library)
  379. $(objpfx)tst-tls3: $(libdl) $(shared-thread-library)
  380. LDFLAGS-tst-tls3 = -rdynamic
  381. $(objpfx)tst-tls3.out: $(objpfx)tst-tls3mod.so
  382. $(objpfx)tst-tls3mod.so: $(shared-thread-library)
  383. $(objpfx)tst-tls4: $(libdl) $(shared-thread-library)
  384. $(objpfx)tst-tls4.out: $(objpfx)tst-tls4moda.so $(objpfx)tst-tls4modb.so
  385. $(objpfx)tst-tls5: $(objpfx)tst-tls5mod.so $(shared-thread-library)
  386. LDFLAGS-tst-tls5mod.so = -Wl,-soname,tst-tls5mod.so
  387. ifeq ($(build-shared),yes)
  388. tests: $(objpfx)tst-tls6.out
  389. $(objpfx)tst-tls6.out: tst-tls6.sh $(objpfx)tst-tls5 \
  390. $(objpfx)tst-tls5moda.so $(objpfx)tst-tls5modb.so \
  391. $(objpfx)tst-tls5modc.so $(objpfx)tst-tls5modd.so \
  392. $(objpfx)tst-tls5mode.so $(objpfx)tst-tls5modf.so
  393. $(SHELL) -e tst-tls6.sh $(common-objpfx) $(elf-objpfx) \
  394. $(rtld-installed-name)
  395. endif
  396. $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library)
  397. $(objpfx)tst-fini1: $(shared-thread-library) $(objpfx)tst-fini1mod.so
  398. ifeq (yes,$(build-shared))
  399. $(objpfx)tst-cond11: $(common-objpfx)rt/librt.so
  400. $(objpfx)tst-cond19: $(common-objpfx)rt/librt.so
  401. $(objpfx)tst-cancel17: $(common-objpfx)rt/librt.so
  402. $(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.so
  403. $(objpfx)tst-cancel18: $(common-objpfx)rt/librt.so
  404. $(objpfx)tst-cancelx18: $(common-objpfx)rt/librt.so
  405. $(objpfx)tst-clock2: $(common-objpfx)rt/librt.so
  406. $(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.so
  407. $(objpfx)tst-_res1mod2.so: $(objpfx)tst-_res1mod1.so
  408. LDFLAGS-tst-_res1mod1.so = -Wl,-soname,tst-_res1mod1.so
  409. LDFLAGS-tst-_res1mod2.so = -Wl,-soname,tst-_res1mod2.so
  410. $(objpfx)tst-_res1: $(objpfx)tst-_res1mod2.so $(shared-thread-library)
  411. else
  412. $(objpfx)tst-cond11: $(common-objpfx)rt/librt.a
  413. $(objpfx)tst-cond19: $(common-objpfx)rt/librt.a
  414. $(objpfx)tst-cancel17: $(common-objpfx)rt/librt.a
  415. $(objpfx)tst-cancelx17: $(common-objpfx)rt/librt.a
  416. $(objpfx)tst-cancel18: $(common-objpfx)rt/librt.a
  417. $(objpfx)tst-cancelx18: $(common-objpfx)rt/librt.a
  418. $(objpfx)tst-clock2: $(common-objpfx)rt/librt.a
  419. $(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
  420. endif
  421. extra-B-pthread.so = -B$(common-objpfx)nptl/
  422. $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
  423. $(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
  424. $(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
  425. # Depend on libc.so so a DT_NEEDED is generated in the shared objects.
  426. # This ensures they will load libc.so for needed symbols if loaded by
  427. # a statically-linked program that hasn't already loaded it.
  428. # Depend on ld.so too to get proper versions of ld.so symbols.
  429. $(objpfx)libpthread.so: $(common-objpfx)libc.so \
  430. $(common-objpfx)libc_nonshared.a \
  431. $(if $(filter yes,$(elf)), $(elfobjdir)/ld.so)
  432. # Make sure we link with the thread library.
  433. ifeq ($(build-shared),yes)
  434. $(addprefix $(objpfx), \
  435. $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
  436. $(tests-nolibpthread), \
  437. $(tests) $(xtests) $(test-srcs))): $(objpfx)libpthread.so \
  438. $(objpfx)libpthread_nonshared.a
  439. $(objpfx)tst-unload: $(common-objpfx)dlfcn/libdl.so
  440. # $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
  441. # since otherwise libpthread.so comes before libc.so when linking.
  442. $(addprefix $(objpfx), $(tests-reverse)): \
  443. $(objpfx)../libc.so $(objpfx)libpthread.so \
  444. $(objpfx)libpthread_nonshared.a
  445. $(objpfx)../libc.so: $(common-objpfx)libc.so ;
  446. $(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
  447. $(objpfx)tst-atfork2.out: $(objpfx)tst-atfork2mod.so
  448. else
  449. $(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
  450. endif
  451. ifeq ($(build-shared),yes)
  452. vpath pt-initfini.c $(full_config_sysdirs)
  453. $(objpfx)pt-initfini.s: pt-initfini.c
  454. $(compile.c) -S $(CFLAGS-pt-initfini.s) -finhibit-size-directive \
  455. $(patsubst -f%,-fno-%,$(exceptions)) -o $@
  456. $(objpfx)tst-cleanup0.out: /dev/null $(objpfx)tst-cleanup0
  457. $(make-test-out) 2>&1 | cmp - tst-cleanup0.expect >& $@
  458. # We only have one kind of startup code files. Static binaries and
  459. # shared libraries are build using the PIC version.
  460. $(objpfx)crti.S: $(objpfx)pt-initfini.s
  461. sed -n -e '1,/@HEADER_ENDS/p' \
  462. -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
  463. -e '/@TRAILER_BEGINS/,$$p' $< > $@
  464. $(objpfx)crtn.S: $(objpfx)pt-initfini.s
  465. sed -n -e '1,/@HEADER_ENDS/p' \
  466. -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
  467. -e '/@TRAILER_BEGINS/,$$p' $< > $@
  468. $(objpfx)defs.h: $(objpfx)pt-initfini.s
  469. sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
  470. $(AWK) -f ../csu/defs.awk > $@
  471. $(objpfx)crti.o: $(objpfx)crti.S $(objpfx)defs.h
  472. $(compile.S) -g0 $(ASFLAGS-.os) -o $@
  473. $(objpfx)crtn.o: $(objpfx)crtn.S $(objpfx)defs.h
  474. $(compile.S) -g0 $(ASFLAGS-.os) -o $@
  475. ifneq ($(multidir),.)
  476. $(objpfx)$(multidir)/crti.o: $(objpfx)crti.o $(objpfx)$(multidir)/
  477. ln -f $< $@
  478. $(objpfx)$(multidir)/crtn.o: $(objpfx)crtn.o $(objpfx)$(multidir)/
  479. ln -f $< $@
  480. endif
  481. generated += crti.S crtn.S defs.h pt-initfini.s libpthread_nonshared.a \
  482. multidir.mk tst-atfork2.mtrace tst-cancel-wrappers.out \
  483. tst-tls6.out
  484. generated += $(objpfx)tst-atfork2.mtrace \
  485. $(addsuffix .so,$(strip $(modules-names)))
  486. $(objpfx)version.d: $(objpfx)banner.h
  487. $(objpfx)version.os: $(objpfx)banner.h
  488. $(objpfx)banner.h: Banner
  489. sed 's/\(.*\)/"\1\\n"/' $< > $@
  490. generated += banner.h
  491. # Give libpthread.so an entry point and make it directly runnable itself.
  492. LDFLAGS-pthread.so += -e __nptl_main
  493. endif
  494. ifeq (no,$(cross-compiling))
  495. ifeq (yes,$(build-shared))
  496. tests: $(objpfx)tst-cancel-wrappers.out
  497. $(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
  498. $(SHELL) $< $(common-objpfx)libc_pic.a \
  499. $(common-objpfx)libc.a \
  500. $(objpfx)libpthread_pic.a \
  501. $(objpfx)libpthread.a > $@
  502. endif
  503. endif
  504. tst-exec4-ARGS = $(built-program-cmd)
  505. $(objpfx)tst-execstack: $(libdl)
  506. $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
  507. LDFLAGS-tst-execstack = -Wl,-z,noexecstack
  508. $(objpfx)tst-fini1mod.so: $(shared-thread-library)
  509. # The tests here better do not run in parallel
  510. ifneq ($(filter %tests,$(MAKECMDGOALS)),)
  511. .NOTPARALLEL:
  512. endif