1. 26 Jan, 2019 1 commit
    • Masahiro Yamada's avatar
      kbuild: let fixdep directly write to .*.cmd files · a41c9b57
      Masahiro Yamada authored
      [ Upstream commit 392885ee ]
      Currently, fixdep writes dependencies to .*.tmp, which is renamed to
      .*.cmd after everything succeeds. This is a very safe way to avoid
      corrupted .*.cmd files. The if_changed_dep has carried this safety
      mechanism since it was added in 2002.
      If fixdep fails for some reasons or a user terminates the build while
      fixdep is running, the incomplete output from the fixdep could be
      This is my insight about some bad scenarios:
      [1] If the compiler succeeds to generate *.o file, but fixdep fails
          to write necessary dependencies to .*.cmd file, Make will miss
          to rebuild the object when headers or CONFIG options are changed.
          In this case, fixdep should not generate .*.cmd file at all so
          that 'arg-check' will surely trigger the rebuild of the object.
      [2] A partially constructed .*.cmd file may not be a syntactically
          correct makefile. The next time Make runs, it would include it,
          then fail to parse it. Once this happens, 'make clean' is be the
          only way to fix it.
      In fact, [1] is no longer a problem since commit 9c2af1c7 ("kbuild:
      add .DELETE_ON_ERROR special target"). Make deletes a target file on
      any failure in its recipe. Because fixdep is a part of the recipe of
      *.o target, if it fails, the *.o is deleted anyway. However, I am a
      bit worried about the slight possibility of [2].
      So, here is a solution. Let fixdep directly write to a .*.cmd file,
      but allow makefiles to include it only when its corresponding target
      This effectively reverts commit 2982c953 ("kbuild: remove redundant
      $(wildcard ...) for cmd_files calculation"), and commit 00d78ab2
      ("kbuild: remove dead code in cmd_files calculation in top Makefile")
      because now we must check the presence of targets.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
  2. 28 Nov, 2018 1 commit
  3. 19 Oct, 2018 2 commits
    • Masahiro Yamada's avatar
      kbuild: use 'else ifeq' for checksrc to improve readability · 7d0ea252
      Masahiro Yamada authored
      'ifeq ... else ifeq ... endif' notation is supported by GNU Make 3.81
      or later, which is the requirement for building the kernel since
      commit 37d69ee3 ("docs: bump minimal GNU Make version to 3.81").
      Use it to improve the readability.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    • Masahiro Yamada's avatar
      kbuild: remove unneeded link_multi_deps · 69ea912f
      Masahiro Yamada authored
      Since commit c8589d1e ("kbuild: handle multi-objs dependency
      appropriately"), $^ really represents all the prerequisite of the
      composite object being built.
      Hence, $(filter %.o,$^) contains all the objects to link together,
      which is much simpler than link_multi_deps calculation.
      Please note $(filter-out FORCE,$^) does not work here. When a single
      object module is turned into a multi object module, $^ will contain
      header files that were previously included for building the single
      object, and recorded in the .*.cmd file. To filter out such headers,
      $(filter %.o,$^) should be used here.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
  4. 19 Sep, 2018 1 commit
  5. 12 Sep, 2018 1 commit
  6. 30 Aug, 2018 1 commit
  7. 23 Aug, 2018 2 commits
  8. 16 Aug, 2018 1 commit
  9. 09 Aug, 2018 1 commit
  10. 06 Jul, 2018 1 commit
  11. 21 Jun, 2018 1 commit
  12. 28 May, 2018 1 commit
  13. 17 May, 2018 2 commits
  14. 07 Apr, 2018 4 commits
    • Masahiro Yamada's avatar
      kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS markers · 54a702f7
      Masahiro Yamada authored
      GNU Make automatically deletes intermediate files that are updated
      in a chain of pattern rules.
      Example 1) %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
      Example 2) %.o <- %.c <- %.c_shipped
      A couple of makefiles mark such targets as .PRECIOUS to prevent Make
      from deleting them, but the correct way is to use .SECONDARY.
          Prerequisites of this special target are treated as intermediate
          files but are never automatically deleted.
          When make is interrupted during execution, it may delete the target
          file it is updating if the file was modified since make started.
          If you mark the file as precious, make will never delete the file
          if interrupted.
      Both can avoid deletion of intermediate files, but the difference is
      the behavior when Make is interrupted; .SECONDARY deletes the target,
      but .PRECIOUS does not.
      The use of .PRECIOUS is relatively rare since we do not want to keep
      partially constructed (possibly corrupted) targets.
      Another difference is that .PRECIOUS works with pattern rules whereas
      .SECONDARY does not.
        .PRECIOUS: $(obj)/%.lex.c
      works, but
        .SECONDARY: $(obj)/%.lex.c
      has no effect.  However, for the reason above, I do not want to use
      .PRECIOUS which could cause obscure build breakage.
      The targets specified as .SECONDARY must be explicit.  $(targets)
      contains all targets that need to include .*.cmd files.  So, the
      intermediates you want to keep are mostly in there.  Therefore, mark
      $(targets) as .SECONDARY.  It means primary targets are also marked
      as .SECONDARY, but I do not see any drawback for this.
      I replaced some .SECONDARY / .PRECIOUS markers with 'targets'.  This
      will make Kbuild search for non-existing .*.cmd files, but this is
      not a noticeable performance issue.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: 's avatarFrank Rowand <frowand.list@gmail.com>
      Acked-by: 's avatarIngo Molnar <mingo@kernel.org>
    • Masahiro Yamada's avatar
      kbuild: rename *-asn1.[ch] to *.asn1.[ch] · 4fa8bc94
      Masahiro Yamada authored
      Our convention is to distinguish file types by suffixes with a period
      as a separator.
      *-asn1.[ch] is a different pattern from other generated sources such
      as *.lex.c, *.tab.[ch], *.dtb.S, etc.  More confusing, files with
      '-asn1.[ch]' are generated files, but '_asn1.[ch]' are checked-in
      Rename generated files to *.asn1.[ch] for consistency.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    • Masahiro Yamada's avatar
      kbuild: add %.dtb.S and %.dtb to 'targets' automatically · a7f92419
      Masahiro Yamada authored
      Another common pattern that consists of chained commands is to compile
      a DTB as binary data into the kernel image or a module.  It is used in
      several places in the source tree.  Support it in the core Makefile.
      $(call if_changed,dt_S_dtb) is more suitable than $(call cmd,dt_S_dtb)
      in case cmd_dt_S_dtb is changed in the future.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: 's avatarFrank Rowand <frowand.list@gmail.com>
    • Masahiro Yamada's avatar
      kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically · b23d1a24
      Masahiro Yamada authored
      Files generated by if_changed* must be added to 'targets' to include
      *.cmd files.  Otherwise, they would be regenerated every time.
      The build system automatically adds objects to 'targets' where
      appropriate, such as obj-y, extra-y, etc. but does nothing for
      intermediate files.  So, each Makefile needs to add them by itself.
      There are some common cases where objects are generated by chained
      rules.  Lexers and parsers are compiled like follows:
         %.lex.o <- %.lex.c <- %.l
         %.tab.o <- %.tab.c <- %.y
      They are common patterns, so it is reasonable to take care of them
      in the core Makefile instead of requiring each Makefile to do so.
      At this moment, you cannot delete 'target += zconf.lex.c' in the
      Kconfig Makefile because zconf.lex.c is included from zconf.tab.c
      instead of being compiled separately.  It should be deleted after
      Kconfig is more refactored.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: 's avatarFrank Rowand <frowand.list@gmail.com>
  15. 25 Mar, 2018 10 commits
  16. 21 Feb, 2018 3 commits
  17. 16 Jan, 2018 1 commit
  18. 20 Nov, 2017 1 commit
    • Matthew Wilcox's avatar
      Add optional check for bad kernel-doc comments · 3a025e1d
      Matthew Wilcox authored
      Implement a '-none' output mode for kernel-doc which will only output
      warning messages, and suppresses the warning message about there being
      no kernel-doc in the file.
      If the build has requested additional warnings, automatically check all
      .c files.  This patch does not check .h files.  Enabling the warning
      by default would add about 1300 warnings, so it's default off for now.
      People who care can use this to check they didn't break the docs and
      maybe we'll get all the warnings fixed and be able to enable this check
      by default in the future.
      Signed-off-by: 's avatarMatthew Wilcox <mawilcox@microsoft.com>
      Signed-off-by: 's avatarJonathan Corbet <corbet@lwn.net>
  19. 18 Nov, 2017 1 commit
    • Masahiro Yamada's avatar
      kbuild: create built-in.o automatically if parent directory wants it · f7adc312
      Masahiro Yamada authored
      "obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory
      and link built-in.o from that directory.  This means foo/Makefile is
      responsible for creating built-in.o even if there is no object to
      link (in this case, built-in.o is an empty archive).
      We have had several fixups like commit 4b024242 ("kbuild: Fix
      linking error built-in.o no such file or directory"), then ended up
      with a complex condition as follows:
        ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
        builtin-target := $(obj)/built-in.o
      We still have more cases not covered by the above, so we need to add
        obj- := dummy.o
      in several places just for creating empty built-in.o.
      A key point is, the parent Makefile knows whether built-in.o is needed
      or not.  If a subdirectory needs to create built-in.o, its parent can
      tell the fact when descending.
      If non-empty $(need-builtin) flag is passed from the parent, built-in.o
      should be created.  $(obj-y) should be still checked to support the
      single target "%/".  All of ugly tricks will go away.
      Signed-off-by: 's avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: 's avatarSam Ravnborg <sam@ravnborg.org>
  20. 16 Nov, 2017 4 commits