1. 03 6月, 2020 1 次提交
  2. 01 6月, 2020 4 次提交
  3. 29 5月, 2020 2 次提交
    • N
      Makefile: support compressed debug info · 10e68b02
      Nick Desaulniers 提交于
      As debug information gets larger and larger, it helps significantly save
      the size of vmlinux images to compress the information in the debug
      information sections. Note: this debug info is typically split off from
      the final compressed kernel image, which is why vmlinux is what's used
      in conjunction with GDB. Minimizing the debug info size should have no
      impact on boot times, or final compressed kernel image size.
      
      All of the debug sections will have a `C` flag set.
      $ readelf -S <object file>
      
      $ bloaty vmlinux.gcc75.compressed.dwarf4 -- \
          vmlinux.gcc75.uncompressed.dwarf4
      
          FILE SIZE        VM SIZE
       --------------  --------------
        +0.0%     +18  [ = ]       0    [Unmapped]
       -73.3%  -114Ki  [ = ]       0    .debug_aranges
       -76.2% -2.01Mi  [ = ]       0    .debug_frame
       -73.6% -2.89Mi  [ = ]       0    .debug_str
       -80.7% -4.66Mi  [ = ]       0    .debug_abbrev
       -82.9% -4.88Mi  [ = ]       0    .debug_ranges
       -70.5% -9.04Mi  [ = ]       0    .debug_line
       -79.3% -10.9Mi  [ = ]       0    .debug_loc
       -39.5% -88.6Mi  [ = ]       0    .debug_info
       -18.2%  -123Mi  [ = ]       0    TOTAL
      
      $ bloaty vmlinux.clang11.compressed.dwarf4 -- \
          vmlinux.clang11.uncompressed.dwarf4
      
          FILE SIZE        VM SIZE
       --------------  --------------
        +0.0%     +23  [ = ]       0    [Unmapped]
       -65.6%    -871  [ = ]       0    .debug_aranges
       -77.4% -1.84Mi  [ = ]       0    .debug_frame
       -82.9% -2.33Mi  [ = ]       0    .debug_abbrev
       -73.1% -2.43Mi  [ = ]       0    .debug_str
       -84.8% -3.07Mi  [ = ]       0    .debug_ranges
       -65.9% -8.62Mi  [ = ]       0    .debug_line
       -86.2% -40.0Mi  [ = ]       0    .debug_loc
       -42.0% -64.1Mi  [ = ]       0    .debug_info
       -22.1%  -122Mi  [ = ]       0    TOTAL
      
      For x86_64 defconfig + LLVM=1 (before):
      Elapsed (wall clock) time (h:mm:ss or m:ss): 3:22.03
      Maximum resident set size (kbytes): 43856
      
      For x86_64 defconfig + LLVM=1 (after):
      Elapsed (wall clock) time (h:mm:ss or m:ss): 3:32.52
      Maximum resident set size (kbytes): 1566776
      
      Thanks to:
      Nick Clifton helped us to provide the minimal binutils version.
      Sedat Dilek found an increase in size of debug .deb package.
      
      Cc: Nick Clifton <nickc@redhat.com>
      Suggested-by: NDavid Blaikie <blaikie@google.com>
      Reviewed-by: NFangrui Song <maskray@google.com>
      Tested-by: NSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: NNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      10e68b02
    • M
      kbuild: disallow multi-word in M= or KBUILD_EXTMOD · e9e81b63
      Masahiro Yamada 提交于
      $(firstword ...) in scripts/Makefile.modpost was added by commit
      3f3fd3c0 ("[PATCH] kbuild: allow multi-word $M in Makefile.modpost")
      to build multiple external module directories.
      
      It was a solution to resolve symbol dependencies when an external
      module depends on another external module.
      
      Commit 0d96fb20 ("kbuild: Add new Kbuild variable
      KBUILD_EXTRA_SYMBOLS") introduced another solution by passing symbol
      info via KBUILD_EXTRA_SYMBOLS, then broke the multi-word M= support.
      
        include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \
                     $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile)
      
      ... does not work if KBUILD_EXTMOD contains multiple words.
      
      This feature has been broken for more than a decade. Remove the
      bitrotten code, and stop parsing if M or KBUILD_EXTMOD contains
      multiple words.
      
      As Documentation/kbuild/modules.rst explains, if your module depends
      on another one, there are two solutions:
        - add a common top-level Kbuild file
        - use KBUILD_EXTRA_SYMBOLS
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      e9e81b63
  4. 25 5月, 2020 7 次提交
  5. 17 5月, 2020 1 次提交
    • M
      kbuild: add infrastructure to build userspace programs · 7f3a59db
      Masahiro Yamada 提交于
      Kbuild supports the infrastructure to build host programs, but there
      was no support to build userspace programs for the target architecture
      (i.e. the same architecture as the kernel).
      
      Sam Ravnborg worked on this in 2014 (https://lkml.org/lkml/2014/7/13/154),
      but it was not merged. One problem at that time was, there was no good way
      to know whether $(CC) can link standalone programs. In fact, pre-built
      kernel.org toolchains [1] are often used for building the kernel, but they
      do not provide libc.
      
      Now, we can handle this cleanly because the compiler capability is
      evaluated at the Kconfig time. If $(CC) cannot link standalone programs,
      the relevant options are hidden by 'depends on CC_CAN_LINK'.
      
      The implementation just mimics scripts/Makefile.host
      
      The userspace programs are compiled with the same flags as the host
      programs. In addition, it uses -m32 or -m64 if it is found in
      $(KBUILD_CFLAGS).
      
      This new syntax has two usecases.
      
      - Sample programs
      
        Several userspace programs under samples/ include UAPI headers
        installed in usr/include. Most of them were previously built for
        the host architecture just to use the 'hostprogs' syntax.
      
        However, 'make headers' always works for the target architecture.
        This caused the arch mismatch in cross-compiling. To fix this
        distortion, sample code should be built for the target architecture.
      
      - Bpfilter
      
        net/bpfilter/Makefile compiles bpfilter_umh as the user mode helper,
        and embeds it into the kernel. Currently, it overrides HOSTCC with
        CC to use the 'hostprogs' syntax. This hack should go away.
      
      [1]: https://mirrors.edge.kernel.org/pub/tools/crosstool/Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NSam Ravnborg <sam@ravnborg.org>
      7f3a59db
  6. 12 5月, 2020 1 次提交
  7. 11 5月, 2020 1 次提交
  8. 10 5月, 2020 5 次提交
    • L
      gcc-10: disable 'restrict' warning for now · adc71920
      Linus Torvalds 提交于
      gcc-10 now warns about passing aliasing pointers to functions that take
      restricted pointers.
      
      That's actually a great warning, and if we ever start using 'restrict'
      in the kernel, it might be quite useful.  But right now we don't, and it
      turns out that the only thing this warns about is an idiom where we have
      declared a few functions to be "printf-like" (which seems to make gcc
      pick up the restricted pointer thing), and then we print to the same
      buffer that we also use as an input.
      
      And people do that as an odd concatenation pattern, with code like this:
      
          #define sysfs_show_gen_prop(buffer, fmt, ...) \
              snprintf(buffer, PAGE_SIZE, "%s"fmt, buffer, __VA_ARGS__)
      
      where we have 'buffer' as both the destination of the final result, and
      as the initial argument.
      
      Yes, it's a bit questionable.  And outside of the kernel, people do have
      standard declarations like
      
          int snprintf( char *restrict buffer, size_t bufsz,
                        const char *restrict format, ... );
      
      where that output buffer is marked as a restrict pointer that cannot
      alias with any other arguments.
      
      But in the context of the kernel, that 'use snprintf() to concatenate to
      the end result' does work, and the pattern shows up in multiple places.
      And we have not marked our own version of snprintf() as taking restrict
      pointers, so the warning is incorrect for now, and gcc picks it up on
      its own.
      
      If we do start using 'restrict' in the kernel (and it might be a good
      idea if people find places where it matters), we'll need to figure out
      how to avoid this issue for snprintf and friends.  But in the meantime,
      this warning is not useful.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      adc71920
    • L
      gcc-10: disable 'stringop-overflow' warning for now · 5a76021c
      Linus Torvalds 提交于
      This is the final array bounds warning removal for gcc-10 for now.
      
      Again, the warning is good, and we should re-enable all these warnings
      when we have converted all the legacy array declaration cases to
      flexible arrays. But in the meantime, it's just noise.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5a76021c
    • L
      gcc-10: disable 'array-bounds' warning for now · 44720996
      Linus Torvalds 提交于
      This is another fine warning, related to the 'zero-length-bounds' one,
      but hitting the same historical code in the kernel.
      
      Because C didn't historically support flexible array members, we have
      code that instead uses a one-sized array, the same way we have cases of
      zero-sized arrays.
      
      The one-sized arrays come from either not wanting to use the gcc
      zero-sized array extension, or from a slight convenience-feature, where
      particularly for strings, the size of the structure now includes the
      allocation for the final NUL character.
      
      So with a "char name[1];" at the end of a structure, you can do things
      like
      
             v = my_malloc(sizeof(struct vendor) + strlen(name));
      
      and avoid the "+1" for the terminator.
      
      Yes, the modern way to do that is with a flexible array, and using
      'offsetof()' instead of 'sizeof()', and adding the "+1" by hand.  That
      also technically gets the size "more correct" in that it avoids any
      alignment (and thus padding) issues, but this is another long-term
      cleanup thing that will not happen for 5.7.
      
      So disable the warning for now, even though it's potentially quite
      useful.  Having a slew of warnings that then hide more urgent new issues
      is not an improvement.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      44720996
    • L
      gcc-10: disable 'zero-length-bounds' warning for now · 5c45de21
      Linus Torvalds 提交于
      This is a fine warning, but we still have a number of zero-length arrays
      in the kernel that come from the traditional gcc extension.  Yes, they
      are getting converted to flexible arrays, but in the meantime the gcc-10
      warning about zero-length bounds is very verbose, and is hiding other
      issues.
      
      I missed one actual build failure because it was hidden among hundreds
      of lines of warning.  Thankfully I caught it on the second go before
      pushing things out, but it convinced me that I really need to disable
      the new warnings for now.
      
      We'll hopefully be all done with our conversion to flexible arrays in
      the not too distant future, and we can then re-enable this warning.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5c45de21
    • L
      Stop the ad-hoc games with -Wno-maybe-initialized · 78a5255f
      Linus Torvalds 提交于
      We have some rather random rules about when we accept the
      "maybe-initialized" warnings, and when we don't.
      
      For example, we consider it unreliable for gcc versions < 4.9, but also
      if -O3 is enabled, or if optimizing for size.  And then various kernel
      config options disabled it, because they know that they trigger that
      warning by confusing gcc sufficiently (ie PROFILE_ALL_BRANCHES).
      
      And now gcc-10 seems to be introducing a lot of those warnings too, so
      it falls under the same heading as 4.9 did.
      
      At the same time, we have a very straightforward way to _enable_ that
      warning when wanted: use "W=2" to enable more warnings.
      
      So stop playing these ad-hoc games, and just disable that warning by
      default, with the known and straight-forward "if you want to work on the
      extra compiler warnings, use W=123".
      
      Would it be great to have code that is always so obvious that it never
      confuses the compiler whether a variable is used initialized or not?
      Yes, it would.  In a perfect world, the compilers would be smarter, and
      our source code would be simpler.
      
      That's currently not the world we live in, though.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      78a5255f
  9. 04 5月, 2020 1 次提交
  10. 27 4月, 2020 1 次提交
  11. 20 4月, 2020 1 次提交
  12. 13 4月, 2020 1 次提交
  13. 09 4月, 2020 2 次提交
  14. 08 4月, 2020 2 次提交
    • M
      kbuild: link lib-y objects to vmlinux forcibly when CONFIG_MODULES=y · 7273ad2b
      Masahiro Yamada 提交于
      Kbuild supports not only obj-y but also lib-y to list objects linked to
      vmlinux.
      
      The difference between them is that all the objects from obj-y are
      forcibly linked to vmlinux, whereas the objects from lib-y are linked
      as needed; if there is no user of a lib-y object, it is not linked.
      
      lib-y is intended to list utility functions that may be called from all
      over the place (and may be unused at all), but it is a problem for
      EXPORT_SYMBOL(). Even if there is no call-site in the vmlinux, we need
      to keep exported symbols for the use from loadable modules.
      
      Commit 7f2084fa ("[kbuild] handle exports in lib-y objects reliably")
      worked around it by linking a dummy object, lib-ksyms.o, which contains
      references to all the symbols exported from lib.a in that directory.
      It uses the linker script command, EXTERN. Unfortunately, the meaning of
      EXTERN of ld.lld is different from that of ld.bfd. Therefore, this does
      not work with LD=ld.lld (CBL issue #515).
      
      Anyway, the build rule of lib-ksyms.o is somewhat tricky. So, I want to
      get rid of it.
      
      At first, I was thinking of accumulating lib-y objects into obj-y
      (or even replacing lib-y with obj-y entirely), but the lib-y syntax
      is used beyond the ordinary use in lib/ and arch/*/lib/.
      
      Examples:
      
       - drivers/firmware/efi/libstub/Makefile builds lib.a, which is linked
         into vmlinux in the own way (arm64), or linked to the decompressor
         (arm, x86).
      
       - arch/alpha/lib/Makefile builds lib.a which is linked not only to
         vmlinux, but also to bootloaders in arch/alpha/boot/Makefile.
      
       - arch/xtensa/boot/lib/Makefile builds lib.a for use from
         arch/xtensa/boot/boot-redboot/Makefile.
      
      One more thing, adding everything to obj-y would increase the vmlinux
      size of allnoconfig (or tinyconfig).
      
      For less impact, I tweaked the destination of lib.a at the top Makefile;
      when CONFIG_MODULES=y, lib.a goes to KBUILD_VMLINUX_OBJS, which is
      forcibly linked to vmlinux, otherwise lib.a goes to KBUILD_VMLINUX_LIBS
      as before.
      
      The size impact for normal usecases is quite small since at lease one
      symbol in every lib-y object is eventually called by someone. In case
      you are intrested, here are the figures.
      
      x86_64_defconfig:
      
         text	   data	    bss	    dec	    hex	filename
      19566602 5422072 1589328 26578002 1958c52 vmlinux.before
      19566932 5422104 1589328 26578364 1958dbc vmlinux.after
      
      The case with the biggest impact is allnoconfig + CONFIG_MODULES=y.
      
      ARCH=x86 allnoconfig + CONFIG_MODULES=y:
      
         text	   data	    bss	    dec	    hex	filename
      1175162	 254740	1220608	2650510	 28718e	vmlinux.before
      1177974	 254836	1220608	2653418	 287cea	vmlinux.after
      
      Hopefully this is still not a big deal. The per-file trimming with the
      static library is not so effective after all.
      
      If fine-grained optimization is desired, some architectures support
      CONFIG_LD_DEAD_CODE_DATA_ELIMINATION, which trims dead code per-symbol
      basis. When LTO is supported in mainline, even better optimization will
      be possible.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/515Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reported-by: Nkbuild test robot <lkp@intel.com>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      7273ad2b
    • N
      kbuild: Enable -Wtautological-compare · afe956c5
      Nathan Chancellor 提交于
      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=42666Signed-off-by: NNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      afe956c5
  15. 01 4月, 2020 1 次提交
  16. 30 3月, 2020 1 次提交
  17. 29 3月, 2020 4 次提交
    • D
      kbuild: add outputmakefile to no-dot-config-targets · 4623980d
      David Engraf 提交于
      The target outputmakefile is used to generate a Makefile
      for out-of-tree builds and does not depend on the kernel
      configuration.
      Signed-off-by: NDavid Engraf <david.engraf@sysgo.com>
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      4623980d
    • M
      kbuild: remove AS variable · aa824e0c
      Masahiro Yamada 提交于
      As commit 5ef87263 ("kbuild: get rid of misleading $(AS) from
      documents") noted, we rarely use $(AS) directly in the kernel build.
      
      Now that the only/last user of $(AS) in drivers/net/wan/Makefile was
      converted to $(CC), $(AS) is no longer used in the build process.
      
      You can still pass in AS=clang, which is just a switch to turn on
      the LLVM integrated assembler.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      Tested-by: NNick Desaulniers <ndesaulniers@google.com>
      Reviewed-by: NNathan Chancellor <natechancellor@gmail.com>
      aa824e0c
    • M
      kbuild: add comment about grouped target · f463c351
      Masahiro Yamada 提交于
      GNU Make commit 8c888d95f618 ("[SV 8297] Implement "grouped targets"
      for explicit rules.") added the '&:' syntax.
      
      I think '&:' is a perfect fit here, but we cannot use it any time
      soon. Just add a TODO comment.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      f463c351
    • M
      kbuild: add -Wall to KBUILD_HOSTCXXFLAGS · 735aab1e
      Masahiro Yamada 提交于
      Add -Wall to catch more warnings for C++ host programs.
      
      When I submitted the previous version, the 0-day bot reported
      -Wc++11-compat warnings for old GCC:
      
        HOSTCXX -fPIC scripts/gcc-plugins/latent_entropy_plugin.o
      In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:28:0,
                       from scripts/gcc-plugins/gcc-common.h:15,
                       from scripts/gcc-plugins/latent_entropy_plugin.c:78:
      /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:102:21: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
          fprintf ((FILE), "%s"HOST_WIDE_INT_PRINT_UNSIGNED"\n",\
                           ^
      /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/config/elfos.h:170:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
             fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                              ^
      In file included from /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/tm.h:42:0,
                       from scripts/gcc-plugins/gcc-common.h:15,
                       from scripts/gcc-plugins/latent_entropy_plugin.c:78:
      /usr/lib/gcc/x86_64-linux-gnu/4.8/plugin/include/defaults.h:126:24: warning: C++11 requires a space between string literal and macro [-Wc++11-compat]
             fprintf ((FILE), ","HOST_WIDE_INT_PRINT_UNSIGNED",%u\n",  \
                              ^
      
      The source of the warnings is in the plugin headers, so we have no
      control of it. I just suppressed them by adding -Wno-c++11-compat to
      scripts/gcc-plugins/Makefile.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NKees Cook <keescook@chromium.org>
      735aab1e
  18. 25 3月, 2020 1 次提交
  19. 23 3月, 2020 1 次提交
  20. 19 3月, 2020 1 次提交
  21. 16 3月, 2020 1 次提交