]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - config/kernel-config-defined.m4
Vendor import of openzfs master @ 184df27eef0abdc7ab2105b21257f753834b936b
[FreeBSD/FreeBSD.git] / config / kernel-config-defined.m4
1 dnl #
2 dnl # Certain kernel build options are not supported.  These must be
3 dnl # detected at configure time and cause a build failure.  Otherwise
4 dnl # modules may be successfully built that behave incorrectly.
5 dnl #
6 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEFINED], [
7         AS_IF([test "x$cross_compiling" != xyes], [
8                 AC_RUN_IFELSE([
9                         AC_LANG_PROGRAM([
10                                 #include "$LINUX/include/linux/license.h"
11                         ], [
12                                 return !license_is_gpl_compatible(
13                                     "$ZFS_META_LICENSE");
14                         ])
15                 ], [
16                         AC_DEFINE([ZFS_IS_GPL_COMPATIBLE], [1],
17                             [Define to 1 if GPL-only symbols can be used])
18                 ], [
19                 ])
20         ])
21
22         ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE
23         ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC
24         ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS
25         ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE
26         ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE
27
28         AC_MSG_CHECKING([for kernel config option compatibility])
29         ZFS_LINUX_TEST_COMPILE_ALL([config])
30         AC_MSG_RESULT([done])
31
32         ZFS_AC_KERNEL_CONFIG_THREAD_SIZE
33         ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
34         ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS
35         ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE
36         ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE
37 ])
38
39 dnl #
40 dnl # Check configured THREAD_SIZE
41 dnl #
42 dnl # The stack size will vary by architecture, but as of Linux 3.15 on x86_64
43 dnl # the default thread stack size was increased to 16K from 8K.  Therefore,
44 dnl # on newer kernels and some architectures stack usage optimizations can be
45 dnl # conditionally applied to improve performance without negatively impacting
46 dnl # stability.
47 dnl #
48 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_THREAD_SIZE], [
49         ZFS_LINUX_TEST_SRC([config_thread_size], [
50                 #include <linux/module.h>
51         ],[
52                 #if (THREAD_SIZE < 16384)
53                 #error "THREAD_SIZE is less than 16K"
54                 #endif
55         ])
56 ])
57
58 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_THREAD_SIZE], [
59         AC_MSG_CHECKING([whether kernel was built with 16K or larger stacks])
60         ZFS_LINUX_TEST_RESULT([config_thread_size], [
61                 AC_MSG_RESULT([yes])
62                 AC_DEFINE(HAVE_LARGE_STACKS, 1, [kernel has large stacks])
63         ],[
64                 AC_MSG_RESULT([no])
65         ])
66 ])
67
68 dnl #
69 dnl # Check CONFIG_DEBUG_LOCK_ALLOC
70 dnl #
71 dnl # This is typically only set for debug kernels because it comes with
72 dnl # a performance penalty.  However, when it is set it maps the non-GPL
73 dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
74 dnl # This will cause a failure at link time which we'd rather know about
75 dnl # at compile time.
76 dnl #
77 dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
78 dnl # with the upstream community we add a check to detect this case.
79 dnl #
80 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_DEBUG_LOCK_ALLOC], [
81         ZFS_LINUX_TEST_SRC([config_debug_lock_alloc], [
82                 #include <linux/mutex.h>
83         ],[
84                 struct mutex lock;
85
86                 mutex_init(&lock);
87                 mutex_lock(&lock);
88                 mutex_unlock(&lock);
89         ], [], [$ZFS_META_LICENSE])
90 ])
91
92 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
93         AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
94         ZFS_LINUX_TEST_RESULT([config_debug_lock_alloc], [
95                 AC_MSG_RESULT(no)
96         ],[
97                 AC_MSG_RESULT(yes)
98                 AC_MSG_ERROR([
99         *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
100         *** with the CDDL license and will prevent the module linking stage
101         *** from succeeding.  You must rebuild your kernel without this
102         *** option enabled.])
103         ])
104 ])
105
106 dnl #
107 dnl # Check CONFIG_TRIM_UNUSED_KSYMS
108 dnl #
109 dnl # Verify the kernel has CONFIG_TRIM_UNUSED_KSYMS disabled.
110 dnl #
111 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_TRIM_UNUSED_KSYMS], [
112         ZFS_LINUX_TEST_SRC([config_trim_unusued_ksyms], [
113                 #if defined(CONFIG_TRIM_UNUSED_KSYMS)
114                 #error CONFIG_TRIM_UNUSED_KSYMS not defined
115                 #endif
116         ],[])
117 ])
118
119 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_TRIM_UNUSED_KSYMS], [
120         AC_MSG_CHECKING([whether CONFIG_TRIM_UNUSED_KSYM is disabled])
121         ZFS_LINUX_TEST_RESULT([config_trim_unusued_ksyms], [
122                 AC_MSG_RESULT([yes])
123         ],[
124                 AC_MSG_RESULT([no])
125                 AS_IF([test "x$enable_linux_builtin" != xyes], [
126                         AC_MSG_ERROR([
127         *** This kernel has unused symbols trimming enabled, please disable.
128         *** Rebuild the kernel with CONFIG_TRIM_UNUSED_KSYMS=n set.])
129                 ])
130         ])
131 ])
132
133 dnl #
134 dnl # Check CONFIG_ZLIB_INFLATE
135 dnl #
136 dnl # Verify the kernel has CONFIG_ZLIB_INFLATE support enabled.
137 dnl #
138 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_INFLATE], [
139         ZFS_LINUX_TEST_SRC([config_zlib_inflate], [
140                 #if !defined(CONFIG_ZLIB_INFLATE) && \
141                     !defined(CONFIG_ZLIB_INFLATE_MODULE)
142                 #error CONFIG_ZLIB_INFLATE not defined
143                 #endif
144         ],[])
145 ])
146
147 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_INFLATE], [
148         AC_MSG_CHECKING([whether CONFIG_ZLIB_INFLATE is defined])
149         ZFS_LINUX_TEST_RESULT([config_zlib_inflate], [
150                 AC_MSG_RESULT([yes])
151         ],[
152                 AC_MSG_RESULT([no])
153                 AC_MSG_ERROR([
154         *** This kernel does not include the required zlib inflate support.
155         *** Rebuild the kernel with CONFIG_ZLIB_INFLATE=y|m set.])
156         ])
157 ])
158
159 dnl #
160 dnl # Check CONFIG_ZLIB_DEFLATE
161 dnl #
162 dnl # Verify the kernel has CONFIG_ZLIB_DEFLATE support enabled.
163 dnl #
164 AC_DEFUN([ZFS_AC_KERNEL_SRC_CONFIG_ZLIB_DEFLATE], [
165         ZFS_LINUX_TEST_SRC([config_zlib_deflate], [
166                 #if !defined(CONFIG_ZLIB_DEFLATE) && \
167                     !defined(CONFIG_ZLIB_DEFLATE_MODULE)
168                 #error CONFIG_ZLIB_DEFLATE not defined
169                 #endif
170         ],[])
171 ])
172
173 AC_DEFUN([ZFS_AC_KERNEL_CONFIG_ZLIB_DEFLATE], [
174         AC_MSG_CHECKING([whether CONFIG_ZLIB_DEFLATE is defined])
175         ZFS_LINUX_TEST_RESULT([config_zlib_deflate], [
176                 AC_MSG_RESULT([yes])
177         ],[
178                 AC_MSG_RESULT([no])
179                 AC_MSG_ERROR([
180         *** This kernel does not include the required zlib deflate support.
181         *** Rebuild the kernel with CONFIG_ZLIB_DEFLATE=y|m set.])
182         ])
183 ])