Skip to content
Snippets Groups Projects
  1. Sep 01, 2024
    • Masahiro Yamada's avatar
      kbuild: remove *.symversions left-over · 87af9388
      Masahiro Yamada authored
      
      Commit 5ce2176b ("genksyms: adjust the output format to modpost")
      stopped generating *.symversions files.
      
      Remove the left-over from the .gitignore file and the 'clean' rule.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      87af9388
    • Laurent Pinchart's avatar
      Remove *.orig pattern from .gitignore · 76be4f5a
      Laurent Pinchart authored
      
      Commit 3f1b0e1f (".gitignore update") added *.orig and *.rej
      patterns to .gitignore in v2.6.23. The commit message didn't give a
      rationale. Later on, commit 1f5d3a6b ("Remove *.rej pattern from
      .gitignore") removed the *.rej pattern in v2.6.26, on the rationale that
      *.rej files indicated something went really wrong and should not be
      ignored.
      
      The *.rej files are now shown by `git status`, which helps located
      conflicts when applying patches and lowers the probability that they
      will go unnoticed. It is however still easy to overlook the *.orig files
      which slowly polute the source tree. That's not as big of a deal as not
      noticing a conflict, but it's still not nice.
      
      Drop the *.orig pattern from .gitignore to avoid this and help keep the
      source tree clean.
      
      Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      [masahiroy@kernel.org:
      I do not have a strong opinion about this. Perhaps some people may have
      a different opinion.
      
      If you are someone who wants to ignore *.orig, it is likely you would
      want to do so across all projects. Then, $XDG_CONFIG_HOME/git/ignore
      would be more suitable for your needs. gitignore(5) suggests, "Patterns
      which a user wants Git to ignore in all situations generally go into a
      file specified by core.excludesFile in the user's ~/.gitconfig".
      
      Please note that you cannot do the opposite; if *.orig is ignored by
      the project's .gitignore, you cannot override the decision because
      $XDG_CONFIG_HOME/git/ignore has a lower priority.
      
      If *.orig is sitting on the fence, I'd leave it to the users. ]
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      76be4f5a
  2. Jul 21, 2024
  3. Feb 19, 2024
    • Masahiro Yamada's avatar
      kbuild: create a list of all built DTB files · 24507871
      Masahiro Yamada authored
      
      It is useful to have a list of all *.dtb and *.dtbo files generated
      from the current build.
      
      With this commit, 'make dtbs' creates arch/*/boot/dts/dtbs-list, which
      lists the dtb(o) files created in the current build. It maintains the
      order of the dtb-y additions in Makefiles although the order is not
      important for DTBs. It is a (good) side effect through the reuse of the
      modules.order rule.
      
      Please note this list only includes the files directly added to dtb-y.
      
      For example, consider this case:
      
          foo-dtbs := foo_base.dtb foo_overlay.dtbo
          dtb-y := foo.dtb
      
      In this example, the list will include foo.dtb, but not foo_base.dtb
      or foo_overlay.dtbo.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      24507871
  4. Dec 28, 2023
  5. Oct 03, 2023
  6. Jul 24, 2023
  7. Jul 04, 2023
  8. 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
  9. Apr 20, 2023
  10. Apr 05, 2023
  11. Mar 16, 2023
  12. Feb 05, 2023
  13. Jan 22, 2023
    • Masahiro Yamada's avatar
      .gitignore: update the command to check tracked files being ignored · b8a9ddca
      Masahiro Yamada authored
      
      Recent git versions do not accept the noted command.
      
        $ git ls-files -i --exclude-standard
        fatal: ls-files -i must be used with either -o or -c
      
      The -c was implied before, but we need to make it explicit since
      git commit b338e9f66873 ("ls-files: error out on -i unless -o or -c
      are specified").
      
      Also, replace --exclude-standard with --exclude-per-directory=.gitignore
      so that everyone will get consistent results.
      
      git-ls-files(1) says:
      
        --exclude-standard
            Add the standard Git exclusions: .git/info/exclude, .gitignore in
            each directory, and the user's global exclusion file.
      
      We cannot predict what is locally added to .git/info/exclude or the
      user's global exclusion file.
      
      We can only manage .gitignore files committed to the repository.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarMiguel Ojeda <ojeda@kernel.org>
      b8a9ddca
  14. Dec 30, 2022
  15. Nov 18, 2022
  16. Sep 28, 2022
  17. May 07, 2022
    • Masahiro Yamada's avatar
      kbuild: split the second line of *.mod into *.usyms · 9413e764
      Masahiro Yamada authored
      
      The *.mod files have two lines; the first line lists the member objects
      of the module, and the second line, if CONFIG_TRIM_UNUSED_KSYMS=y, lists
      the undefined symbols.
      
      Currently, we generate *.mod after constructing composite modules,
      otherwise, we cannot compute the second line. No prerequisite is
      required to print the first line.
      
      They are orthogonal. Splitting them into separate commands will ease
      further cleanups.
      
      This commit splits the list of undefined symbols out to *.usyms files.
      
      Previously, the list of undefined symbols ended up with a very long
      line, but now it has one symbol per line.
      
      Use sed like we did before commit 7d32358b ("kbuild: avoid split
      lines in .mod files").
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: default avatarNicolas Schier <nicolas@fjasle.eu>
      9413e764
  18. May 01, 2021
  19. Apr 24, 2021
    • Masahiro Yamada's avatar
      kbuild: generate Module.symvers only when vmlinux exists · 69bc8d38
      Masahiro Yamada authored
      
      The external module build shows the following warning if Module.symvers
      is missing in the kernel tree.
      
        WARNING: Symbol version dump "Module.symvers" is missing.
                 Modules may not have dependencies or modversions.
      
      I think this is an important heads-up because the resulting modules may
      not work as expected. This happens when you did not build the entire
      kernel tree, for example, you might have prepared the minimal setups
      for external modules by 'make defconfig && make modules_preapre'.
      
      A problem is that 'make modules' creates Module.symvers even without
      vmlinux. In this case, that warning is suppressed since Module.symvers
      already exists in spite of its incomplete content.
      
      The incomplete (i.e. invalid) Module.symvers should not be created.
      
      This commit changes the second pass of modpost to dump symbols into
      modules-only.symvers. The final Module.symvers is created by
      concatenating vmlinux.symvers and modules-only.symvers if both exist.
      
      Module.symvers is supposed to collect symbols from both vmlinux and
      modules. It might be a bit confusing, and I am not quite sure if it
      is an official interface, but presumably it is difficult to rename it
      because some tools (e.g. kmod) parse it.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      69bc8d38
    • Rasmus Villemoes's avatar
      kbuild: add CONFIG_VMLINUX_MAP expert option · 5cc12472
      Rasmus Villemoes authored
      
      It can be quite useful to have ld emit a link map file, in order to
      debug or verify that special sections end up where they are supposed
      to, and to see what LD_DEAD_CODE_DATA_ELIMINATION manages to get rid
      of.
      
      The only reason I'm not just adding this unconditionally is that the
      .map file can be rather large (several MB), and that's a waste of
      space when one isn't interested in these things. Also make it depend
      on CONFIG_EXPERT.
      
      Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5cc12472
  20. Feb 04, 2021
  21. Jan 14, 2021
  22. Sep 10, 2020
  23. Jul 31, 2020
  24. Jul 05, 2020
  25. Jun 06, 2020
    • Masahiro Yamada's avatar
      modpost: generate vmlinux.symvers and reuse it for the second modpost · 269a535c
      Masahiro Yamada authored
      
      The full build runs modpost twice, first for vmlinux.o and second for
      modules.
      
      The first pass dumps all the vmlinux symbols into Module.symvers, but
      the second pass parses vmlinux again instead of reusing the dump file,
      presumably because it needs to avoid accumulating stale symbols.
      
      Loading symbol info from a dump file is faster than parsing an ELF object.
      Besides, modpost deals with various issues to parse vmlinux in the second
      pass.
      
      A solution is to make the first pass dumps symbols into a separate file,
      vmlinux.symvers. The second pass reads it, and parses module .o files.
      The merged symbol information is dumped into Module.symvers in the same
      way as before.
      
      This makes further modpost cleanups possible.
      
      Also, it fixes the problem of 'make vmlinux', which previously overwrote
      Module.symvers, throwing away module symbols.
      
      I slightly touched scripts/link-vmlinux.sh so that vmlinux is re-linked
      when you cross this commit. Otherwise, vmlinux.symvers would not be
      generated.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      269a535c
  26. Mar 25, 2020
  27. Mar 02, 2020
  28. Feb 20, 2020
  29. Nov 11, 2019
  30. Sep 10, 2019
  31. Aug 21, 2019
  32. Jul 27, 2019
  33. Jul 17, 2019
    • Masahiro Yamada's avatar
      kbuild: create *.mod with full directory path and remove MODVERDIR · b7dca6dd
      Masahiro Yamada authored
      While descending directories, Kbuild produces objects for modules,
      but do not link final *.ko files; it is done in the modpost.
      
      To keep track of modules, Kbuild creates a *.mod file in $(MODVERDIR)
      for every module it is building. Some post-processing steps read the
      necessary information from *.mod files. This avoids descending into
      directories again. This mechanism was introduced in 2003 or so.
      
      Later, commit 551559e1 ("kbuild: implement modules.order") added
      modules.order. So, we can simply read it out to know all the modules
      with directory paths. This is easier than parsing the first line of
      *.mod files.
      
      $(MODVERDIR) has a flat directory structure, that is, *.mod files
      are named only with base names. This is based on the assumption that
      the module name is unique across the tree. This assumption is really
      fragile.
      
      Stephen Rothwell reported a race condition caused by a module name
      conflict:
      
        https://lkml.org/lkml/2019/5/13/991
      
      
      
      In parallel building, two different threads could write to the same
      $(MODVERDIR)/*.mod simultaneously.
      
      Non-unique module names are the source of all kind of troubles, hence
      commit 3a48a919 ("kbuild: check uniqueness of module names")
      introduced a new checker script.
      
      However, it is still fragile in the build system point of view because
      this race happens before scripts/modules-check.sh is invoked. If it
      happens again, the modpost will emit unclear error messages.
      
      To fix this issue completely, create *.mod with full directory path
      so that two threads never attempt to write to the same file.
      
      $(MODVERDIR) is no longer needed.
      
      Since modules with directory paths are listed in modules.order, Kbuild
      is still able to find *.mod files without additional descending.
      
      I also killed cmd_secanalysis; scripts/mod/sumversion.c computes MD4 hash
      for modules with MODULE_VERSION(). When CONFIG_DEBUG_SECTION_MISMATCH=y,
      it occurs not only in the modpost stage, but also during directory
      descending, where sumversion.c may parse stale *.mod files. It would emit
      'No such file or directory' warning when an object consisting a module is
      renamed, or when a single-obj module is turned into a multi-obj module or
      vice versa.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarNicolas Pitre <nico@fluxnic.net>
      b7dca6dd
  34. Jul 09, 2019
    • Masahiro Yamada's avatar
      kbuild: do not create wrappers for header-test-y · c93a0368
      Masahiro Yamada authored
      
      header-test-y does not work with headers in sub-directories.
      
      For example, you may want to write a Makefile, like this:
      
      include/linux/Kbuild:
      
        header-test-y += mtd/nand.h
      
      This entry will create a wrapper include/linux/mtd/nand.hdrtest.c
      with the following content:
      
        #include "mtd/nand.h"
      
      To make this work, we need to add $(srctree)/include/linux to the
      header search path. It would be tedious to add ccflags-y.
      
      Instead, we could change the *.hdrtest.c rule to wrap:
      
        #include "nand.h"
      
      This works for in-tree build since #include "..." searches in the
      relative path from the header with this directive. For O=... build,
      we need to add $(srctree)/include/linux/mtd to the header search path,
      which will be even more tedious.
      
      After all, I thought it would be handier to compile headers directly
      without creating wrappers.
      
      I added a new build rule to compile %.h into %.h.s
      
      The target is %.h.s instead of %.h.o because it is slightly faster.
      Also, as for GCC, an empty assembly is smaller than an empty object.
      
      I wrote the build rule:
      
        $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $<
      
      instead of:
      
        $(CC) $(c_flags) -S -o $@ -x c $<
      
      Both work fine with GCC, but the latter is bad for Clang.
      
      This comes down to the difference in the -Wunused-function policy.
      GCC does not warn about unused 'static inline' functions at all.
      Clang does not warn about the ones in included headers, but does
      about the ones in the source. So, we should handle headers as
      headers, not as source files.
      
      In fact, this has been hidden since commit abb2ea7d ("compiler,
      clang: suppress warning for unused static inline functions"), but we
      should not rely on that.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
      Tested-by: default avatarJani Nikula <jani.nikula@intel.com>
      c93a0368
  35. Jun 15, 2019
Loading