The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/conf/kern.mk

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 # $FreeBSD: releng/11.0/sys/conf/kern.mk 302441 2016-07-08 18:54:28Z ngie $
    2 
    3 #
    4 # Warning flags for compiling the kernel and components of the kernel:
    5 #
    6 CWARNFLAGS?=    -Wall -Wredundant-decls -Wnested-externs -Wstrict-prototypes \
    7                 -Wmissing-prototypes -Wpointer-arith -Winline -Wcast-qual \
    8                 -Wundef -Wno-pointer-sign ${FORMAT_EXTENSIONS} \
    9                 -Wmissing-include-dirs -fdiagnostics-show-option \
   10                 -Wno-unknown-pragmas \
   11                 ${CWARNEXTRA}
   12 #
   13 # The following flags are next up for working on:
   14 #       -Wextra
   15 
   16 # Disable a few warnings for clang, since there are several places in the
   17 # kernel where fixing them is more trouble than it is worth, or where there is
   18 # a false positive.
   19 .if ${COMPILER_TYPE} == "clang"
   20 NO_WCONSTANT_CONVERSION=        -Wno-constant-conversion
   21 NO_WSHIFT_COUNT_NEGATIVE=       -Wno-shift-count-negative
   22 NO_WSHIFT_COUNT_OVERFLOW=       -Wno-shift-count-overflow
   23 NO_WSELF_ASSIGN=                -Wno-self-assign
   24 NO_WUNNEEDED_INTERNAL_DECL=     -Wno-unneeded-internal-declaration
   25 NO_WSOMETIMES_UNINITIALIZED=    -Wno-error-sometimes-uninitialized
   26 NO_WCAST_QUAL=                  -Wno-cast-qual
   27 # Several other warnings which might be useful in some cases, but not severe
   28 # enough to error out the whole kernel build.  Display them anyway, so there is
   29 # some incentive to fix them eventually.
   30 CWARNEXTRA?=    -Wno-error-tautological-compare -Wno-error-empty-body \
   31                 -Wno-error-parentheses-equality -Wno-error-unused-function \
   32                 -Wno-error-pointer-sign
   33 .if ${COMPILER_VERSION} >= 30700
   34 CWARNEXTRA+=    -Wno-error-shift-negative-value
   35 .endif
   36 
   37 CLANG_NO_IAS= -no-integrated-as
   38 .if ${COMPILER_VERSION} < 30500
   39 # XXX: clang < 3.5 integrated-as doesn't grok .codeNN directives
   40 CLANG_NO_IAS34= -no-integrated-as
   41 .endif
   42 .endif
   43 
   44 .if ${COMPILER_TYPE} == "gcc"
   45 .if ${COMPILER_VERSION} >= 40800
   46 # Catch-all for all the things that are in our tree, but for which we're
   47 # not yet ready for this compiler.
   48 CWARNEXTRA?=    -Wno-error=inline -Wno-error=enum-compare -Wno-error=unused-but-set-variable \
   49                 -Wno-error=aggressive-loop-optimizations -Wno-error=maybe-uninitialized \
   50                 -Wno-error=array-bounds -Wno-error=address \
   51                 -Wno-error=cast-qual -Wno-error=sequence-point -Wno-error=attributes \
   52                 -Wno-error=strict-overflow -Wno-error=overflow
   53 .else
   54 # For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars.
   55 CWARNEXTRA?=    -Wno-uninitialized
   56 .endif
   57 .endif
   58 
   59 # External compilers may not support our format extensions.  Allow them
   60 # to be disabled.  WARNING: format checking is disabled in this case.
   61 .if ${MK_FORMAT_EXTENSIONS} == "no"
   62 FORMAT_EXTENSIONS=      -Wno-format
   63 .elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
   64 FORMAT_EXTENSIONS=      -D__printf__=__freebsd_kprintf__
   65 .else
   66 FORMAT_EXTENSIONS=      -fformat-extensions
   67 .endif
   68 
   69 #
   70 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
   71 # and above adds code to the entry and exit point of every function to align the
   72 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
   73 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
   74 # it is probably an overall loss as it makes the code bigger (less efficient
   75 # use of code cache tag lines) and uses more stack (less efficient use of data
   76 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
   77 # operations inside the kernel itself.  These operations are exclusively
   78 # reserved for user applications.
   79 #
   80 # gcc:
   81 # Setting -mno-mmx implies -mno-3dnow
   82 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
   83 #
   84 # clang:
   85 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
   86 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
   87 #
   88 .if ${MACHINE_CPUARCH} == "i386"
   89 CFLAGS.gcc+=    -mno-align-long-strings -mpreferred-stack-boundary=2
   90 CFLAGS.clang+=  -mno-aes -mno-avx
   91 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
   92 INLINE_LIMIT?=  8000
   93 .endif
   94 
   95 .if ${MACHINE_CPUARCH} == "arm"
   96 INLINE_LIMIT?=  8000
   97 .endif
   98 
   99 .if ${MACHINE_CPUARCH} == "aarch64"
  100 # We generally don't want fpu instructions in the kernel.
  101 CFLAGS += -mgeneral-regs-only
  102 # Reserve x18 for pcpu data
  103 CFLAGS += -ffixed-x18
  104 .endif
  105 
  106 .if ${MACHINE_CPUARCH} == "riscv"
  107 CFLAGS.gcc+=    -mcmodel=medany
  108 INLINE_LIMIT?=  8000
  109 .endif
  110 
  111 #
  112 # For sparc64 we want the medany code model so modules may be located
  113 # anywhere in the 64-bit address space.  We also tell GCC to use floating
  114 # point emulation.  This avoids using floating point registers for integer
  115 # operations which it has a tendency to do.
  116 #
  117 .if ${MACHINE_CPUARCH} == "sparc64"
  118 CFLAGS.clang+=  -mcmodel=large -fno-dwarf2-cfi-asm
  119 CFLAGS.gcc+=    -mcmodel=medany -msoft-float
  120 INLINE_LIMIT?=  15000
  121 .endif
  122 
  123 #
  124 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
  125 # operations inside the kernel itself.  These operations are exclusively
  126 # reserved for user applications.
  127 #
  128 # gcc:
  129 # Setting -mno-mmx implies -mno-3dnow
  130 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
  131 #
  132 # clang:
  133 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
  134 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
  135 # (-mfpmath= is not supported)
  136 #
  137 .if ${MACHINE_CPUARCH} == "amd64"
  138 CFLAGS.clang+=  -mno-aes -mno-avx
  139 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
  140                 -fno-asynchronous-unwind-tables
  141 INLINE_LIMIT?=  8000
  142 .endif
  143 
  144 #
  145 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
  146 # floating point registers for integer operations which it has a tendency to do.
  147 # Also explicitly disable Altivec instructions inside the kernel.
  148 #
  149 .if ${MACHINE_CPUARCH} == "powerpc"
  150 CFLAGS+=        -mno-altivec
  151 CFLAGS.clang+=  -mllvm -disable-ppc-float-in-variadic=true
  152 CFLAGS.gcc+=    -msoft-float
  153 INLINE_LIMIT?=  15000
  154 .endif
  155 
  156 #
  157 # Use dot symbols on powerpc64 to make ddb happy
  158 #
  159 .if ${MACHINE_ARCH} == "powerpc64"
  160 CFLAGS.gcc+=    -mcall-aixdesc
  161 .endif
  162 
  163 #
  164 # For MIPS we also tell gcc to use floating point emulation
  165 #
  166 .if ${MACHINE_CPUARCH} == "mips"
  167 CFLAGS+=        -msoft-float
  168 INLINE_LIMIT?=  8000
  169 .endif
  170 
  171 #
  172 # GCC 3.0 and above like to do certain optimizations based on the
  173 # assumption that the program is linked against libc.  Stop this.
  174 #
  175 CFLAGS+=        -ffreestanding
  176 
  177 #
  178 # The C standard leaves signed integer overflow behavior undefined.
  179 # gcc and clang opimizers take advantage of this.  The kernel makes
  180 # use of signed integer wraparound mechanics so we need the compiler
  181 # to treat it as a wraparound and not take shortcuts.
  182 # 
  183 CFLAGS+=        -fwrapv
  184 
  185 #
  186 # GCC SSP support
  187 #
  188 .if ${MK_SSP} != "no" && \
  189     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
  190 CFLAGS+=        -fstack-protector
  191 .endif
  192 
  193 #
  194 # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
  195 # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
  196 # cope well with DWARF 4, so force it to genereate DWARF2, which they
  197 # understand. Do this unconditionally as it is harmless when not needed,
  198 # but critical for these newer versions.
  199 #
  200 .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
  201 CFLAGS+=        -gdwarf-2
  202 .endif
  203 
  204 CFLAGS+= ${CWARNFLAGS} ${CWARNFLAGS.${.IMPSRC:T}}
  205 CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} ${CFLAGS.${.IMPSRC:T}}
  206 
  207 # Tell bmake not to mistake standard targets for things to be searched for
  208 # or expect to ever be up-to-date.
  209 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
  210                 beforelinking build build-tools buildfiles buildincludes \
  211                 checkdpadd clean cleandepend cleandir cleanobj configure \
  212                 depend distclean distribute exe \
  213                 html includes install installfiles installincludes lint \
  214                 obj objlink objs objwarn \
  215                 realinstall regress \
  216                 tags whereobj
  217 
  218 .PHONY: ${PHONY_NOTMAIN}
  219 .NOTMAIN: ${PHONY_NOTMAIN}
  220 
  221 CSTD=           c99
  222 
  223 .if ${CSTD} == "k&r"
  224 CFLAGS+=        -traditional
  225 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
  226 CFLAGS+=        -std=iso9899:1990
  227 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
  228 CFLAGS+=        -std=iso9899:199409
  229 .elif ${CSTD} == "c99"
  230 CFLAGS+=        -std=iso9899:1999
  231 .else # CSTD
  232 CFLAGS+=        -std=${CSTD}
  233 .endif # CSTD

Cache object: fd7a3ac3d7c3456893dc410744f198b9


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.