syslog: Improve fortify with clang
[glibc.git] / sysdeps / mach / hurd / Makefile
blob698729a8a6a289d33da730716fcde881ac5e754e
1 # Copyright (C) 1993-2024 Free Software Foundation, Inc.
2 # This file is part of the GNU C Library.
4 # The GNU C Library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # The GNU C Library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with the GNU C Library; if not, see
16 # <https://www.gnu.org/licenses/>.
18 ifdef in-Makerules
20 # Look for header files in hurd/ under the top-level library source directory.
21 # Look for generated header files where they get created.
22 includes += -I$(..)hurd -I$(common-objpfx)hurd/
24 # We use the style `if (err = call(...))' a lot in the Hurd code,
25 # where we have a lot of functions that return zero or an errno code.
26 +cflags += -Wno-parentheses
28 # Do not use any assembly code from sysdeps/unix (and subdirectories).
29 # This bypasses all the system call stubs and uses any existing posix or
30 # generic C files instead.
31 inhibit-sysdep-asm += unix.*
32 inhibit-unix-syscalls = yes
34 # Don't try to generate anything from the installed Unix system and its
35 # libraries. That is only of use when building for a Unix system, so as to
36 # be compatible with some existing binaries for that system.
37 inhibit-glue = yes
39 ifeq (,$(filter mach hurd,$(subdir)))
40 # Subdirectories other than hurd/ might use the generated Hurd headers.
41 # So make sure we get a chance to run in hurd/ to make them before all else.
42 # (But we don't want to do this in mach/, because hurd/ needs some things
43 # there, and we know mach/ doesn't need anything from hurd/.)
45 hurd-objpfx = $(common-objpfx)hurd/
47 # These are all the generated headers that <hurd.h> includes.
48 before-compile += $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process)
49 $(patsubst %,$(hurd-objpfx)hurd/%.h,auth io fs process): hurd-before-compile
50 .PHONY: hurd-before-compile
51 hurd-before-compile: $(common-objpfx)mach/mach-shortcuts.h
52 $(MAKE) -C $(..)hurd subdir=hurd before-compile no_deps=t
53 endif
55 # Hurd profil.c includes this file, so give a rule to make it.
56 ifeq ($(subdir),gmon)
57 $(common-objpfx)hurd/../mach/RPC_task_get_sampled_pcs.c:
58 $(MAKE) -C $(..)mach subdir=mach before-compile no_deps=t
59 endif
62 # Generate bits/errno.h from the section of the manual that lists all the errno
63 # codes.
65 errno.texinfo = $(..)manual/errno.texi
67 hurd = $(..)sysdeps/mach/hurd
69 mach-errno-h = \
70 mach/message.h \
71 mach/kern_return.h \
72 mach/mig_errors.h \
73 device/device_types.h
75 # We use the compiler to generate a list of absolute file names for
76 # the headers we want to search for Mach error codes, listed above (and
77 # incidentally, all other headers those include).
78 -include $(common-objpfx)errnos.d
79 $(common-objpfx)errnos.d: $(mach-errnos-deps)
80 echo -n "mach-errnos-deps := " > $@t
81 for h in $(mach-errno-h) ; do \
82 echo "#include <$$h>" \
83 | $(CC) $(CFLAGS) \
84 $(subst -include $(common-objpfx)libc-modules.h,,$(CPPFLAGS)) \
85 -M -x c - \
86 | sed $(sed-remove-objpfx) \
87 -e 's, \.\./, $(..),g' \
88 -e 's,\\$$,,g' \
89 -e 's, ,\n,g' \
90 | grep "$$h$$" \
91 | tr '\n' ' ' \
92 >> $@t ; \
93 done
94 echo >> $@t
95 mv -f $@t $@
97 $(hurd)/bits/errno.h: $(common-objpfx)stamp-errnos ;
98 $(common-objpfx)stamp-errnos: $(hurd)/errnos.awk $(errno.texinfo) \
99 $(mach-errnos-deps) $(common-objpfx)errnos.d
100 mkdir -p $(hurd-objpfx)bits
101 $(AWK) -f $^ > $(hurd-objpfx)bits/errno.h-tmp
102 # Make it unwritable so no one will edit it by mistake.
103 -chmod a-w $(hurd-objpfx)bits/errno.h-tmp
104 $(move-if-change) $(hurd-objpfx)bits/errno.h-tmp $(hurd)/bits/errno.h
105 touch $@
107 common-generated += errnos.d stamp-errnos
109 # We install the real libc.a as libcrt.a and as libc.a we install a linker
110 # script which does -( -lcrt -lmachuser -lhurduser -).
112 libc-name = crt
114 ifeq (,$(subdir))
115 install-others += $(inst_libdir)/libc.a
116 $(inst_libdir)/libc.a: $(hurd)/libc-ldscript $(+force); $(do-install)
117 ifeq (yes,$(build-profile))
118 install-others += $(inst_libdir)/libc_p.a
119 $(inst_libdir)/libc_p.a: $(hurd)/libc_p-ldscript $(+force); $(do-install)
120 endif
121 endif
123 # Make sure these are used to build the libc.so shared object too. There
124 # is a circular dependency between each of these shared objects and libc
125 # (many high-level libc functions call stubs, stubs call low-level libc
126 # functions like memcpy and mach_msg). This works out fine at run time
127 # (all the objects are loaded before resolving their symbols, so these
128 # interdependencies are fine). But to create the shared objects we must
129 # link them one at a time; since each needs one or both of the others to
130 # produce its DT_NEEDED entries and to assign its undefined symbols the
131 # right symbol versions, we can't do any of them before the others! To
132 # get around this, we link each lib*user.so shared object twice. First,
133 # we link an object without reference to libc.so (since we haven't linked
134 # libc.so yet), so it lacks a DT_NEEDED record for the libc soname it
135 # depends on, and its undefined symbol references lack the symbol version
136 # assignments they should have. We will use this shared object solely to
137 # link libc.so against it; that gives libc.so the proper DT_NEEDED record,
138 # and symbol versions assignments (if the lib*user.so object is using them).
139 # Finally we link a second version of the same lib*user.so shared object,
140 # this time linked normally against libc so it gets a proper DT_NEEDED
141 # record and symbol version set; this one can be installed for run-time use.
142 rpcuserlibs := $(common-objpfx)mach/libmachuser.so \
143 $(common-objpfx)hurd/libhurduser.so
144 link-rpcuserlibs := $(rpcuserlibs:%user.so=%user-link.so)
145 $(common-objpfx)libc.so: $(link-rpcuserlibs)
146 $(common-objpfx)linkobj/libc.so: $(link-rpcuserlibs)
147 rpath-dirs += mach hurd
149 # Make sure the `lib' pass builds the dummy shared objects so
150 # we can link libc against them.
151 ifeq (mach,$(subdir))
152 lib-noranlib: $(common-objpfx)mach/libmachuser-link.so
153 endif
154 ifeq (hurd,$(subdir))
155 lib-noranlib: $(common-objpfx)hurd/libhurduser-link.so
156 endif
158 $(link-rpcuserlibs): %-link.so: %_pic.a
159 # These shared objects are just for the purpose of linking libc,
160 # so they don't need abi-note.o linked into them.
161 $(build-shlib-helper) \
162 -nostdlib -o $@ \
163 -Wl,-soname=$(*F).so$($(*F).so-version) \
164 $(build-shlib-objlist)
165 libmachuser-link.so-no-z-defs = yes
166 libhurduser-link.so-no-z-defs = yes
168 # And get them into the libc.so ldscript.
169 $(inst_libdir)/libc.so: $(rpcuserlibs)
171 # The RPC stubs from these libraries are needed in building the dynamic
172 # linker, too. It must be self-contained, so we link the needed PIC
173 # objects directly into the shared object.
174 ifeq (elf,$(subdir))
175 $(objpfx)librtld.map: $(rpcuserlibs:.so=_pic.a)
177 CFLAGS-dl-load.c = -DEXTERNAL_MAP_FROM_FD
178 endif
180 # Override the generic Makeconfig values so we link against the RPC libs.
181 link-libc-static := -Wl,--start-group \
182 $(patsubst %,$(common-objpfx)%.a,\
183 libc mach/libmachuser hurd/libhurduser) \
184 $(static-gnulib) -Wl,--end-group
185 link-libc-static-tests := -Wl,--start-group \
186 $(patsubst %,$(common-objpfx)%.a,\
187 libc mach/libmachuser hurd/libhurduser) \
188 $(static-gnulib-tests) -Wl,--end-group
190 ifeq ($(subdir),csu)
192 extra-objs += static-start.o
194 # We need special startup code for statically linked binaries.
195 $(objpfx)crt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o $(objpfx)static-reloc.o
196 $(link-relocatable)
197 $(objpfx)rcrt0.o: $(objpfx)static-start.o $(objpfx)abi-note.o $(objpfx)init.o
198 $(link-relocatable)
200 endif
202 ifeq (hurd, $(subdir))
203 sysdep_routines += cthreads
204 endif
206 ifeq (elf, $(subdir))
207 sysdep-dl-routines += dl-tls-initialized
208 endif
210 ifeq (io, $(subdir))
211 sysdep_routines += f_setlk close_nocancel close_nocancel_nostatus \
212 fcntl_nocancel open_nocancel openat_nocancel read_nocancel \
213 pread64_nocancel write_nocancel pwrite64_nocancel \
214 wait4_nocancel \
215 xstat fxstat lxstat xstat64 fxstat64 lxstat64 \
216 xmknod xmknodat \
217 fxstatat fxstatat64
219 sysdep_headers += bits/types/struct_flock.h
220 endif
222 ifeq (misc, $(subdir))
223 sysdep_routines += writev_nocancel writev_nocancel_nostatus mremap
224 endif
226 ifeq ($(subdir),sunrpc)
227 sysdep_headers += nfs/nfs.h
228 endif
230 ifeq ($(subdir),socket)
231 sysdep_headers += net/ethernet.h net/if_arp.h net/if_ether.h net/route.h
232 endif
234 ifeq ($(subdir),nis)
235 CFLAGS-ypclnt.c += -DUSE_BINDINGDIR=1
236 endif
238 LDLIBS-pthread.so += $(objdir)/hurd/libhurduser.so
239 LDLIBS-c_malloc_debug.so += $(link-rpcuserlibs)
241 endif # in-Makerules
243 # For bug 23286
244 ifeq ($(subdir),hurd)
245 test-xfail-check-abi-libhurduser = yes
246 endif
247 ifeq ($(subdir),mach)
248 test-xfail-check-abi-libmachuser = yes
249 endif
251 # For bug 25521
252 # (setpshared support)
253 ifeq ($(subdir),malloc)
254 test-xfail-tst-mallocfork2 = yes
255 test-xfail-tst-mallocfork2-mcheck = yes
256 test-xfail-tst-mallocfork2-malloc-check = yes
257 test-xfail-tst-mallocfork2-malloc-hugetlb1 = yes
258 test-xfail-tst-mallocfork2-malloc-hugetlb2 = yes
259 endif
260 ifeq ($(subdir),htl)
261 test-xfail-tst-mutex4 = yes
262 test-xfail-tst-cancel16 = yes
263 test-xfail-tst-cancelx16 = yes
264 test-xfail-tst-cond4 = yes
265 test-xfail-tst-cond6 = yes
266 test-xfail-tst-cond12 = yes
267 test-xfail-tst-cond13 = yes
268 test-xfail-tst-cond23 = yes
269 test-xfail-tst-rwlock4 = yes
270 test-xfail-tst-rwlock12 = yes
271 test-xfail-tst-barrier2 = yes
272 test-xfail-tst-pututxline-cache = yes
273 test-xfail-tst-pututxline-lockfail = yes
274 test-xfail-tst-flock2 = yes
275 test-xfail-tst-signal1 = yes
276 test-xfail-tst-signal2 = yes
277 endif
279 ifeq ($(subdir),htl)
280 # For bug 25522
281 # (setprotocol support)
282 test-xfail-tst-cond24 = yes
283 test-xfail-tst-cond25 = yes
285 # For bug 25563
286 # (robust support against dead threads)
287 test-xfail-tst-robust1 = yes
288 test-xfail-tst-robust2 = yes
289 test-xfail-tst-robust3 = yes
290 test-xfail-tst-robust4 = yes
291 test-xfail-tst-robust5 = yes
292 test-xfail-tst-robust6 = yes
293 test-xfail-tst-robust7 = yes
294 test-xfail-tst-robust9 = yes
295 endif
297 ifeq ($(subdir),elf)
298 # We do use nested functions involving creation of trampolines, notably for
299 # callbacks whose parameters don't permit to get the context parameters.
300 check-execstack-xfail += ld.so libc.so libpthread.so
301 # We always create a thread for signals
302 test-xfail-tst-single_threaded-pthread-static = yes
303 endif
305 # For bug 30166
306 # (missing RLIMIT_AS support)
307 ifeq ($(subdir),malloc)
308 tests-unsupported += tst-malloc-thread-fail
309 tests-unsupported += tst-malloc-thread-fail-malloc-check
310 tests-unsupported += tst-malloc-thread-fail-mcheck
311 tests-unsupported += tst-malloc-thread-fail-malloc-hugetlb1
312 tests-unsupported += tst-malloc-thread-fail-malloc-hugetlb2
313 tests-unsupported += tst-dynarray-fail
314 endif
316 # For bug 30167
317 # (select requests overflow)
318 ifeq ($(subdir),htl)
319 tests-unsupported += tst-pthread_cancel-select-loop
320 endif
322 # For bug 30168
323 # (audit tests hang)
324 ifeq ($(subdir),elf)
325 tests-unsupported += tst-audit14
326 tests-unsupported += tst-audit14a
327 tests-unsupported += tst-audit15
328 tests-unsupported += tst-audit16
329 tests-unsupported += tst-audit17
330 endif
332 # For bug 30341
333 ifeq ($(subdir),posix)
334 tests-unsupported += tst-spawn6
335 endif
337 # For bug 30342
338 ifeq ($(subdir),io)
339 tests-unsupported += test-lfs
340 endif