misc: tst-poll: Proper synchronize with child before sending the signal
[glibc.git] / gmon / Makefile
blob4e1a4a309cc06b683e15c2889cd8fd1c95936dcb
1 # Copyright (C) 1995-2024 Free Software Foundation, Inc.
2 # Copyright The GNU Toolchain Authors.
3 # This file is part of the GNU C Library.
5 # The GNU C Library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # The GNU C Library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with the GNU C Library; if not, see
17 # <https://www.gnu.org/licenses/>.
20 # Sub-makefile for gmon portion of the library.
22 subdir := gmon
24 include ../Makeconfig
26 headers := sys/gmon.h sys/gmon_out.h sys/profil.h
27 routines := gmon mcount profil sprofil prof-freq
29 tests = tst-sprofil tst-gmon tst-mcount-overflow tst-mcleanup
30 ifeq ($(build-profile),yes)
31 tests += tst-profile-static
32 tests-static += tst-profile-static
34 LDFLAGS-tst-profile-static = -profile
35 endif
37 tests += tst-gmon-static
38 tests-static += tst-gmon-static
40 ifeq (yesyes,$(have-fpie)$(build-shared))
41 tests += tst-gmon-pie
42 tests-pie += tst-gmon-pie
43 ifeq (yes,$(enable-static-pie))
44 tests += tst-gmon-static-pie
45 tests-static += tst-gmon-static-pie
46 endif
47 endif
49 # The mcount code won't work without a frame pointer.
50 CFLAGS-mcount.c := -fno-omit-frame-pointer
52 CFLAGS-tst-gmon.c := -fno-omit-frame-pointer -pg
53 tst-gmon-no-pie = yes
54 CRT-tst-gmon := $(csu-objpfx)g$(start-installed-name)
55 tst-gmon-ENV := GMON_OUT_PREFIX=$(objpfx)tst-gmon.data
56 ifeq ($(run-built-tests),yes)
57 tests-special += $(objpfx)tst-gmon-gprof.out
58 endif
60 CFLAGS-tst-mcount-overflow.c := -fno-omit-frame-pointer -pg
61 tst-mcount-overflow-no-pie = yes
62 CRT-tst-mcount-overflow := $(csu-objpfx)g$(start-installed-name)
63 # Intentionally use invalid config where maxarcs<minarcs to check warning is printed
64 tst-mcount-overflow-ENV := GMON_OUT_PREFIX=$(objpfx)tst-mcount-overflow.data \
65 GLIBC_TUNABLES=glibc.gmon.minarcs=51:glibc.gmon.maxarcs=50
66 # Send stderr into output file because we make sure expected messages are printed
67 tst-mcount-overflow-ARGS := 2>&1 1>/dev/null | cat
68 ifeq ($(run-built-tests),yes)
69 tests-special += $(objpfx)tst-mcount-overflow-check.out
70 endif
72 CFLAGS-tst-mcleanup.c := -fno-omit-frame-pointer -pg
73 tst-mcleanup-no-pie = yes
74 CRT-tst-mcleanup := $(csu-objpfx)g$(start-installed-name)
75 tst-mcleanup-ENV := GMON_OUT_PREFIX=$(objpfx)tst-mcleanup.data
76 ifeq ($(run-built-tests),yes)
77 tests-special += $(objpfx)tst-mcleanup.out
78 endif
80 CFLAGS-tst-gmon-static.c := $(PIE-ccflag) -fno-omit-frame-pointer -pg
81 CRT-tst-gmon-static := $(csu-objpfx)g$(static-start-installed-name)
82 tst-gmon-static-no-pie = yes
83 tst-gmon-static-ENV := GMON_OUT_PREFIX=$(objpfx)tst-gmon-static.data
84 ifeq ($(run-built-tests),yes)
85 tests-special += $(objpfx)tst-gmon-static-gprof.out
86 endif
88 CFLAGS-tst-gmon-pie.c := $(PIE-ccflag) -fno-omit-frame-pointer -pg
89 CRT-tst-gmon-pie := $(csu-objpfx)g$(start-installed-name)
90 tst-gmon-pie-ENV := GMON_OUT_PREFIX=$(objpfx)tst-gmon-pie.data
91 ifeq ($(run-built-tests),yes)
92 tests-special += $(objpfx)tst-gmon-pie-gprof.out
93 endif
95 ifeq (yes,$(enable-static-pie))
96 CFLAGS-tst-gmon-static-pie.c := $(PIE-ccflag) -fno-omit-frame-pointer -pg
97 CRT-tst-gmon-static-pie := $(csu-objpfx)gr$(static-start-installed-name)
98 tst-gmon-static-pie-ENV := GMON_OUT_PREFIX=$(objpfx)tst-gmon-static-pie.data
99 ifeq ($(run-built-tests),yes)
100 tests-special += $(objpfx)tst-gmon-static-pie-gprof.out
101 endif
102 endif
105 include ../Rules
107 # We cannot compile mcount.c with -pg because that would
108 # create recursive calls. Just copy the normal static object.
109 # On systems where `profil' is not a system call, the same
110 # problem exists for the internal functions in profil.c.
112 noprof := mcount $(sysdep_noprof)
113 ifeq (,$(filter profil,$(unix-syscalls)))
114 noprof += profil sprofil
115 endif
117 $(noprof:%=$(objpfx)%.op): %.op: %.o
118 rm -f $@
119 ln $< $@
121 # GMON_OUTPUT_PREFIX only sets the output prefix. The actual file
122 # name contains the PID as well.
123 $(objpfx)tst-gmon.out: clean-tst-gmon-data
124 clean-tst-gmon-data:
125 rm -f $(objpfx)tst-gmon.data.*
127 $(objpfx)tst-mcount-overflow.o: clean-tst-mcount-overflow-data
128 clean-tst-mcount-overflow-data:
129 rm -f $(objpfx)tst-mcount-overflow.data.*
131 $(objpfx)tst-mcount-overflow-check.out: tst-mcount-overflow-check.sh $(objpfx)tst-mcount-overflow.out
132 $(SHELL) $< $(objpfx)tst-mcount-overflow > $@; \
133 $(evaluate-test)
135 $(objpfx)tst-mcleanup.out: clean-tst-mcleanup-data
136 clean-tst-mcleanup-data:
137 rm -f $(objpfx)tst-mcleanup.data.*
139 $(objpfx)tst-gmon-gprof.out: tst-gmon-gprof.sh $(objpfx)tst-gmon.out
140 $(SHELL) $< $(GPROF) $(objpfx)tst-gmon $(objpfx)tst-gmon.data.* > $@; \
141 $(evaluate-test)
143 $(objpfx)tst-gmon-static.out: clean-tst-gmon-static-data
144 clean-tst-gmon-static-data:
145 rm -f $(objpfx)tst-gmon-static.data.*
147 $(objpfx)tst-gmon-static-gprof.out: tst-gmon-static-gprof.sh \
148 $(objpfx)tst-gmon-static.out
149 $(SHELL) $< $(GPROF) $(objpfx)tst-gmon-static \
150 $(objpfx)tst-gmon-static.data.* > $@; \
151 $(evaluate-test)
153 $(objpfx)tst-gmon-pie.out: clean-tst-gmon-pie-data
154 clean-tst-gmon-pie-data:
155 rm -f $(objpfx)tst-gmon-pie.data.*
157 $(objpfx)tst-gmon-pie-gprof.out: tst-gmon-gprof.sh $(objpfx)tst-gmon-pie.out
158 $(SHELL) $< $(GPROF) $(objpfx)tst-gmon-pie $(objpfx)tst-gmon-pie.data.* > $@; \
159 $(evaluate-test)
161 $(objpfx)tst-gmon-static-pie.out: clean-tst-gmon-static-pie-data
162 clean-tst-gmon-static-pie-data:
163 rm -f $(objpfx)tst-gmon-static-pie.data.*
165 $(objpfx)tst-gmon-static-pie-gprof.out: tst-gmon-static-gprof.sh \
166 $(objpfx)tst-gmon-static-pie.out
167 $(SHELL) $< $(GPROF) $(objpfx)tst-gmon-static-pie \
168 $(objpfx)tst-gmon-static-pie.data.* > $@; \
169 $(evaluate-test)