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

Cache object: 8d29df1b88406bdc92f743516e73d93e


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