Skip to content

Commit 32e14ed

Browse files
szuberskrincebrain
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 openzfs#13260 - Scope `GCC diagnostic ignored` statements to GCC only. Clang doesn't need them to compile the code. Porting notes: - Moved the stanzas removing -mgeneral-regs-only to Makefile.in since they wouldn't readily work in Kbuild.in and that did. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: szubersk <[email protected]> Closes openzfs#13260 Closes openzfs#14150 Closes openzfs#14624 Ported-by: Rich Ercolani <[email protected] Signed-off-by: Rich Ercolani <[email protected]>
1 parent 7d26967 commit 32e14ed

File tree

9 files changed

+54
-3
lines changed

9 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
@@ -221,3 +221,34 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA], [
221221
CFLAGS="$saved_flags"
222222
AC_SUBST([NO_IPA_SRA])
223223
])
224+
225+
dnl #
226+
dnl # Check if kernel cc supports -fno-ipa-sra option.
227+
dnl #
228+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA], [
229+
AC_MSG_CHECKING([whether $KERNEL_CC supports -fno-ipa-sra])
230+
231+
saved_cc="$CC"
232+
saved_flags="$CFLAGS"
233+
CC="gcc"
234+
CFLAGS="$CFLAGS -Werror -fno-ipa-sra"
235+
236+
AS_IF([ test -n "$KERNEL_CC" ], [
237+
CC="$KERNEL_CC"
238+
])
239+
AS_IF([ test -n "$KERNEL_LLVM" ], [
240+
CC="clang"
241+
])
242+
243+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
244+
KERNEL_NO_IPA_SRA=-fno-ipa-sra
245+
AC_MSG_RESULT([yes])
246+
], [
247+
KERNEL_NO_IPA_SRA=
248+
AC_MSG_RESULT([no])
249+
])
250+
251+
CC="$saved_cc"
252+
CFLAGS="$saved_flags"
253+
AC_SUBST([KERNEL_NO_IPA_SRA])
254+
])

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"
@@ -217,6 +217,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
217217
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH
218218
ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
219219
ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA
220+
ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA
220221
ZFS_AC_CONFIG_ALWAYS_CC_ASAN
221222
ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
222223
ZFS_AC_CONFIG_ALWAYS_SYSTEM

module/Kbuild.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ endif
4444
subdir-asflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
4545
subdir-ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
4646

47+
4748
endif

module/icp/algs/edonr/edonr.c

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

350352
#if defined(__IBMC__) && defined(_AIX) && defined(__64BIT__)
351353
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
@@ -225,8 +225,10 @@ __div_u64(uint64_t u, uint32_t v)
225225
* replacements for libgcc-provided functions and will never be called
226226
* directly.
227227
*/
228+
#if defined(__GNUC__) && !defined(__clang__)
228229
#pragma GCC diagnostic push
229230
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
231+
#endif
230232

231233
/*
232234
* Implementation of 64-bit unsigned division for 32-bit machines.
@@ -425,7 +427,9 @@ __aeabi_ldivmod(int64_t u, int64_t v)
425427
EXPORT_SYMBOL(__aeabi_ldivmod);
426428
#endif /* __arm || __arm__ */
427429

430+
#if defined(__GNUC__) && !defined(__clang__)
428431
#pragma GCC diagnostic pop
432+
#endif
429433

430434
#endif /* BITS_PER_LONG */
431435

module/zcommon/Makefile.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@ $(MODULE)-$(CONFIG_X86) += zfs_fletcher_intel.o
2626
$(MODULE)-$(CONFIG_X86) += zfs_fletcher_sse.o
2727
$(MODULE)-$(CONFIG_X86) += zfs_fletcher_avx512.o
2828
$(MODULE)-$(CONFIG_ARM64) += zfs_fletcher_aarch64_neon.o
29+
30+
ifeq ($(CONFIG_ARM64),y)
31+
CFLAGS_REMOVE_zfs_fletcher_aarch64_neon.o += -mgeneral-regs-only
32+
endif

module/zfs/Makefile.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,9 @@ ifeq ($(CONFIG_ALTIVEC),y)
154154
$(obj)/vdev_raidz_math_powerpc_altivec.o: c_flags += -maltivec
155155
endif
156156

157+
ifeq ($(CONFIG_ARM64),y)
158+
CFLAGS_REMOVE_vdev_raidz_math_aarch64_neon.o += -mgeneral-regs-only
159+
CFLAGS_REMOVE_vdev_raidz_math_aarch64_neonx2.o += -mgeneral-regs-only
160+
endif
161+
157162
include $(mfdir)/../os/linux/zfs/Makefile

0 commit comments

Comments
 (0)