Skip to content

Commit fe97504

Browse files
szuberskbehlendorf
authored andcommitted
Fix Clang 15 compilation errors
- Clang 15 doesn't support `-fno-ipa-sra` anymore. Do a separate check for `-fno-ipa-sra` support by $KERNEL_CC. - Don't enable `-mgeneral-regs-only` for certain module files. Fix #13260 - Scope `GCC diagnostic ignored` statements to GCC only. Clang doesn't need them to compile the code. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: szubersk <[email protected]> Closes #13260 Closes #14150
1 parent 3c1e193 commit fe97504

File tree

8 files changed

+54
-3
lines changed

8 files changed

+54
-3
lines changed

config/always-compiler-options.m4

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,34 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA], [
324324
CFLAGS="$saved_flags"
325325
AC_SUBST([NO_IPA_SRA])
326326
])
327+
328+
dnl #
329+
dnl # Check if kernel cc supports -fno-ipa-sra option.
330+
dnl #
331+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA], [
332+
AC_MSG_CHECKING([whether $KERNEL_CC supports -fno-ipa-sra])
333+
334+
saved_cc="$CC"
335+
saved_flags="$CFLAGS"
336+
CC="gcc"
337+
CFLAGS="$CFLAGS -Werror -fno-ipa-sra"
338+
339+
AS_IF([ test -n "$KERNEL_CC" ], [
340+
CC="$KERNEL_CC"
341+
])
342+
AS_IF([ test -n "$KERNEL_LLVM" ], [
343+
CC="clang"
344+
])
345+
346+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
347+
KERNEL_NO_IPA_SRA=-fno-ipa-sra
348+
AC_MSG_RESULT([yes])
349+
], [
350+
KERNEL_NO_IPA_SRA=
351+
AC_MSG_RESULT([no])
352+
])
353+
354+
CC="$saved_cc"
355+
CFLAGS="$saved_flags"
356+
AC_SUBST([KERNEL_NO_IPA_SRA])
357+
])

config/zfs-build.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ AC_DEFUN([ZFS_AC_DEBUG], [
8181
AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
8282
DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline $NO_IPA_SRA"
8383
84-
KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $NO_IPA_SRA"
84+
KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $KERNEL_NO_IPA_SRA"
8585
KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
8686
8787
DEBUGINFO_ZFS="_with_debuginfo"
@@ -219,6 +219,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
219219
ZFS_AC_CONFIG_ALWAYS_CC_FORMAT_OVERFLOW
220220
ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
221221
ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA
222+
ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA
222223
ZFS_AC_CONFIG_ALWAYS_CC_ASAN
223224
ZFS_AC_CONFIG_ALWAYS_CC_UBSAN
224225
ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD

module/Kbuild.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ endif
4242
asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
4343
ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
4444

45+
ifeq ($(CONFIG_ARM64),y)
46+
CFLAGS_REMOVE_zcommon/zfs_fletcher_aarch64_neon.o += -mgeneral-regs-only
47+
CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neon.o += -mgeneral-regs-only
48+
CFLAGS_REMOVE_zfs/vdev_raidz_math_aarch64_neonx2.o += -mgeneral-regs-only
49+
endif
50+
4551
# Suppress unused-value warnings in sparc64 architecture headers
4652
ccflags-$(CONFIG_SPARC64) += -Wno-unused-value
4753

module/icp/algs/edonr/edonr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,11 @@ Q256(size_t bitlen, const uint32_t *data, uint32_t *restrict p)
346346
* which only goes over it by a hair (1248 bytes on ARM32).
347347
*/
348348
#include <sys/isa_defs.h> /* for _ILP32 */
349-
#ifdef _ILP32 /* We're 32-bit, assume small stack frames */
349+
#if defined(_ILP32) /* We're 32-bit, assume small stack frames */
350+
#if defined(__GNUC__) && !defined(__clang__)
350351
#pragma GCC diagnostic ignored "-Wframe-larger-than="
351352
#endif
353+
#endif
352354

353355
#if defined(__IBMC__) && defined(_AIX) && defined(__64BIT__)
354356
static inline size_t

module/icp/algs/skein/skein_block.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
* the #pragma here to ignore the warning.
3131
*/
3232
#if defined(_ILP32) || defined(__powerpc) /* Assume small stack */
33+
#if defined(__GNUC__) && !defined(__clang__)
3334
#pragma GCC diagnostic ignored "-Wframe-larger-than="
35+
#endif
3436
/*
3537
* We're running on 32-bit, don't unroll loops to save stack frame space
3638
*

module/lua/ldo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ l_noret luaD_throw (lua_State *L, int errcode) {
197197
}
198198
}
199199

200-
#if defined(HAVE_INFINITE_RECURSION)
200+
#if defined(__GNUC__) && !defined(__clang__) && \
201+
defined(HAVE_INFINITE_RECURSION)
201202
#pragma GCC diagnostic pop
202203
#endif
203204

module/os/linux/spl/spl-generic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,10 @@ __div_u64(uint64_t u, uint32_t v)
254254
* replacements for libgcc-provided functions and will never be called
255255
* directly.
256256
*/
257+
#if defined(__GNUC__) && !defined(__clang__)
257258
#pragma GCC diagnostic push
258259
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
260+
#endif
259261

260262
/*
261263
* Implementation of 64-bit unsigned division for 32-bit machines.
@@ -449,7 +451,9 @@ __aeabi_ldivmod(int64_t u, int64_t v)
449451
EXPORT_SYMBOL(__aeabi_ldivmod);
450452
#endif /* __arm || __arm__ */
451453

454+
#if defined(__GNUC__) && !defined(__clang__)
452455
#pragma GCC diagnostic pop
456+
#endif
453457

454458
#endif /* BITS_PER_LONG */
455459

module/zfs/vdev_raidz_math_aarch64_neonx2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,13 @@ DEFINE_GEN_METHODS(aarch64_neonx2);
210210
* If compiled with -O0, gcc doesn't do any stack frame coalescing
211211
* and -Wframe-larger-than=1024 is triggered in debug mode.
212212
*/
213+
#if defined(__GNUC__) && !defined(__clang__)
213214
#pragma GCC diagnostic ignored "-Wframe-larger-than="
215+
#endif
214216
DEFINE_REC_METHODS(aarch64_neonx2);
217+
#if defined(__GNUC__) && !defined(__clang__)
215218
#pragma GCC diagnostic pop
219+
#endif
216220

217221
static boolean_t
218222
raidz_will_aarch64_neonx2_work(void)

0 commit comments

Comments
 (0)