Skip to content

Commit c0b49ff

Browse files
Improve -msplit-patch-nops detection
gcc-15 ppc64le needs this flag for libpulp to compile. Check if the compiler supports it and pass the flag accordingly. Signed-off-by: Giuliano Belinassi <gbelinassi@suse.de>
1 parent 4baef1b commit c0b49ff

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

Diff for: configure.ac

+35-11
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,9 @@ AX_PYTHON_MODULE([psutil], [fatal])
134134

135135
_SPLIT_PATCH_NOPS=""
136136

137-
# Check if compiler provides -msplit-patch-nops. It may be required on
138-
# some architectures.
139-
AX_CHECK_COMPILE_FLAG([-msplit-patch-nops],
140-
[_SPLIT_PATCH_NOPS="-msplit-patch-nops"],
141-
[_SPLIT_PATCH_NOPS=""])
142-
143137
# Add the following flags to the compilation of all files
144-
AC_SUBST([AM_CFLAGS], ["-Wall -Wextra -Werror $_SPLIT_PATCH_NOPS"])
145-
AC_SUBST([AM_CXXFLAGS], ["-Wall -Wextra -Werror $_SPLIT_PATCH_NOPS"])
138+
AC_SUBST([AM_CFLAGS], ["-Wall -Wextra -Werror"])
139+
AC_SUBST([AM_CXXFLAGS], ["-Wall -Wextra -Werror"])
146140
AC_SUBST([AM_CCASFLAGS], ["-Wa,--fatal-warnings"])
147141

148142
# Checking the call stack of all threads enables libpulp to only apply a live
@@ -272,6 +266,12 @@ AC_DEFINE_UNQUOTED([LD_LINUX], ["$_LD_LINUX"],
272266
AM_CONDITIONAL([CPU_X86_64], [test "$_PROC" == "x86_64"])
273267
AM_CONDITIONAL([CPU_PPC64LE], [test "$_PROC" == "powerpc64le"])
274268

269+
# Check if compiler provides -msplit-patch-nops. It may be required on
270+
# some architectures.
271+
AX_CHECK_COMPILE_FLAG([-msplit-patch-nops],
272+
[AX_APPEND_FLAG([-msplit-patch-nops])],
273+
[])
274+
275275
# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$RE_NOPS_LEN works
276276
# correctly.
277277
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
@@ -281,13 +281,37 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
281281
[patchable_works=yes],
282282
[patchable_works=no])
283283

284-
# Fix some problems with the Makefiles expecting a default value for AM_LDFLAGS
285-
AC_SUBST([AM_LDFLAGS], [""])
286-
287284
AS_IF([test "x$patchable_works" == "xno"],
288285
AC_MSG_ERROR(
289286
[The -fpatchable-functions-entry flag of your C compiler does not work correctly]))
290287

288+
# Now check for C++.
289+
AC_LANG_PUSH([C++])
290+
# Check if compiler provides -msplit-patch-nops. It may be required on
291+
# some architectures.
292+
AX_CHECK_COMPILE_FLAG([-msplit-patch-nops],
293+
[AX_APPEND_FLAG([-msplit-patch-nops])],
294+
[])
295+
296+
# Check if -fpatchable-function-entry=$ULP_NOPS_LEN,$RE_NOPS_LEN works
297+
# correctly.
298+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
299+
[[extern void g(void);
300+
__attribute__((patchable_function_entry($_NOPS_LEN, $_PRE_NOPS_LEN)))
301+
void f(void) { g(); }]])],
302+
[patchable_works=yes],
303+
[patchable_works=no])
304+
305+
AS_IF([test "x$patchable_works" == "xno"],
306+
AC_MSG_ERROR(
307+
[The -fpatchable-functions-entry flag of your C++ compiler does not work correctly]))
308+
309+
AC_LANG_POP([C++])
310+
311+
# Fix some problems with the Makefiles expecting a default value for AM_LDFLAGS
312+
AC_SUBST([AM_LDFLAGS], [""])
313+
314+
291315
AC_CONFIG_FILES([Makefile
292316
include/Makefile
293317
lib/Makefile

0 commit comments

Comments
 (0)