25 Nov, 2020

1 commit

  • This warning behaves differently depending on the architecture
    and compiler. Using x86 gcc, we get no output at all because
    gcc knows the architecture can handle unaligned accesses.

    Using x86 clang, or gcc on an architecture that needs to
    manually deal with unaligned accesses, the build log is
    completely flooded with these warnings, as they are commonly
    invoked by inline functions of networking headers, e.g.

    include/linux/skbuff.h:1426:26: warning: cast increases required alignment of target type [-Wcast-align]

    The compiler is correct to point this out, as we are dealing
    with undefined behavior that does cause problems in practice,
    but there is also no good way to rewrite the code in commonly
    included headers to a safer method.

    Signed-off-by: Arnd Bergmann
    Reviewed-by: Nathan Chancellor
    Signed-off-by: Masahiro Yamada

    Arnd Bergmann
     

18 Aug, 2020

1 commit


10 Jul, 2020

1 commit

  • -Wtype-limits is included in -Wextra which is added at W=1. It warns
    (among other things) that 'comparison of an unsigned variable `< 0` is
    always false. This causes noisy warnings, especially when used in
    macros, hence it is more suitable for W=2.

    Link: https://lore.kernel.org/lkml/CAHk-=wiKCXEWKJ9dWUimGbrVRo_N2RosESUw8E7m9AEtyZcu=w@mail.gmail.com/
    Signed-off-by: Rikard Falkeborn
    Suggested-by: Arnd Bergmann
    Acked-by: Andy Shevchenko
    Signed-off-by: Linus Torvalds

    Rikard Falkeborn
     

08 Apr, 2020

1 commit

  • Currently, we disable -Wtautological-compare, which in turn disables a
    bunch of more specific tautological comparison warnings that are useful
    for the kernel such as -Wtautological-bitwise-compare. See clang's
    documentation below for the other warnings that are suppressed by
    -Wtautological-compare. Now that all of the major/noisy warnings have
    been fixed, enable -Wtautological-compare so that more issues can be
    caught at build time by various continuous integration setups.

    -Wtautological-constant-out-of-range-compare is kept disabled under a
    normal build but visible at W=1 because there are places in the kernel
    where a constant or variable size can change based on the kernel
    configuration. These are not fixed in a clean/concise way and the ones
    I have audited so far appear to be harmless. It is not a subgroup but
    rather just one warning so we do not lose out on much coverage by
    default.

    Link: https://github.com/ClangBuiltLinux/linux/issues/488
    Link: http://releases.llvm.org/10.0.0/tools/clang/docs/DiagnosticsReference.html#wtautological-compare
    Link: https://bugs.llvm.org/show_bug.cgi?id=42666
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Masahiro Yamada

    Nathan Chancellor
     

14 Mar, 2020

1 commit

  • Clang's -Wpointer-to-int-cast deviates from GCC in that it warns when
    casting to enums. The kernel does this in certain places, such as device
    tree matches to set the version of the device being used, which allows
    the kernel to avoid using a gigantic union.

    https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L428
    https://elixir.bootlin.com/linux/v5.5.8/source/drivers/ata/ahci_brcm.c#L402
    https://elixir.bootlin.com/linux/v5.5.8/source/include/linux/mod_devicetable.h#L264

    To avoid a ton of false positive warnings, disable this particular part
    of the warning, which has been split off into a separate diagnostic so
    that the entire warning does not need to be turned off for clang. It
    will be visible under W=1 in case people want to go about fixing these
    easily and enabling the warning treewide.

    Cc: stable@vger.kernel.org
    Link: https://github.com/ClangBuiltLinux/linux/issues/887
    Link: https://github.com/llvm/llvm-project/commit/2a41b31fcdfcb67ab7038fc2ffb606fd50b83a84
    Signed-off-by: Nathan Chancellor
    Signed-off-by: Masahiro Yamada

    Nathan Chancellor
     

09 Sep, 2019

1 commit

  • GCC and Clang have different policy for -Wunused-function; GCC does not
    warn unused static inline functions at all whereas Clang does if they
    are defined in source files instead of included headers although it has
    been suppressed since commit abb2ea7dfd82 ("compiler, clang: suppress
    warning for unused static inline functions").

    We often miss to delete unused functions where 'static inline' is used
    in *.c files since there is no tool to detect them. Unused code remains
    until somebody notices. For example, commit 075ddd75680f ("regulator:
    core: remove unused rdev_get_supply()").

    Let's remove __maybe_unused from the inline macro to allow Clang to
    start finding unused static inline functions. For now, we do this only
    for W=1 build since it is not a good idea to sprinkle warnings for the
    normal build (e.g. 35 warnings for arch/x86/configs/x86_64_defconfig).

    My initial attempt was to add -Wno-unused-function for no W= build
    (https://lore.kernel.org/patchwork/patch/1120594/)

    Nathan Chancellor pointed out that would weaken Clang's checks since
    we would no longer get -Wunused-function without W=1. It is true GCC
    would catch unused static non-inline functions, but it would weaken
    Clang as a standalone compiler, at least.

    Hence, here is a counter implementation. The current problem is, W=...
    only controls compiler flags, which are globally effective. There is
    no way to address only 'static inline' functions.

    This commit defines KBUILD_EXTRA_WARN[123] corresponding to W=[123].
    When KBUILD_EXTRA_WARN1 is defined, __maybe_unused is omitted from
    the 'inline' macro.

    The new macro __inline_maybe_unused makes the code a bit uglier, so I
    hope we can remove it entirely after fixing most of the warnings.

    If you contribute to code clean-up, please run "make CC=clang W=1"
    and check -Wunused-function warnings. You will find lots of unused
    functions.

    Some of them are false-positives because the call-sites are disabled
    by #ifdef. I do not like to abuse the inline keyword for suppressing
    unused-function warnings because it is intended to be a hint for the
    compiler optimization. I prefer #ifdef around the definition, or
    __maybe_unused if #ifdef would make the code too ugly.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Nathan Chancellor
    Tested-by: Nathan Chancellor

    Masahiro Yamada
     

06 Sep, 2019

2 commits

  • KBUILD_ENABLE_EXTRA_GCC_CHECKS started as a switch to add extra warning
    options for GCC, but now it is a historical misnomer since we use it
    also for Clang, DTC, and even kernel-doc.

    Rename it to more sensible, shorter KBUILD_EXTRA_WARN.

    For the backward compatibility, KBUILD_ENABLE_EXTRA_GCC_CHECKS is still
    supported (but not advertised in the documentation).

    I also fixed up 'make help', and updated the documentation.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Nathan Chancellor
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Sedat Dilek

    Masahiro Yamada
     
  • Instead of the warning-[123] magic, let's accumulate compiler options
    to KBUILD_CFLAGS directly as the top Makefile does. I think this makes
    it easier to understand what is going on in this file.

    This commit slightly changes the behavior, I think all of which are OK.

    [1] Currently, cc-option calls are needlessly evaluated. For example,
    warning-3 += $(call cc-option, -Wpacked-bitfield-compat)
    needs evaluating only when W=3, but it is actually evaluated for
    W=1, W=2 as well. With this commit, only relevant cc-option calls
    will be evaluated. This is a slight optimization.

    [2] Currently, unsupported level like W=4 is checked by:
    $(error W=$(KBUILD_ENABLE_EXTRA_GCC_CHECKS) is unknown)
    This will no longer be checked, but I do not think it is a big
    deal.

    [3] Currently, 4 Clang warnings (Winitializer-overrides, Wformat,
    Wsign-compare, Wformat-zero-length) are shown by any of W=1, W=2,
    and W=3. With this commit, they will be warned only by W=1. I
    think this is a more correct behavior since each warning belongs
    to only one group.

    For understanding this commit correctly:

    We have 3 warning groups, W=1, W=2, and W=3. You may think W=3 has a
    higher level than W=1, but they are actually independent. If you like,
    you can combine them like W=13. To enable all the warnings, you can
    pass W=123. It is shown by 'make help', but not noticed much. Since we
    support W= combination, there should not exist intersection among the
    three groups. If we enable Winitializer-overrides for W=1, we do not
    need to for W=2 or W=3. This is the reason why I think the change [3]
    makes sense.

    The documentation says -Winitializer-overrides is enabled by default.
    (https://clang.llvm.org/docs/DiagnosticsReference.html#winitializer-overrides)
    We negate it by passing -Wno-initializer-overrides for the normal
    build, but we do not do that for W=1. This means, W=1 effectively
    enables -Winitializer-overrides by the clang's default. The same for
    the other three.

    Add comments in case people are confused with the code.

    Signed-off-by: Masahiro Yamada
    Reviewed-by: Nathan Chancellor
    Tested-by: Sedat Dilek
    Acked-by: Nick Desaulniers
    Acked-by: Miguel Ojeda

    Masahiro Yamada
     

24 Jun, 2019

2 commits

  • This flag turns off several other warnings that would
    be useful. Most notably -warn_unused_result is disabled.
    All of the following warnings are currently disabled:

    UnusedValue
    |-UnusedComparison
    |-warn_unused_comparison
    |-UnusedResult
    |-warn_unused_result
    |-UnevaluatedExpression
    |-PotentiallyEvaluatedExpression
    |-warn_side_effects_typeid
    |-warn_side_effects_unevaluated_context
    |-warn_unused_expr
    |-warn_unused_voidptr
    |-warn_unused_container_subscript_expr
    |-warn_unused_call

    With this flag removed there are ~10 warnings.
    Patches have been submitted for each of these warnings.

    Reported-by: Nick Desaulniers
    Cc: clang-built-linux@googlegroups.com
    Link: https://github.com/ClangBuiltLinux/linux/issues/520
    Signed-off-by: Nathan Huckleberry
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Masahiro Yamada

    Nathan Huckleberry
     
  • This helps fine very dodgy behavior through both -Wuninitialized
    (warning that a variable is always uninitialized) and
    -Wsometimes-uninitialized (warning that a variable is sometimes
    uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
    catch things that GCC doesn't such as:

    https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

    We very much want to catch these so turn this warning on so that CI is
    aware of it.

    Link: https://github.com/ClangBuiltLinux/linux/issues/381
    Signed-off-by: Nathan Chancellor
    Reviewed-by: Nick Desaulniers
    Signed-off-by: Masahiro Yamada

    Nathan Chancellor
     

09 Jun, 2019

1 commit

  • It makes little sense to pass -Waggregate-return these days since large
    part of the linux kernel rely on returning struct(s). For instance:

    ../include/linux/timekeeping.h: In function 'show_uptime':
    ../include/linux/ktime.h:91:34: error: function call has aggregate value [-Werror=aggregate-return]
    #define ktime_to_timespec64(kt) ns_to_timespec64((kt))
    ^~~~~~~~~~~~~~~~~~~~~~
    ../include/linux/timekeeping.h:166:8: note: in expansion of macro 'ktime_to_timespec64'
    *ts = ktime_to_timespec64(ktime_get_coarse_boottime());

    Remove this warning from W=2 completely.

    Signed-off-by: Mathieu Malaterre
    Signed-off-by: Masahiro Yamada

    Mathieu Malaterre
     

18 May, 2019

2 commits


04 Nov, 2018

1 commit

  • Pull Kbuild updates from Masahiro Yamada:

    - clean-up leftovers in Kconfig files

    - remove stale oldnoconfig and silentoldconfig targets

    - remove unneeded cc-fullversion and cc-name variables

    - improve merge_config script to allow overriding option prefix

    * tag 'kbuild-v4.20-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kbuild: remove cc-name variable
    kbuild: replace cc-name test with CONFIG_CC_IS_CLANG
    merge_config.sh: Allow to define config prefix
    kbuild: remove unused cc-fullversion variable
    kconfig: remove silentoldconfig target
    kconfig: remove oldnoconfig target
    powerpc: PCI_MSI needs PCI
    powerpc: remove CONFIG_MCA leftovers
    powerpc: remove CONFIG_PCI_QSPAN
    scsi: aha152x: rename the PCMCIA define

    Linus Torvalds
     

02 Nov, 2018

2 commits

  • Evaluating cc-name invokes the compiler every time even when you are
    not compiling anything, like 'make help'. This is not efficient.

    The compiler type has been already detected in the Kconfig stage.
    Use CONFIG_CC_IS_CLANG, instead.

    Signed-off-by: Masahiro Yamada
    Acked-by: Michael Ellerman (powerpc)
    Acked-by: Paul Burton (MIPS)
    Acked-by: Joel Stanley

    Masahiro Yamada
     
  • Pull compiler attribute updates from Miguel Ojeda:
    "This is an effort to disentangle the include/linux/compiler*.h headers
    and bring them up to date.

    The main idea behind the series is to use feature checking macros
    (i.e. __has_attribute) instead of compiler version checks (e.g.
    GCC_VERSION), which are compiler-agnostic (so they can be shared,
    reducing the size of compiler-specific headers) and version-agnostic.

    Other related improvements have been performed in the headers as well,
    which on top of the use of __has_attribute it has amounted to a
    significant simplification of these headers (e.g. GCC_VERSION is now
    only guarding a few non-attribute macros).

    This series should also help the efforts to support compiling the
    kernel with clang and icc. A fair amount of documentation and comments
    have also been added, clarified or removed; and the headers are now
    more readable, which should help kernel developers in general.

    The series was triggered due to the move to gcc >= 4.6. In turn, this
    series has also triggered Sparse to gain the ability to recognize
    __has_attribute on its own.

    Finally, the __nonstring variable attribute series has been also
    applied on top; plus two related patches from Nick Desaulniers for
    unreachable() that came a bit afterwards"

    * tag 'compiler-attributes-for-linus-4.20-rc1' of https://github.com/ojeda/linux:
    compiler-gcc: remove comment about gcc 4.5 from unreachable()
    compiler.h: update definition of unreachable()
    Compiler Attributes: ext4: remove local __nonstring definition
    Compiler Attributes: auxdisplay: panel: use __nonstring
    Compiler Attributes: enable -Wstringop-truncation on W=1 (gcc >= 8)
    Compiler Attributes: add support for __nonstring (gcc >= 8)
    Compiler Attributes: add MAINTAINERS entry
    Compiler Attributes: add Doc/process/programming-language.rst
    Compiler Attributes: remove uses of __attribute__ from compiler.h
    Compiler Attributes: KENTRY used twice the "used" attribute
    Compiler Attributes: use feature checks instead of version checks
    Compiler Attributes: add missing SPDX ID in compiler_types.h
    Compiler Attributes: remove unneeded sparse (__CHECKER__) tests
    Compiler Attributes: homogenize __must_be_array
    Compiler Attributes: remove unneeded tests
    Compiler Attributes: always use the extra-underscores syntax
    Compiler Attributes: remove unused attributes

    Linus Torvalds
     

11 Oct, 2018

1 commit

  • Now that Variable Length Arrays (VLAs) have been entirely removed[1]
    from the kernel, enable the VLA warning globally. The only exceptions
    to this are the KASan an UBSan tests which are explicitly checking that
    VLAs trigger their respective tests.

    [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com

    Cc: Masahiro Yamada
    Cc: Andrew Morton
    Cc: David Airlie
    Cc: linux-kbuild@vger.kernel.org
    Cc: intel-gfx@lists.freedesktop.org
    Cc: dri-devel@lists.freedesktop.org
    Signed-off-by: Kees Cook

    Kees Cook
     

01 Oct, 2018

1 commit

  • Commit 217c3e019675 ("disable stringop truncation warnings for now")
    disabled -Wstringop-truncation since it was too noisy.

    Having __nonstring available allows us to let GCC know that a string
    is not meant to be NUL-terminated, which helps suppressing some
    -Wstringop-truncation warnings.

    Note that using __nonstring actually triggers other warnings
    (-Wstringop-overflow, which is on by default) which may be real
    problems. Therefore, cleaning up -Wstringop-truncation warnings
    also buys us the ability to uncover further potential problems.

    To encourage the use of __nonstring, we put the warning back at W=1.
    In the future, if we end up with a fairly warning-free tree,
    we might want to enable it by default.

    Tested-by: Sedat Dilek # on top of v4.19-rc5, clang 7
    Reviewed-by: Kees Cook
    Reviewed-by: Nick Desaulniers
    Reviewed-by: Luc Van Oostenryck
    Signed-off-by: Miguel Ojeda

    Miguel Ojeda
     

18 Jan, 2018

1 commit

  • gcc-8 reports many -Wpacked-not-aligned warnings. The below are some
    examples.

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    ./include/linux/ceph/msgr.h:67:1: warning: alignment 1 of 'struct
    ceph_entity_addr' is less than 8 [-Wpacked-not-aligned]
    } __attribute__ ((packed));

    This patch suppresses this kind of warnings for default setting.

    Signed-off-by: Xiongfeng Wang
    Signed-off-by: Masahiro Yamada

    Xiongfeng Wang
     

02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

01 Sep, 2017

1 commit


23 Apr, 2017

1 commit

  • Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
    cc-option to support clang"), cc-option and friends work nicely
    for clang.

    However, -Wno-unknown-warning-option makes clang happy with any
    unknown warning options even if -Werror is specified.

    Once -Wno-unknown-warning-option is added, any succeeding call of
    cc-disable-warning is evaluated positive, then unknown warning
    options are accepted. This should be dropped.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

12 Nov, 2016

2 commits

  • Previously the warnings were added back at the W=1 level and above, this
    now turns them on again by default, assuming that we have addressed all
    warnings and again have a clean build for v4.10.

    I found a number of new warnings in linux-next already and submitted
    bugfixes for those. Hopefully they are caught by the 0day builder in
    the future as soon as this patch is merged.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     
  • Traditionally, we have always had warnings about uninitialized variables
    enabled, as this is part of -Wall, and generally a good idea [1], but it
    also always produced false positives, mainly because this is a variation
    of the halting problem and provably impossible to get right in all cases
    [2].

    Various people have identified cases that are particularly bad for false
    positives, and in commit e74fc973b6e5 ("Turn off -Wmaybe-uninitialized
    when building with -Os"), I turned off the warning for any build that
    was done with CC_OPTIMIZE_FOR_SIZE. This drastically reduced the number
    of false positive warnings in the default build but unfortunately had
    the side effect of turning the warning off completely in 'allmodconfig'
    builds, which in turn led to a lot of warnings (both actual bugs, and
    remaining false positives) to go in unnoticed.

    With commit 877417e6ffb9 ("Kbuild: change CC_OPTIMIZE_FOR_SIZE
    definition") enabled the warning again for allmodconfig builds in v4.7
    and in v4.8-rc1, I had finally managed to address all warnings I get in
    an ARM allmodconfig build and most other maybe-uninitialized warnings
    for ARM randconfig builds.

    However, commit 6e8d666e9253 ("Disable "maybe-uninitialized" warning
    globally") was merged at the same time and disabled it completely for
    all configurations, because of false-positive warnings on x86 that I had
    not addressed until then. This caused a lot of actual bugs to get
    merged into mainline, and I sent several dozen patches for these during
    the v4.9 development cycle. Most of these are actual bugs, some are for
    correct code that is safe because it is only called under external
    constraints that make it impossible to run into the case that gcc sees,
    and in a few cases gcc is just stupid and finds something that can
    obviously never happen.

    I have now done a few thousand randconfig builds on x86 and collected
    all patches that I needed to address every single warning I got (I can
    provide the combined patch for the other warnings if anyone is
    interested), so I hope we can get the warning back and let people catch
    the actual bugs earlier.

    This reverts the change to disable the warning completely and for now
    brings it back at the "make W=1" level, so we can get it merged into
    mainline without introducing false positives. A follow-up patch enables
    it on all levels unless some configuration option turns it off because
    of false-positives.

    Link: https://rusty.ozlabs.org/?p=232 [1]
    Link: https://gcc.gnu.org/wiki/Better_Uninitialized_Warnings [2]
    Signed-off-by: Arnd Bergmann
    Signed-off-by: Linus Torvalds

    Arnd Bergmann
     

11 May, 2016

1 commit

  • gcc-6 started warning by default about variables that are not
    used anywhere and that are marked 'const', generating many
    false positives in an allmodconfig build, e.g.:

    arch/arm/mach-davinci/board-da830-evm.c:282:20: warning: 'da830_evm_emif25_pins' defined but not used [-Wunused-const-variable=]
    arch/arm/plat-omap/dmtimer.c:958:34: warning: 'omap_timer_match' defined but not used [-Wunused-const-variable=]
    drivers/bluetooth/hci_bcm.c:625:39: warning: 'acpi_bcm_default_gpios' defined but not used [-Wunused-const-variable=]
    drivers/char/hw_random/omap-rng.c:92:18: warning: 'reg_map_omap4' defined but not used [-Wunused-const-variable=]
    drivers/devfreq/exynos/exynos5_bus.c:381:32: warning: 'exynos5_busfreq_int_pm' defined but not used [-Wunused-const-variable=]
    drivers/dma/mv_xor.c:1139:34: warning: 'mv_xor_dt_ids' defined but not used [-Wunused-const-variable=]

    This is similar to the existing -Wunused-but-set-variable warning
    that was added in an earlier release and that we disable by default
    now and only enable when W=1 is set, so it makes sense to do
    the same here. Once we have eliminated the majority of the
    warnings for both, we can put them back into the default list.

    We probably want this in backport kernels as well, to allow building
    them with gcc-6 without introducing extra warnings.

    Signed-off-by: Arnd Bergmann
    Acked-by: Olof Johansson
    Acked-by: Lee Jones
    Cc: stable@vger.kernel.org
    Signed-off-by: Michal Marek

    Arnd Bergmann
     

12 Jan, 2016

1 commit

  • Ideally, a kernel compile with W=1 enabled should complete cleanly;
    however, when we run one currently we are presented with ~25k warnings.
    'sign-compare' accounts for ~22k of those ~25k.

    In this patch we're demoting 'sign-compare' warnings to W=2, with a view
    to fixing the remaining 3k W=1 warnings required for a clean build.

    Arnd adds:
    "As per our discussion, I'd add that this was inadvertedly introduced
    by Behan when he moved the clang specific warnings into an ifdef block
    and did not notice that -Wsign-compare was interpreted by both gcc
    and clang.

    Earlier, it was introduced in just the same way by Jan-Simon as part
    of 3d3d6b847420 ("kbuild: LLVMLinux: Adapt warnings for compilation
    with clang")."

    Acked-by: Arnd Bergmann
    Fixes: 26ea6bb1fef0 ("kbuild, LLVMLinux: Supress warnings unless W=1-3")
    Signed-off-by: Lee Jones
    Signed-off-by: Michal Marek

    Lee Jones
     

04 Sep, 2015

1 commit

  • We cannot detect clang before including the arch Makefile, because that
    can set the default cross compiler. We also cannot detect clang after
    including the arch Makefile, because powerpc wants to know about clang.
    Solve this by using an deferred variable. This costs us a few shell
    invocations, but this is only a constant number.

    Reported-by: Behan Webster
    Reported-by: Anton Blanchard
    Signed-off-by: Michal Marek

    Michal Marek
     

05 Aug, 2014

1 commit

  • clang has more warnings enabled by default. Turn them off unless W is
    set. This patch fixes a logic bug where warnings in clang were disabled
    when W was set.

    Signed-off-by: Behan Webster
    Signed-off-by: Jan-Simon Möller
    Signed-off-by: Mark Charlebois
    Cc: bp@alien8.de
    Signed-off-by: Michal Marek

    Behan Webster
     

17 Apr, 2014

1 commit

  • W=... provides extra gcc checks.

    Having such code in scripts/Makefile.build results in the same flags
    being added to KBUILD_CFLAGS multiple times becuase
    scripts/Makefile.build is invoked every time Kbuild descends into
    the subdirectories.

    Since the top Makefile is already too cluttered, this commit moves
    all of extra gcc check stuff to a new file scripts/Makefile.extrawarn,
    which is included from the top Makefile.

    Signed-off-by: Masahiro Yamada
    CC: Sam Ravnborg
    Signed-off-by: Michal Marek

    Masahiro Yamada