Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Aug 15, 2021
  2. Aug 08, 2021
  3. Aug 05, 2021
  4. Aug 04, 2021
  5. Aug 01, 2021
  6. Jul 25, 2021
  7. Jul 18, 2021
  8. Jul 15, 2021
    • Linus Torvalds's avatar
      Revert "Makefile: Enable -Wimplicit-fallthrough for Clang" · d936eb23
      Linus Torvalds authored
      This reverts commit b7eb335e.
      
      It turns out that the problem with the clang -Wimplicit-fallthrough
      warning is not about the kernel source code, but about clang itself, and
      that the warning is unusable until clang fixes its broken ways.
      
      In particular, when you enable this warning for clang, you not only get
      warnings about implicit fallthroughs.  You also get this:
      
         warning: fallthrough annotation in unreachable code [-Wimplicit-fallthrough]
      
      which is completely broken becasue it
      
       (a) doesn't even tell you where the problem is (seriously: no line
           numbers, no filename, no nothing).
      
       (b) is fundamentally broken anyway, because there are perfectly valid
           reasons to have a fallthrough statement even if it turns out that
           it can perhaps not be reached.
      
      In the kernel, an example of that second case is code in the scheduler:
      
                      switch (state) {
                      case cpuset:
                              if (IS_ENABLED(CONFIG_CPUSETS)) {
                                      cpuset_cpus_allowed_fallback(p);
                                      state = possible;
                                      break;
                              }
                              fallthrough;
                      case possible:
      
      where if CONFIG_CPUSETS is enabled you actually never hit the
      fallthrough case at all.  But that in no way makes the fallthrough
      wrong.
      
      So the warning is completely broken, and enabling it for clang is a very
      bad idea.
      
      In the meantime, we can keep the gcc option enabled, and make the gcc
      build use
      
          -Wimplicit-fallthrough=5
      
      which means that we will at least continue to require a proper
      fallthrough statement, and that gcc won't silently accept the magic
      comment versions. Because gcc does this all correctly, and while the odd
      "=5" part is kind of obscure, it's documented in [1]:
      
        "-Wimplicit-fallthrough=5 doesn’t recognize any comments as
         fallthrough comments, only attributes disable the warning"
      
      so if clang ever fixes its bad behavior we can try enabling it there again.
      
      Link: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
      
       [1]
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d936eb23
  9. Jul 14, 2021
    • Gustavo A. R. Silva's avatar
      Makefile: Enable -Wimplicit-fallthrough for Clang · b7eb335e
      Gustavo A. R. Silva authored
      
      With the recent fixes for fallthrough warnings, it is now possible to
      enable -Wimplicit-fallthrough for Clang.
      
      It's important to mention that since we have adopted the use of the
      pseudo-keyword macro fallthrough; we also want to avoid having more
      /* fall through */ comments being introduced. Notice that contrary
      to GCC, Clang doesn't recognize any comments as implicit fall-through
      markings when the -Wimplicit-fallthrough option is enabled. So, in
      order to avoid having more comments being introduced, we have to use
      the option -Wimplicit-fallthrough=5 for GCC, which similar to Clang,
      will cause a warning in case a code comment is intended to be used
      as a fall-through marking.
      
      Co-developed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      b7eb335e
  10. Jul 11, 2021
  11. Jun 27, 2021
  12. Jun 20, 2021
  13. Jun 16, 2021
    • Masahiro Yamada's avatar
      kbuild: remove trailing slashes from $(KBUILD_EXTMOD) · 74ee585b
      Masahiro Yamada authored
      M= (or KBUILD_EXTMOD) generally expects a directory path without any
      trailing slashes, like M=a/b/c.
      
      If you add a trailing slash, like M=a/b/c/, you will get ugly build
      logs (two slashes in a series), but it still works fine as long as it
      is consistent between 'make modules' and 'make modules_install'.
      
      The following commands correctly build and install the modules.
      
        $ make M=a/b/c/ modules
        $ sudo make M=a/b/c/ modules_install
      
      Since commit ccae4cfa ("kbuild: refactor scripts/Makefile.modinst"),
      a problem happens if you add a trailing slash only for modules_install.
      
        $ make M=a/b/c modules
        $ sudo make M=a/b/c/ modules_install
      
      No module is installed in this case, Johannes Berg reported. [1]
      
      Trim any trailing slashes from $(KBUILD_EXTMOD).
      
      I used the 'dirname' command to remove all the trailing slashes in
      case someone adds more slashes like M=a/b/c/////. The Make's built-in
      function, $(dir ...) cannot take care of such a case.
      
      [1]: https://lore.kernel.org/lkml/10cc8522b27a051e6a9c3e158a4c4b6414fd04a0.camel@sipsolutions.net/
      
      Fixes: ccae4cfa
      
       ("kbuild: refactor scripts/Makefile.modinst")
      Reported-by: default avatarJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      74ee585b
  14. Jun 14, 2021
  15. Jun 13, 2021
  16. Jun 08, 2021
  17. Jun 06, 2021
  18. May 30, 2021
  19. May 26, 2021
  20. May 24, 2021
    • Nick Desaulniers's avatar
      Makefile: LTO: have linker check -Wframe-larger-than · 24845dcb
      Nick Desaulniers authored
      
      -Wframe-larger-than= requires stack frame information, which the
      frontend cannot provide. This diagnostic is emitted late during
      compilation once stack frame size is available.
      
      When building with LTO, the frontend simply lowers C to LLVM IR and does
      not have stack frame information, so it cannot emit this diagnostic.
      When the linker drives LTO, it restarts optimizations and lowers LLVM IR
      to object code. At that point, it has stack frame information but
      doesn't know to check for a specific max stack frame size.
      
      I consider this a bug in LLVM that we need to fix. There are some
      details we're working out related to LTO such as which value to use when
      there are multiple different values specified per TU, or how to
      propagate these to compiler synthesized routines properly, if at all.
      
      Until it's fixed, ensure we don't miss these. At that point we can wrap
      this in a compiler version guard or revert this based on the minimum
      support version of Clang.
      
      The error message is not generated during link:
        LTO     vmlinux.o
      ld.lld: warning: stack size limit exceeded (8224) in foobarbaz
      
      Cc: Sami Tolvanen <samitolvanen@google.com>
      Reported-by: default avatarCandle Sun <candlesea@gmail.com>
      Suggested-by: default avatarFangrui Song <maskray@google.com>
      Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20210312010942.1546679-1-ndesaulniers@google.com
      24845dcb
  21. May 23, 2021
  22. May 16, 2021
  23. May 09, 2021
  24. May 05, 2021
  25. May 03, 2021
  26. May 01, 2021
  27. Apr 25, 2021
  28. Apr 24, 2021
    • Nathan Chancellor's avatar
      kbuild: Add $(KBUILD_HOSTLDFLAGS) to 'has_libelf' test · f634ca65
      Nathan Chancellor authored
      Normally, invocations of $(HOSTCC) include $(KBUILD_HOSTLDFLAGS), which
      in turn includes $(HOSTLDFLAGS), which allows users to pass in their own
      flags when linking. However, the 'has_libelf' test does not, meaning
      that if a user requests a specific linker via HOSTLDFLAGS=-fuse-ld=...,
      it is not respected and the build might error.
      
      For example, if a user building with clang wants to use all of the LLVM
      tools without any GNU tools, they might remove all of the GNU tools from
      their system or PATH then build with
      
      $ make HOSTLDFLAGS=-fuse-ld=lld LLVM=1 LLVM_IAS=1
      
      which says use all of the LLVM tools, the integrated assembler, and
      ld.lld for linking host executables. Without this change, the build will
      error because $(HOSTCC) uses its default linker, rather than the one
      requested via -fuse-ld=..., which is GNU ld in clang's case in a default
      configuration.
      
      error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please
      install libelf-dev, libelf-devel or elfutils-libelf-devel
      make[1]: *** [Makefile:1260: prepare-objtool] Error 1
      
      Add $(KBUILD_HOSTLDFLAGS) to the 'has_libelf' test so that the linker
      choice is respected.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/479
      
      
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      f634ca65
    • Masahiro Yamada's avatar
      kbuild: merge scripts/Makefile.modsign to scripts/Makefile.modinst · 961ab4a3
      Masahiro Yamada authored
      scripts/Makefile.modsign is a subset of scripts/Makefile.modinst,
      and duplicates the code. Let's merge them.
      
      By the way, you do not need to run 'make modules_sign' explicitly
      because modules are signed as a part of 'make modules_install' when
      CONFIG_MODULE_SIG_ALL=y. If CONFIG_MODULE_SIG_ALL=n, mod_sign_cmd is
      set to 'true', so 'make modules_sign' is not functional.
      
      In my understanding, the reason of still keeping this is to handle
      corner cases like commit 64178cb6
      
       ("builddeb: fix stripped module
      signatures if CONFIG_DEBUG_INFO and CONFIG_MODULE_SIG_ALL are set").
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      961ab4a3
    • Masahiro Yamada's avatar
      kbuild: move module strip/compression code into scripts/Makefile.modinst · 65ce9c38
      Masahiro Yamada authored
      
      Both mod_strip_cmd and mod_compress_cmd are only used in
      scripts/Makefile.modinst, hence there is no good reason to define them
      in the top Makefile. Move the relevant code to scripts/Makefile.modinst.
      
      Also, show separate log messages for each of install, strip, sign, and
      compress.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      65ce9c38
    • Masahiro Yamada's avatar
      kbuild: refactor scripts/Makefile.modinst · ccae4cfa
      Masahiro Yamada authored
      
      scripts/Makefile.modinst is ugly and weird in multiple ways; it
      specifies real files $(modules) as phony, makes directory manipulation
      needlessly too complicated.
      
      Clean up the Makefile code, and show the full path of installed modules
      in the log.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      ccae4cfa
    • Masahiro Yamada's avatar
      kbuild: rename extmod-prefix to extmod_prefix · 7f69180b
      Masahiro Yamada authored
      
      This seems to be useful in sub-make as well. As a preparation of
      exporting it, rename extmod-prefix to extmod_prefix because exported
      variables cannot contain hyphens.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      7f69180b