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

Cache object: 18b78b2eba9168c876ed384d9ad8e857


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