shenki's glibc patch adapted to 2.36.1 for bookworm
[glibc.git] / sysdeps / powerpc / powerpc64 / le / Makefile
1 # When building float128 we need to ensure -mfloat128 is
2 # passed to all such object files.
3 type-float128-CFLAGS := -mfloat128
4
5 # Bootstrapping code for enabling IEEE 128. This can be removed and
6 # any indirections simplified once IEEE 128 long double is enabled.
7 type-ldouble-CFLAGS =
8 no-gnu-attribute-CFLAGS =
9 ifeq ($(ibm128-fcts),yes)
10 ibm128-abi-CFLAGS := -mabi=ibmlongdouble
11 type-ldouble-CFLAGS += $(ibm128-abi-CFLAGS)
12 no-gnu-attribute-CFLAGS = -mno-gnu-attribute
13
14 # This is a very gnarly workaround to static libgcc providing a .gnu.attribute
15 # in ibm128 functions. This is not a bug in static libgcc as normal users
16 # should only ever link ibm128 or ieee128 routines, never both. We are the
17 # exception which allows the decision to be deferred to user libraries or
18 # applications.
19 #
20 # We built an object file and extract the desired .gnu.attributes section
21 # to be inserted into lib{c,m}.so.
22 ifeq ($(build-shared),yes)
23
24 # Build everything with IEEE 128-bit long double.
25 sysdep-CFLAGS += -mabi=ieeelongdouble -Wno-psabi $(no-gnu-attribute-CFLAGS)
26
27 before-compile += $(common-objpfx)no_ldbl_gnu_attribute.bin
28
29 $(common-objpfx)no_ldbl_gnu_attribute.bin: $(..)sysdeps/powerpc/powerpc64/le/no_ldbl_gnu_attribute.c
30 $(filter-out $(no-gnu-attribute-CFLAGS),$(compile.c)) -o $(basename $@).o
31 $(OBJCOPY) --dump-section=.gnu.attributes=$@.tmp $(basename $@).o
32 mv $@.tmp $@
33
34 define after-link
35 if [ ! -z "$(filter libm.so libc.so,$(notdir $1))" ]; then \
36 echo "Replacing .gnu.attributes in $1"; \
37 $(OBJCOPY) --update-section=.gnu.attributes=$(common-objpfx)no_ldbl_gnu_attribute.bin $1; \
38 fi
39 endef
40
41 # Ensure a .gnu.attributes section is present by building an ibm128 file with
42 # -mgnu-attribute in both libm and libc shared libraries. Prior to GCC 11 this
43 # section was implicitly included via static libgcc ibm128 routines.
44 ifeq ($(subdir),math)
45 $(objpfx)m_ldexpl.os: CFLAGS += -mgnu-attribute
46 $(objpfx)s_ldexpl.os: CFLAGS += -mgnu-attribute
47 endif
48
49 endif # ifeq ($(build-shared),yes)
50 endif # ifeq ($(ibm128-fcts),yes)
51
52 # All _Float128 files should be built assuming an ibm128 long double.
53 # Likewise, this avoids some old GCC 7 compiler bugs whereby calls
54 # to __mulkc3 are swapped with __multc3, or worse. This is noted in
55 # GCC BZ 84914, and marked as will-not-fix.
56 type-float128-CFLAGS += $(type-ldouble-CFLAGS)
57
58 type-float128-CFLAGS =
59
60 ifeq ($(subdir),math)
61 # sqrtf128 requires emulation before POWER9.
62 CPPFLAGS += -I../soft-fp
63
64 # float128 requires adding a handful of extra flags.
65 # Similarly, disable
66 $(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
67 $(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
68 $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += $(type-float128-CFLAGS)
69 $(foreach suf,$(all-object-suffixes),$(objpfx)test-float64x%$(suf)): CFLAGS += $(type-float128-CFLAGS)
70 # Pairs of types with _Float128 / _Float64x as the wider type but not
71 # the narrower one.
72 f128-pairs = float32-float64x float32-float128 float64-float64x \
73 float64-float128 float32x-float64x float32x-float128
74 $(foreach suf,$(all-object-suffixes),$(foreach pair,$(f128-pairs),$(objpfx)test-$(pair)%$(suf))): CFLAGS += $(type-float128-CFLAGS)
75 CFLAGS-libm-test-support-float128.c += $(type-float128-CFLAGS)
76 CFLAGS-libm-test-support-float64x.c += $(type-float128-CFLAGS)
77 CFLAGS-test-math-iscanonical.cc += $(type-float128-CFLAGS)
78 CFLAGS-test-math-iseqsig.cc += $(type-float128-CFLAGS)
79 CFLAGS-test-math-issignaling.cc += $(type-float128-CFLAGS)
80 CFLAGS-test-math-iszero.cc += $(type-float128-CFLAGS)
81
82 CFLAGS-s_logbl-power7.c += $(type-ldouble-CFLAGS)
83 CFLAGS-s_logbl-ppc64.c += $(type-ldouble-CFLAGS)
84
85 $(foreach suf,$(all-object-suffixes),\
86 $(objpfx)s_copysignl$(suf) \
87 $(objpfx)s_fabsl$(suf)): \
88 ASFLAGS += $(type-ldouble-CFLAGS)
89
90 $(foreach suf,$(all-object-suffixes),\
91 $(objpfx)libm-test-%ibm128$(suf) \
92 $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf)): \
93 CFLAGS += $(type-ldouble-CFLAGS)
94
95 # Newer GCC (>7) doesn't like -mabi=* and -mlong-double-64
96 $(foreach suf,$(all-object-suffixes),\
97 $(objpfx)test-narrow-macros-ldbl-64$(suf) \
98 $(objpfx)test-nldbl-redirect$(suf) \
99 $(objpfx)test-redirection-ldbl-64$(suf) \
100 ): sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble,$(sysdep-CFLAGS))
101
102 endif
103
104 # Newer GCC (>7) doesn't like -mabi=* and -mlong-double-64
105 ifeq ($(subdir),misc)
106 $(foreach suf,$(all-object-suffixes),\
107 $(objpfx)tst-nldbl-warn$(suf) \
108 $(objpfx)tst-nldbl-error$(suf) \
109 ): sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble,$(sysdep-CFLAGS))
110 endif
111
112 # Newer GCC (>7) doesn't like -mabi=* and -mlong-double-64
113 ifeq ($(subdir),argp)
114 $(foreach suf,$(all-object-suffixes),\
115 $(objpfx)tst-nldbl-argp$(suf) \
116 ): sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble,$(sysdep-CFLAGS))
117 endif
118
119
120 # Append flags to string <-> _Float128 routines.
121 ifneq ($(filter $(subdir),wcsmbs stdlib),)
122 $(foreach suf,$(all-object-suffixes),%f128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
123 $(foreach suf,$(all-object-suffixes),%f128_l$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
124 $(foreach suf,$(all-object-suffixes),%f128_nan$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
125 $(foreach suf,$(all-object-suffixes),%float1282mpn$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
126 $(foreach suf,$(all-object-suffixes),%mpn2float128$(suf)): CFLAGS += $(type-float128-CFLAGS) $(no-gnu-attribute-CFLAGS)
127 CFLAGS-bug-strtod.c += $(type-float128-CFLAGS)
128 CFLAGS-bug-strtod2.c += $(type-float128-CFLAGS)
129 CFLAGS-tst-strtod-round.c += $(type-float128-CFLAGS)
130 CFLAGS-tst-wcstod-round.c += $(type-float128-CFLAGS)
131 CFLAGS-tst-strtod-nan-locale.c += $(type-float128-CFLAGS)
132 CFLAGS-tst-wcstod-nan-locale.c += $(type-float128-CFLAGS)
133 CFLAGS-tst-strtod6.c += $(type-float128-CFLAGS)
134 CFLAGS-tst-strfrom.c += $(type-float128-CFLAGS)
135 CFLAGS-tst-strfrom-locale.c += $(type-float128-CFLAGS)
136 CFLAGS-strfrom-skeleton.c += $(type-float128-CFLAGS)
137 CFLAGS-tst-strtod-nan-sign.c += $(type-float128-CFLAGS)
138 CFLAGS-tst-wcstod-nan-sign.c += $(type-float128-CFLAGS)
139
140 # When building glibc with support for _Float128, the powers of ten tables in
141 # fpioconst.c and in the string conversion functions must be extended. Some
142 # Makefiles (e.g.: wcsmbs/Makefile) override CFLAGS defined by the Makefiles in
143 # sysdeps. This is avoided with the use sysdep-CFLAGS instead of CFLAGS.
144 sysdep-CFLAGS += $(sysdep-CFLAGS-$(<F))
145 sysdep-CFLAGS-fpioconst.c += $(type-float128-CFLAGS)
146 sysdep-CFLAGS-strtod_l.c += $(type-float128-CFLAGS)
147 sysdep-CFLAGS-strtof_l.c += $(type-float128-CFLAGS)
148 sysdep-CFLAGS-strtold_l.c += $(type-float128-CFLAGS)
149 sysdep-CFLAGS-wcstod_l.c += $(type-float128-CFLAGS)
150 sysdep-CFLAGS-wcstof_l.c += $(type-float128-CFLAGS)
151 sysdep-CFLAGS-wcstold_l.c += $(type-float128-CFLAGS)
152
153 # Build any ibm128 specific stdlib tests with ibm128 ABI.
154 $(foreach suf,$(all-object-suffixes),%128ibm$(suf)): CFLAGS += $(type-ldouble-CFLAGS)
155 endif
156
157 # Append flags to printf routines.
158 ifeq ($(subdir),stdio-common)
159 CFLAGS-printf_fp.c = $(type-float128-CFLAGS)
160 CFLAGS-printf_fphex.c = $(type-float128-CFLAGS)
161 CFLAGS-printf_size.c = $(type-float128-CFLAGS)
162 endif
163
164 # Disable linker noise on files using ieee128 long double internally
165 ifeq ($(subdir),time)
166 CFLAGS-difftime.c += $(no-gnu-attribute-CFLAGS)
167 endif
168
169 $(foreach suf,$(all-object-suffixes),$(objpfx)nldbl-%$(suf)): \
170 CFLAGS += $(type-ldouble-CFLAGS)
171
172 ldbl-ibm128-files = $(objpfx)nldbl-%$(suf) \
173 $(objpfx)libm-test-%ibm128$(suf) \
174 $(objpfx)test-iibm128%$(suf) $(objpfx)test-ibm128%$(suf) \
175 $(objpfx)test-tgmath3-%$(suf)
176
177 # Remove -mabi=ieeelongdouble from ldbl-ibm128 files.
178 $(foreach suf,$(all-object-suffixes), $(ldbl-ibm128-files)) \
179 $(foreach r,$(ldbl-128ibm-routines) $(ldbl-tests), \
180 $(objpfx)$(r)$(suf)): \
181 sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble,$(sysdep-CFLAGS))
182
183 # TODO: a bug in stdc++ will fail if -mabi=ieeelongdouble and -mfloat128
184 # are both enabled. The latter is enabled by default in GCC 8+. This is
185 # tracked via GCC BZ 94080.
186 ifeq ($(subdir),support)
187 CFLAGS-links-dso-program.cc += -mno-float128
188 endif
189 ifeq ($(subdir),nptl)
190 CFLAGS-tst-thread_local1.cc += -mno-float128
191 CFLAGS-tst-minstack-throw.cc += -mno-float128
192 endif
193
194 ifeq ($(subdir),elf)
195 $(objpfx)tst-glibc-hwcaps: \
196 $(objpfx)libmarkermod2-1.so $(objpfx)libmarkermod3-1.so
197 $(objpfx)tst-glibc-hwcaps.out: \
198 $(objpfx)libmarkermod2.so \
199 $(objpfx)glibc-hwcaps/power9/libmarkermod2.so \
200 $(objpfx)libmarkermod3.so \
201 $(objpfx)glibc-hwcaps/power9/libmarkermod3.so \
202 $(objpfx)glibc-hwcaps/power10/libmarkermod3.so \
203
204 $(objpfx)glibc-hwcaps/power9/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
205 $(make-target-directory)
206 cp $< $@
207 $(objpfx)glibc-hwcaps/power9/libmarkermod3.so: $(objpfx)libmarkermod3-2.so
208 $(make-target-directory)
209 cp $< $@
210 $(objpfx)glibc-hwcaps/power10/libmarkermod3.so: $(objpfx)libmarkermod3-3.so
211 $(make-target-directory)
212 cp $< $@
213
214 ifeq (no,$(build-hardcoded-path-in-tests))
215 # This is an ld.so.cache test, and RPATH/RUNPATH in the executable
216 # interferes with its test objectives.
217 tests-container += tst-glibc-hwcaps-cache
218 endif
219
220 endif # $(subdir) == elf