Skip to content
Snippets Groups Projects
  1. Sep 02, 2023
  2. Aug 27, 2023
  3. Aug 20, 2023
  4. Aug 13, 2023
  5. Aug 06, 2023
  6. Jul 30, 2023
  7. Jul 23, 2023
  8. Jul 16, 2023
  9. Jul 09, 2023
  10. Jun 27, 2023
    • Masahiro Yamada's avatar
      kbuild: revive "Entering directory" for Make >= 4.4.1 · 5fc10e76
      Masahiro Yamada authored
      
      With commit 9da0763b ("kbuild: Use relative path when building in
      a subdir of the source tree"), compiler messages in out-of-tree builds
      include relative paths, which are relative to the build directory, not
      the directory where make was started.
      
      To help IDEs/editors find the source files, Kbuild lets GNU Make print
      "Entering directory ..." when it changes the working directory. It has
      been working fine for a long time, but David reported it is broken with
      the latest GNU Make.
      
      The behavior was changed by GNU Make commit 8f9e7722ff0f ("[SV 63537]
      Fix setting -w in makefiles"). Previously, setting --no-print-directory
      to MAKEFLAGS only affected child makes, but it is now interpreted in
      the current make as soon as it is set.
      
      [test code]
      
        $ cat /tmp/Makefile
        ifneq ($(SUBMAKE),1)
        MAKEFLAGS += --no-print-directory
        all: ; $(MAKE) SUBMAKE=1
        else
        all: ; :
        endif
      
      [before 8f9e7722ff0f]
      
        $ make -C /tmp
        make: Entering directory '/tmp'
        make SUBMAKE=1
        :
        make: Leaving directory '/tmp'
      
      [after 8f9e7722ff0f]
      
        $ make -C /tmp
        make SUBMAKE=1
        :
      
      Previously, the effect of --no-print-directory was delayed until Kbuild
      started the directory descending, but it is no longer true with GNU Make
      4.4.1.
      
      This commit adds one more recursion to cater to GNU Make >= 4.4.1.
      
      When Kbuild needs to change the working directory, __submake will be
      executed twice.
      
        __submake without --no-print-directory  --> show "Entering directory ..."
        __submake with    --no-print-directory  --> parse the rest of Makefile
      
      We end up with one more recursion than needed for GNU Make < 4.4.1, but
      I do not want to complicate the version check.
      
      Reported-by: default avatarDavid Howells <dhowells@redhat.com>
      Closes: https://lore.kernel.org/all/2427604.1686237298@warthog.procyon.org.uk/
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: default avatarNicolas Schier <n.schier@avm.de>
      5fc10e76
    • Masahiro Yamada's avatar
      kbuild: set correct abs_srctree and abs_objtree for package builds · 5fa94ceb
      Masahiro Yamada authored
      
      When you run 'make rpm-pkg', the rpmbuild tool builds the kernel in
      rpmbuild/BUILD, but $(abs_srctree) and $(abs_objtree) point to the
      directory path where make was started, not the kernel is actually
      being built. The same applies to 'make snap-pkg'. Fix it.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5fa94ceb
  11. Jun 26, 2023
  12. Jun 25, 2023
  13. Jun 24, 2023
  14. Jun 22, 2023
    • Masahiro Yamada's avatar
      kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion · 5e9e95cc
      Masahiro Yamada authored
      When CONFIG_TRIM_UNUSED_KSYMS is enabled, Kbuild recursively traverses
      the directory tree to determine which EXPORT_SYMBOL to trim. If an
      EXPORT_SYMBOL turns out to be unused by anyone, Kbuild begins the
      second traverse, where some source files are recompiled with their
      EXPORT_SYMBOL() tuned into a no-op.
      
      Linus stated negative opinions about this slowness in commits:
      
       - 5cf0fd59 ("Kbuild: disable TRIM_UNUSED_KSYMS option")
       - a555bdd0 ("Kbuild: enable TRIM_UNUSED_KSYMS again, with some guarding")
      
      We can do this better now. The final data structures of EXPORT_SYMBOL
      are generated by the modpost stage, so modpost can selectively emit
      KSYMTAB entries that are really used by modules.
      
      Commit f73edc89 ("kbuild: unify two modpost invocations") is another
      ground-work to do this in a one-pass algorithm. With the list of modules,
      modpost sets sym->used if it is used by a module. modpost emits KSYMTAB
      only for symbols with sym->used==true.
      
      BTW, Nicolas explained why the trimming was implemented with recursion:
      
        https://lore.kernel.org/all/2o2rpn97-79nq-p7s2-nq5-8p83391473r@syhkavp.arg/
      
      
      
      Actually, we never achieved that level of optimization where the chain
      reaction of trimming comes into play because:
      
       - CONFIG_LTO_CLANG cannot remove any unused symbols
       - CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled only for vmlinux,
         but not modules
      
      If deeper trimming is required, we need to revisit this, but I guess
      that is unlikely to happen.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5e9e95cc
  15. Jun 18, 2023
  16. Jun 11, 2023
  17. Jun 04, 2023
  18. May 28, 2023
  19. May 22, 2023
  20. May 21, 2023
  21. May 14, 2023
  22. May 07, 2023
  23. Apr 23, 2023
  24. Apr 17, 2023
  25. Apr 16, 2023
  26. Apr 09, 2023
  27. Apr 02, 2023
  28. Mar 26, 2023
  29. Mar 19, 2023
  30. Mar 16, 2023
  31. Mar 15, 2023
  32. Mar 12, 2023
  33. Mar 05, 2023
  34. Feb 19, 2023
  35. Feb 16, 2023
    • Masahiro Yamada's avatar
      kbuild: add a tool to list files ignored by git · 5c3d1d0a
      Masahiro Yamada authored
      In short, the motivation of this commit is to build a source package
      without cleaning the source tree.
      
      The deb-pkg and (src)rpm-pkg targets first run 'make clean' before
      creating a source tarball. Otherwise build artifacts such as *.o,
      *.a, etc. would be included in the tarball. Yet, the tarball ends up
      containing several garbage files since 'make clean' does not clean
      everything.
      
      Cleaning the tree every time is annoying since it makes the incremental
      build impossible. It is desirable to create a source tarball without
      cleaning the tree.
      
      In fact, there are some ways to achieve this.
      
      The easiest solution is 'git archive'. 'make perf-tar*-src-pkg' uses
      it, but I do not like it because it works only when the source tree is
      managed by git, and all files you want in the tarball must be committed
      in advance.
      
      I want to make it work without relying on git. We can do this.
      
      Files that are ignored by git are generated files, so should be excluded
      from the source tarball. We can list them out by parsing the .gitignore
      files. Of course, .gitignore does not cover all the cases, but it works
      well enough.
      
      tar(1) claims to support it:
      
        --exclude-vcs-ignores
      
          Exclude files that match patterns read from VCS-specific ignore files.
          Supported files are: .cvsignore, .gitignore, .bzrignore, and .hgignore.
      
      The best scenario would be to use 'tar --exclude-vcs-ignores', but this
      option does not work. --exclude-vcs-ignore does not understand any of
      the negation (!), preceding slash, following slash, etc.. So, this option
      is just useless.
      
      Hence, I wrote this gitignore parser. The previous version [1], written
      in Python, was so slow. This version is implemented in C, so it works
      much faster.
      
      I imported the code from git (commit: 23c56f7bd5f1), so we get the same
      result.
      
      This tool traverses the source tree, parsing all .gitignore files, and
      prints file paths that are ignored by git.
      
      The output is similar to 'git ls-files --ignored --directory --others
      --exclude-per-directory=.gitignore', except
      
        [1] Not sorted
        [2] No trailing slash for directories
      
      [2] is intentional because tar's --exclude-from option cannot handle
      trailing slashes.
      
      [How to test this tool]
      
        $ git clean -dfx
        $ make -s -j$(nproc) defconfig all                       # or allmodconifg or whatever
        $ git archive -o ../linux1.tar --prefix=./ HEAD
        $ tar tf ../linux1.tar | LANG=C sort > ../file-list1     # files emitted by 'git archive'
        $ make scripts_package
          HOSTCC  scripts/list-gitignored
        $ scripts/list-gitignored  --prefix=./ -o ../exclude-list
        $ tar cf ../linux2.tar --exclude-from=../exclude-list .
        $ tar tf ../linux2.tar | LANG=C sort > ../file-list2     # files emitted by 'tar'
        $ diff  ../file-list1 ../file-list2 | grep -E '^(<|>)'
        < ./Documentation/devicetree/bindings/.yamllint
        < ./drivers/clk/.kunitconfig
        < ./drivers/gpu/drm/tests/.kunitconfig
        < ./drivers/hid/.kunitconfig
        < ./fs/ext4/.kunitconfig
        < ./fs/fat/.kunitconfig
        < ./kernel/kcsan/.kunitconfig
        < ./lib/kunit/.kunitconfig
        < ./mm/kfence/.kunitconfig
        < ./tools/testing/selftests/arm64/tags/
        < ./tools/testing/selftests/arm64/tags/.gitignore
        < ./tools/testing/selftests/arm64/tags/Makefile
        < ./tools/testing/selftests/arm64/tags/run_tags_test.sh
        < ./tools/testing/selftests/arm64/tags/tags_test.c
        < ./tools/testing/selftests/kvm/.gitignore
        < ./tools/testing/selftests/kvm/Makefile
        < ./tools/testing/selftests/kvm/config
        < ./tools/testing/selftests/kvm/settings
      
      The source tarball contains most of files that are tracked by git. You
      see some diffs, but it is just because some .gitignore files are wrong.
      
        $ git ls-files -i -c --exclude-per-directory=.gitignore
        Documentation/devicetree/bindings/.yamllint
        drivers/clk/.kunitconfig
        drivers/gpu/drm/tests/.kunitconfig
        drivers/hid/.kunitconfig
        fs/ext4/.kunitconfig
        fs/fat/.kunitconfig
        kernel/kcsan/.kunitconfig
        lib/kunit/.kunitconfig
        mm/kfence/.kunitconfig
        tools/testing/selftests/arm64/tags/.gitignore
        tools/testing/selftests/arm64/tags/Makefile
        tools/testing/selftests/arm64/tags/run_tags_test.sh
        tools/testing/selftests/arm64/tags/tags_test.c
        tools/testing/selftests/kvm/.gitignore
        tools/testing/selftests/kvm/Makefile
        tools/testing/selftests/kvm/config
        tools/testing/selftests/kvm/settings
      
      [1]: https://lore.kernel.org/all/20230128173843.765212-1-masahiroy@kernel.org/
      
      
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5c3d1d0a
  36. Feb 12, 2023
  37. Feb 07, 2023
Loading