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$
    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-error=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-error=unneeded-internal-declaration
   25 NO_WSOMETIMES_UNINITIALIZED=    -Wno-error=sometimes-uninitialized
   26 NO_WCAST_QUAL=                  -Wno-error=cast-qual
   27 NO_WTAUTOLOGICAL_POINTER_COMPARE= -Wno-tautological-pointer-compare
   28 # Several other warnings which might be useful in some cases, but not severe
   29 # enough to error out the whole kernel build.  Display them anyway, so there is
   30 # some incentive to fix them eventually.
   31 CWARNEXTRA?=    -Wno-error=tautological-compare -Wno-error=empty-body \
   32                 -Wno-error=parentheses-equality -Wno-error=unused-function \
   33                 -Wno-error=pointer-sign
   34 .if ${COMPILER_VERSION} >= 30700
   35 CWARNEXTRA+=    -Wno-error=shift-negative-value
   36 .endif
   37 .if ${COMPILER_VERSION} >= 40000
   38 CWARNEXTRA+=    -Wno-address-of-packed-member
   39 .endif
   40 .if ${COMPILER_VERSION} >= 100000
   41 NO_WMISLEADING_INDENTATION=     -Wno-misleading-indentation
   42 .endif
   43 
   44 CLANG_NO_IAS= -no-integrated-as
   45 .if ${COMPILER_VERSION} < 30500
   46 # XXX: clang < 3.5 integrated-as doesn't grok .codeNN directives
   47 CLANG_NO_IAS34= -no-integrated-as
   48 .endif
   49 .endif
   50 
   51 .if ${COMPILER_TYPE} == "gcc"
   52 .if ${COMPILER_VERSION} >= 40800
   53 # Catch-all for all the things that are in our tree, but for which we're
   54 # not yet ready for this compiler.
   55 CWARNEXTRA?=    -Wno-error=address                              \
   56                 -Wno-error=aggressive-loop-optimizations        \
   57                 -Wno-error=array-bounds                         \
   58                 -Wno-error=attributes                           \
   59                 -Wno-error=cast-qual                            \
   60                 -Wno-error=enum-compare                         \
   61                 -Wno-error=inline                               \
   62                 -Wno-error=maybe-uninitialized                  \
   63                 -Wno-error=overflow                             \
   64                 -Wno-error=sequence-point                       \
   65                 -Wno-error=unused-but-set-variable
   66 .if ${COMPILER_VERSION} >= 60100
   67 CWARNEXTRA+=    -Wno-error=misleading-indentation               \
   68                 -Wno-error=nonnull-compare                      \
   69                 -Wno-error=shift-overflow                       \
   70                 -Wno-error=tautological-compare
   71 .endif
   72 .else
   73 # For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars.
   74 CWARNEXTRA?=    -Wno-uninitialized
   75 .endif
   76 .endif
   77 
   78 # External compilers may not support our format extensions.  Allow them
   79 # to be disabled.  WARNING: format checking is disabled in this case.
   80 .if ${MK_FORMAT_EXTENSIONS} == "no"
   81 FORMAT_EXTENSIONS=      -Wno-format
   82 .elif ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 30600
   83 FORMAT_EXTENSIONS=      -D__printf__=__freebsd_kprintf__
   84 .else
   85 FORMAT_EXTENSIONS=      -fformat-extensions
   86 .endif
   87 
   88 #
   89 # On i386, do not align the stack to 16-byte boundaries.  Otherwise GCC 2.95
   90 # and above adds code to the entry and exit point of every function to align the
   91 # stack to 16-byte boundaries -- thus wasting approximately 12 bytes of stack
   92 # per function call.  While the 16-byte alignment may benefit micro benchmarks,
   93 # it is probably an overall loss as it makes the code bigger (less efficient
   94 # use of code cache tag lines) and uses more stack (less efficient use of data
   95 # cache tag lines).  Explicitly prohibit the use of FPU, SSE and other SIMD
   96 # operations inside the kernel itself.  These operations are exclusively
   97 # reserved for user applications.
   98 #
   99 # gcc:
  100 # Setting -mno-mmx implies -mno-3dnow
  101 # Setting -mno-sse implies -mno-sse2, -mno-sse3 and -mno-ssse3
  102 #
  103 # clang:
  104 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
  105 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
  106 #
  107 .if ${MACHINE_CPUARCH} == "i386"
  108 CFLAGS.gcc+=    -mno-align-long-strings -mpreferred-stack-boundary=2
  109 CFLAGS.clang+=  -mno-aes -mno-avx
  110 CFLAGS+=        -mno-mmx -mno-sse -msoft-float
  111 INLINE_LIMIT?=  8000
  112 .endif
  113 
  114 .if ${MACHINE_CPUARCH} == "arm"
  115 INLINE_LIMIT?=  8000
  116 .endif
  117 
  118 .if ${MACHINE_CPUARCH} == "aarch64"
  119 # We generally don't want fpu instructions in the kernel.
  120 CFLAGS += -mgeneral-regs-only
  121 # Reserve x18 for pcpu data
  122 CFLAGS += -ffixed-x18
  123 .endif
  124 
  125 .if ${MACHINE_CPUARCH} == "riscv"
  126 CFLAGS.gcc+=    -mcmodel=medany
  127 INLINE_LIMIT?=  8000
  128 .endif
  129 
  130 #
  131 # For sparc64 we want the medany code model so modules may be located
  132 # anywhere in the 64-bit address space.  We also tell GCC to use floating
  133 # point emulation.  This avoids using floating point registers for integer
  134 # operations which it has a tendency to do.
  135 #
  136 .if ${MACHINE_CPUARCH} == "sparc64"
  137 CFLAGS.clang+=  -mcmodel=large -fno-dwarf2-cfi-asm
  138 CFLAGS.gcc+=    -mcmodel=medany -msoft-float
  139 INLINE_LIMIT?=  15000
  140 .endif
  141 
  142 #
  143 # For AMD64, we explicitly prohibit the use of FPU, SSE and other SIMD
  144 # operations inside the kernel itself.  These operations are exclusively
  145 # reserved for user applications.
  146 #
  147 # gcc:
  148 # Setting -mno-mmx implies -mno-3dnow
  149 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3 and -mfpmath=387
  150 #
  151 # clang:
  152 # Setting -mno-mmx implies -mno-3dnow and -mno-3dnowa
  153 # Setting -mno-sse implies -mno-sse2, -mno-sse3, -mno-ssse3, -mno-sse41 and -mno-sse42
  154 # (-mfpmath= is not supported)
  155 #
  156 .if ${MACHINE_CPUARCH} == "amd64"
  157 CFLAGS.clang+=  -mno-aes -mno-avx
  158 CFLAGS+=        -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float \
  159                 -fno-asynchronous-unwind-tables
  160 INLINE_LIMIT?=  8000
  161 .endif
  162 
  163 #
  164 # For PowerPC we tell gcc to use floating point emulation.  This avoids using
  165 # floating point registers for integer operations which it has a tendency to do.
  166 # Also explicitly disable Altivec instructions inside the kernel.
  167 #
  168 .if ${MACHINE_CPUARCH} == "powerpc"
  169 CFLAGS+=        -mno-altivec -msoft-float
  170 INLINE_LIMIT?=  15000
  171 .endif
  172 
  173 #
  174 # Use dot symbols on powerpc64 to make ddb happy
  175 #
  176 .if ${MACHINE_ARCH} == "powerpc64"
  177 CFLAGS.gcc+=    -mcall-aixdesc
  178 .endif
  179 
  180 #
  181 # For MIPS we also tell gcc to use floating point emulation
  182 #
  183 .if ${MACHINE_CPUARCH} == "mips"
  184 CFLAGS+=        -msoft-float
  185 INLINE_LIMIT?=  8000
  186 .endif
  187 
  188 #
  189 # GCC 3.0 and above like to do certain optimizations based on the
  190 # assumption that the program is linked against libc.  Stop this.
  191 #
  192 CFLAGS+=        -ffreestanding
  193 
  194 #
  195 # The C standard leaves signed integer overflow behavior undefined.
  196 # gcc and clang opimizers take advantage of this.  The kernel makes
  197 # use of signed integer wraparound mechanics so we need the compiler
  198 # to treat it as a wraparound and not take shortcuts.
  199 #
  200 CFLAGS+=        -fwrapv
  201 
  202 #
  203 # GCC SSP support
  204 #
  205 .if ${MK_SSP} != "no" && \
  206     ${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
  207 CFLAGS+=        -fstack-protector
  208 .endif
  209 
  210 #
  211 # Retpoline speculative execution vulnerability mitigation (CVE-2017-5715)
  212 #
  213 .if defined(COMPILER_FEATURES) && ${COMPILER_FEATURES:Mretpoline} != "" && \
  214     ${MK_KERNEL_RETPOLINE} != "no"
  215 CFLAGS+=        -mretpoline
  216 .endif
  217 
  218 #
  219 # Add -gdwarf-2 when compiling -g. The default starting in clang v3.4
  220 # and gcc 4.8 is to generate DWARF version 4. However, our tools don't
  221 # cope well with DWARF 4, so force it to genereate DWARF2, which they
  222 # understand. Do this unconditionally as it is harmless when not needed,
  223 # but critical for these newer versions.
  224 #
  225 .if ${CFLAGS:M-g} != "" && ${CFLAGS:M-gdwarf*} == ""
  226 CFLAGS+=        -gdwarf-2
  227 .endif
  228 
  229 CFLAGS+= ${CWARNFLAGS:M*} ${CWARNFLAGS.${.IMPSRC:T}}
  230 CFLAGS+= ${CFLAGS.${COMPILER_TYPE}} ${CFLAGS.${.IMPSRC:T}}
  231 
  232 # Tell bmake not to mistake standard targets for things to be searched for
  233 # or expect to ever be up-to-date.
  234 PHONY_NOTMAIN = afterdepend afterinstall all beforedepend beforeinstall \
  235                 beforelinking build build-tools buildfiles buildincludes \
  236                 checkdpadd clean cleandepend cleandir cleanobj configure \
  237                 depend distclean distribute exe \
  238                 html includes install installfiles installincludes lint \
  239                 obj objlink objs objwarn \
  240                 realinstall regress \
  241                 tags whereobj
  242 
  243 .PHONY: ${PHONY_NOTMAIN}
  244 .NOTMAIN: ${PHONY_NOTMAIN}
  245 
  246 CSTD=           c99
  247 
  248 .if ${CSTD} == "k&r"
  249 CFLAGS+=        -traditional
  250 .elif ${CSTD} == "c89" || ${CSTD} == "c90"
  251 CFLAGS+=        -std=iso9899:1990
  252 .elif ${CSTD} == "c94" || ${CSTD} == "c95"
  253 CFLAGS+=        -std=iso9899:199409
  254 .elif ${CSTD} == "c99"
  255 CFLAGS+=        -std=iso9899:1999
  256 .else # CSTD
  257 CFLAGS+=        -std=${CSTD}
  258 .endif # CSTD
  259 
  260 # Set target-specific linker emulation name.
  261 LD_EMULATION_aarch64=aarch64elf
  262 LD_EMULATION_amd64=elf_x86_64_fbsd
  263 LD_EMULATION_arm=armelf_fbsd
  264 LD_EMULATION_armeb=armelfb_fbsd
  265 LD_EMULATION_armv6=armelf_fbsd
  266 LD_EMULATION_i386=elf_i386_fbsd
  267 LD_EMULATION_mips= elf32btsmip_fbsd
  268 LD_EMULATION_mips64= elf64btsmip_fbsd
  269 LD_EMULATION_mipsel= elf32ltsmip_fbsd
  270 LD_EMULATION_mips64el= elf64ltsmip_fbsd
  271 LD_EMULATION_mipsn32= elf32btsmipn32_fbsd
  272 LD_EMULATION_mipsn32el= elf32btsmipn32_fbsd   # I don't think this is a thing that works
  273 LD_EMULATION_powerpc= elf32ppc_fbsd
  274 LD_EMULATION_powerpc64= elf64ppc_fbsd
  275 LD_EMULATION_riscv64= elf64lriscv
  276 LD_EMULATION_sparc64= elf64_sparc_fbsd
  277 LD_EMULATION=${LD_EMULATION_${MACHINE_ARCH}}

Cache object: 54bdfc086a12b52d59fdd7018c5c3ad9


[ 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.