@@ -563,14 +563,6 @@ KBUILD_CFLAGS += -funsigned-char
563
563
KBUILD_CFLAGS += -fno-common
564
564
KBUILD_CFLAGS += -fno-PIE
565
565
KBUILD_CFLAGS += -fno-strict-aliasing
566
- KBUILD_CFLAGS += -Wall
567
- KBUILD_CFLAGS += -Wundef
568
- KBUILD_CFLAGS += -Werror=implicit-function-declaration
569
- KBUILD_CFLAGS += -Werror=implicit-int
570
- KBUILD_CFLAGS += -Werror=return-type
571
- KBUILD_CFLAGS += -Werror=strict-prototypes
572
- KBUILD_CFLAGS += -Wno-format-security
573
- KBUILD_CFLAGS += -Wno-trigraphs
574
566
575
567
KBUILD_CPPFLAGS := -D__KERNEL__
576
568
KBUILD_RUSTFLAGS := $(rust_common_flags ) \
@@ -823,10 +815,6 @@ endif # may-sync-config
823
815
endif # need-config
824
816
825
817
KBUILD_CFLAGS += -fno-delete-null-pointer-checks
826
- KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,)
827
- KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
828
- KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
829
- KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member)
830
818
831
819
ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
832
820
KBUILD_CFLAGS += -O2
@@ -857,40 +845,15 @@ ifdef CONFIG_READABLE_ASM
857
845
KBUILD_CFLAGS += -fno-reorder-blocks -fno-ipa-cp-clone -fno-partial-inlining
858
846
endif
859
847
860
- ifneq ($(CONFIG_FRAME_WARN ) ,0)
861
- KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN )
862
- endif
863
-
864
848
stackp-flags-y := -fno-stack-protector
865
849
stackp-flags-$(CONFIG_STACKPROTECTOR) := -fstack-protector
866
850
stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG) := -fstack-protector-strong
867
851
868
852
KBUILD_CFLAGS += $(stackp-flags-y )
869
853
870
- KBUILD_CPPFLAGS-$(CONFIG_WERROR) += -Werror
871
- KBUILD_CPPFLAGS += $(KBUILD_CPPFLAGS-y )
872
- KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
873
-
874
854
KBUILD_RUSTFLAGS-$(CONFIG_WERROR) += -Dwarnings
875
855
KBUILD_RUSTFLAGS += $(KBUILD_RUSTFLAGS-y )
876
856
877
- ifdef CONFIG_CC_IS_CLANG
878
- # The kernel builds with '-std=gnu11' so use of GNU extensions is acceptable.
879
- KBUILD_CFLAGS += -Wno-gnu
880
- else
881
-
882
- # gcc inanely warns about local variables called 'main'
883
- KBUILD_CFLAGS += -Wno-main
884
- endif
885
-
886
- # These warnings generated too much noise in a regular build.
887
- # Use make W=1 to enable them (see scripts/Makefile.extrawarn)
888
- KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
889
- KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable)
890
-
891
- # These result in bogus false positives
892
- KBUILD_CFLAGS += $(call cc-disable-warning, dangling-pointer)
893
-
894
857
ifdef CONFIG_FRAME_POINTER
895
858
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
896
859
KBUILD_RUSTFLAGS += -Cforce-frame-pointers=y
@@ -1025,51 +988,12 @@ endif
1025
988
# arch Makefile may override CC so keep this after arch Makefile is included
1026
989
NOSTDINC_FLAGS += -nostdinc
1027
990
1028
- # Variable Length Arrays (VLAs) should not be used anywhere in the kernel
1029
- KBUILD_CFLAGS += -Wvla
1030
-
1031
- # disable pointer signed / unsigned warnings in gcc 4.0
1032
- KBUILD_CFLAGS += -Wno-pointer-sign
1033
-
1034
- # In order to make sure new function cast mismatches are not introduced
1035
- # in the kernel (to avoid tripping CFI checking), the kernel should be
1036
- # globally built with -Wcast-function-type.
1037
- KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type)
1038
-
1039
991
# To gain proper coverage for CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE,
1040
992
# the kernel uses only C99 flexible arrays for dynamically sized trailing
1041
993
# arrays. Enforce this for everything that may examine structure sizes and
1042
994
# perform bounds checking.
1043
995
KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3)
1044
996
1045
- # disable stringop warnings in gcc 8+
1046
- KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation)
1047
-
1048
- # We'll want to enable this eventually, but it's not going away for 5.7 at least
1049
- KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
1050
-
1051
- # Another good warning that we'll want to enable eventually
1052
- KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
1053
-
1054
- # Enabled with W=2, disabled by default as noisy
1055
- ifdef CONFIG_CC_IS_GCC
1056
- KBUILD_CFLAGS += -Wno-maybe-uninitialized
1057
- endif
1058
-
1059
- # The allocators already balk at large sizes, so silence the compiler
1060
- # warnings for bounds checks involving those possible values. While
1061
- # -Wno-alloc-size-larger-than would normally be used here, earlier versions
1062
- # of gcc (<9.1) weirdly don't handle the option correctly when _other_
1063
- # warnings are produced (?!). Using -Walloc-size-larger-than=SIZE_MAX
1064
- # doesn't work (as it is documented to), silently resolving to "0" prior to
1065
- # version 9.1 (and producing an error more recently). Numeric values larger
1066
- # than PTRDIFF_MAX also don't work prior to version 9.1, which are silently
1067
- # ignored, continuing to default to PTRDIFF_MAX. So, left with no other
1068
- # choice, we must perform a versioned check to disable this warning.
1069
- # https://lore.kernel.org/lkml/[email protected]
1070
- KBUILD_CFLAGS-$(call gcc-min-version, 90100) += -Wno-alloc-size-larger-than
1071
- KBUILD_CFLAGS += $(KBUILD_CFLAGS-y ) $(CONFIG_CC_IMPLICIT_FALLTHROUGH )
1072
-
1073
997
# disable invalid "can't wrap" optimizations for signed / pointers
1074
998
KBUILD_CFLAGS += -fno-strict-overflow
1075
999
@@ -1081,18 +1005,6 @@ ifdef CONFIG_CC_IS_GCC
1081
1005
KBUILD_CFLAGS += -fconserve-stack
1082
1006
endif
1083
1007
1084
- # Prohibit date/time macros, which would make the build non-deterministic
1085
- KBUILD_CFLAGS += -Werror=date-time
1086
-
1087
- # enforce correct pointer usage
1088
- KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types)
1089
-
1090
- # Require designated initializers for all marked structures
1091
- KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init)
1092
-
1093
- # Warn if there is an enum types mismatch
1094
- KBUILD_CFLAGS += $(call cc-option,-Wenum-conversion)
1095
-
1096
1008
# change __FILE__ to the relative path from the srctree
1097
1009
KBUILD_CPPFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree ) /=)
1098
1010
0 commit comments