Skip to content
Snippets Groups Projects
  1. Dec 08, 2018
  2. Dec 01, 2018
    • Masahiro Yamada's avatar
      kbuild: let fixdep directly write to .*.cmd files · 392885ee
      Masahiro Yamada authored
      
      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
      troublesome.
      
      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
      exists.
      
      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: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      392885ee
    • Masahiro Yamada's avatar
      kbuild: descend into scripts/gcc-plugins/ via scripts/Makefile · ce2fd53a
      Masahiro Yamada authored
      
      Now that 'archprepare' depends on 'scripts', Kbuild can descend into
      scripts/gcc-plugins in a more standard way.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      ce2fd53a
    • Masahiro Yamada's avatar
      kbuild: make 'archprepare' depend on 'scripts' · 059bc9fc
      Masahiro Yamada authored
      
      Before start descending, Kbuild needs to run 'prepare' and 'scripts',
      which has been orthogonal to each other.
      
      Going forward, let's consider 'scripts' is a part of the preparation.
      This will allow more cleanups.
      
      Move 'scripts' to the prerequisite of 'archprepare', where UML starts
      compiling target *.c files.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      059bc9fc
    • Masahiro Yamada's avatar
      kbuild: move modpost out of 'scripts' target · 60df1aee
      Masahiro Yamada authored
      
      I am eagar to build under the scripts/ directory only with $(HOSTCC),
      but scripts/mod/ highly depends on the $(CC) and target arch headers.
      That it why the 'scripts' target must depend on 'asm-generic',
      'gcc-plugins', and $(autoksyms_h).
      
      Move it to the 'prepare0' stage. I know this is a cheesy workaround,
      but better than the current situation.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      60df1aee
    • Masahiro Yamada's avatar
      kbuild: fix UML build error with CONFIG_GCC_PLUGINS · 65bba042
      Masahiro Yamada authored
      
      UML fails to build with CONFIG_GCC_PLUGINS=y.
      
      $ make -s ARCH=um mrproper
      $ make -s ARCH=um allmodconfig
      $ make ARCH=um
        UPD     include/generated/uapi/linux/version.h
        WRAP    arch/x86/include/generated/uapi/asm/bpf_perf_event.h
        WRAP    arch/x86/include/generated/uapi/asm/poll.h
        WRAP    arch/x86/include/generated/asm/dma-contiguous.h
        WRAP    arch/x86/include/generated/asm/early_ioremap.h
        WRAP    arch/x86/include/generated/asm/export.h
        WRAP    arch/x86/include/generated/asm/mcs_spinlock.h
        WRAP    arch/x86/include/generated/asm/mm-arch-hooks.h
        SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
        SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
        SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
        SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
        SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
        SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
        SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
        HOSTCC  scripts/unifdef
        CC      arch/x86/um/user-offsets.s
      cc1: error: cannot load plugin ./scripts/gcc-plugins/cyc_complexity_plugin.so
      ./scripts/gcc-plugins/cyc_complexity_plugin.so: cannot open shared object file: No such file or directory
      cc1: error: cannot load plugin ./scripts/gcc-plugins/structleak_plugin.so
      ./scripts/gcc-plugins/structleak_plugin.so: cannot open shared object file: No such file or directory
      cc1: error: cannot load plugin ./scripts/gcc-plugins/latent_entropy_plugin.so
      ./scripts/gcc-plugins/latent_entropy_plugin.so: cannot open shared object file: No such file or directory
      cc1: error: cannot load plugin ./scripts/gcc-plugins/randomize_layout_plugin.so
      ./scripts/gcc-plugins/randomize_layout_plugin.so: cannot open shared object file: No such file or directory
      make[1]: *** [scripts/Makefile.build;119: arch/x86/um/user-offsets.s] Error 1
      make: *** [arch/um/Makefile;152: arch/x86/um/user-offsets.s] Error 2
      
      Reorder the preparation stage (with cleanups) to make sure gcc-plugins
      is built before descending to arch/x86/um/.
      
      Fixes: 6b90bd4b ("GCC plugin infrastructure")
      Reported-by: default avatarkbuild test robot <lkp@intel.com>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      65bba042
    • Masahiro Yamada's avatar
      kbuild: fix single target build for external module · e07db28e
      Masahiro Yamada authored
      
      Building a single target in an external module fails due to missing
      .tmp_versions directory.
      
      For example,
      
        $ make -C /lib/modules/$(uname -r)/build M=$PWD foo.o
      
      will fail in the following way:
      
        CC [M]  /home/masahiro/foo/foo.o
      /bin/sh: 1: cannot create /home/masahiro/foo/.tmp_versions/foo.mod: Directory nonexistent
      
      This is because $(cmd_crmodverdir) is executed only before building
      /, %/, %.ko single targets of external modules. Create .tmp_versions
      in the 'prepare' target.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      e07db28e
    • Masahiro Yamada's avatar
      kbuild: announce removal of SUBDIRS if used · 0126be38
      Masahiro Yamada authored
      
      SUBDIRS has been kept as a backward compatibility since
      commit ("[PATCH] kbuild: external module support") in 2002.
      
      We do not need multiple ways to do the same thing, so I will remove
      SUBDIRS after the Linux 5.3 release. I cleaned up in-tree code, and
      updated the document so that nobody would try to use it.
      
      Meanwhile, display the following warning if SUBDIRS is used.
      
      Makefile:189: ================= WARNING ================
      Makefile:190: 'SUBDIRS' will be removed after Linux 5.3
      Makefile:191: Please use 'M=' or 'KBUILD_EXTMOD' instead
      Makefile:192: ==========================================
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: Boris Brezillon <boris.brezillon@bootlin.com> # for scx200_docflash.c
      Acked-by: Guenter Roeck <linux@roeck-us.net> # for scx200_wdt.c
      0126be38
  3. Nov 13, 2018
  4. Nov 11, 2018
  5. Nov 04, 2018
  6. Nov 02, 2018
  7. Oct 22, 2018
  8. Oct 19, 2018
  9. Oct 15, 2018
  10. Oct 11, 2018
  11. Oct 07, 2018
  12. Oct 04, 2018
    • Masahiro Yamada's avatar
      kbuild: do not pass $(objtree) to scripts/mkmakefile · 4fd61277
      Masahiro Yamada authored
      
      Since $(objtree) is always '.', it is not useful to pass it to
      scripts/mkmakefile.  I assume nobody wants to run this script directly.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4fd61277
    • Masahiro Yamada's avatar
      kbuild: remove VERSION and PATCHLEVEL from $(objtree)/Makefile · 77ec0c20
      Masahiro Yamada authored
      
      Neither VERSION nor PATCHLEVEL is used in any useful way.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      77ec0c20
    • Masahiro Yamada's avatar
      kbuild: add --include-dir flag only for out-of-tree build · 80463f1b
      Masahiro Yamada authored
      
      The --include-dir flag is used to include check-in Makefiles from
      $(objtree) without $(srctree)/ prefix.  Obviously, this is unneeded
      for in-tree build.  Add the flag just before changing the working
      directory.
      
      This becomes effective after invoking sub-make.  Add a little bit
      comments about it.
      
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      80463f1b
    • Nadav Amit's avatar
      kbuild/Makefile: Prepare for using macros in inline assembly code to work... · 77b0bf55
      Nadav Amit authored
      kbuild/Makefile: Prepare for using macros in inline assembly code to work around asm() related GCC inlining bugs
      
      Using macros in inline assembly allows us to work around bugs
      in GCC's inlining decisions.
      
      Compile macros.S and use it to assemble all C files.
      Currently only x86 will use it.
      
      Background:
      
      The inlining pass of GCC doesn't include an assembler, so it's not aware
      of basic properties of the generated code, such as its size in bytes,
      or that there are such things as discontiuous blocks of code and data
      due to the newfangled linker feature called 'sections' ...
      
      Instead GCC uses a lazy and fragile heuristic: it does a linear count of
      certain syntactic and whitespace elements in inlined assembly block source
      code, such as a count of new-lines and semicolons (!), as a poor substitute
      for "code size and complexity".
      
      Unsurprisingly this heuristic falls over and breaks its neck whith certain
      common types of kernel code that use inline assembly, such as the frequent
      practice of putting useful information into alternative sections.
      
      As a result of this fresh, 20+ years old GCC bug, GCC's inlining decisions
      are effectively disabled for inlined functions that make use of such asm()
      blocks, because GCC thinks those sections of code are "large" - when in
      reality they are often result in just a very low number of machine
      instructions.
      
      This absolute lack of inlining provess when GCC comes across such asm()
      blocks both increases generated kernel code size and causes performance
      overhead, which is particularly noticeable on paravirt kernels, which make
      frequent use of these inlining facilities in attempt to stay out of the
      way when running on baremetal hardware.
      
      Instead of fixing the compiler we use a workaround: we set an assembly macro
      and call it from the inlined assembly block. As a result GCC considers the
      inline assembly block as a single instruction. (Which it often isn't but I digress.)
      
      This uglifies and bloats the source code - for example just the refcount
      related changes have this impact:
      
       Makefile                 |    9 +++++++--
       arch/x86/Makefile        |    7 +++++++
       arch/x86/kernel/macros.S |    7 +++++++
       scripts/Kbuild.include   |    4 +++-
       scripts/mod/Makefile     |    2 ++
       5 files changed, 26 insertions(+), 3 deletions(-)
      
      Yay readability and maintainability, it's not like assembly code is hard to read
      and maintain ...
      
      We also hope that GCC will eventually get fixed, but we are not holding
      our breath for that. Yet we are optimistic, it might still happen, any decade now.
      
      [ mingo: Wrote new changelog describing the background. ]
      
      Tested-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Brian Gerst <brgerst@gmail.com>
      Cc: Denys Vlasenko <dvlasenk@redhat.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: linux-kbuild@vger.kernel.org
      Link: http://lkml.kernel.org/r/20181003213100.189959-3-namit@vmware.com
      
      
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      77b0bf55
  13. Oct 02, 2018
    • Rob Herring's avatar
      kbuild: consolidate Devicetree dtb build rules · 37c8a5fa
      Rob Herring authored
      
      There is nothing arch specific about building dtb files other than their
      location under /arch/*/boot/dts/. Keeping each arch aligned is a pain.
      The dependencies and supported targets are all slightly different.
      Also, a cross-compiler for each arch is needed, but really the host
      compiler preprocessor is perfectly fine for building dtbs. Move the
      build rules to a common location and remove the arch specific ones. This
      is done in a single step to avoid warnings about overriding rules.
      
      The build dependencies had been a mixture of 'scripts' and/or 'prepare'.
      These pull in several dependencies some of which need a target compiler
      (specifically devicetable-offsets.h) and aren't needed to build dtbs.
      All that is really needed is dtc, so adjust the dependencies to only be
      dtc.
      
      This change enables support 'dtbs_install' on some arches which were
      missing the target.
      
      Acked-by: default avatarWill Deacon <will.deacon@arm.com>
      Acked-by: default avatarPaul Burton <paul.burton@mips.com>
      Acked-by: default avatarLey Foon Tan <ley.foon.tan@intel.com>
      Acked-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: linux-kbuild@vger.kernel.org
      Cc: linux-snps-arc@lists.infradead.org
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: uclinux-h8-devel@lists.sourceforge.jp
      Cc: linux-mips@linux-mips.org
      Cc: nios2-dev@lists.rocketboards.org
      Cc: linuxppc-dev@lists.ozlabs.org
      Cc: linux-xtensa@linux-xtensa.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      37c8a5fa
  14. Sep 30, 2018
  15. Sep 23, 2018
  16. Sep 19, 2018
  17. Sep 16, 2018
  18. Sep 14, 2018
  19. Sep 12, 2018
    • Paulo Zanoni's avatar
      tracing/Makefile: Fix handling redefinition of CC_FLAGS_FTRACE · b1f4ff74
      Paulo Zanoni authored
      
      As a Kernel developer, I make heavy use of "make targz-pkg" in order
      to locally compile and remotely install my development Kernels. The
      nice feature I rely on is that after a normal "make", "make targz-pkg"
      only generates the tarball without having to recompile everything.
      
      That was true until commit f28bc3c3 ("tracing: Handle
      CC_FLAGS_FTRACE more accurately"). After it, running "make targz-pkg"
      after "make" will recompile the whole Kernel tree, making my
      development workflow much slower.
      
      The Kernel is choosing to recompile everything because it claims the
      command line has changed. A diff of the .cmd files show a repeated
      -mfentry in one of the files. That is because "make targz-pkg" calls
      "make modules_install" and the environment is already populated with
      the exported variables, CC_FLAGS_FTRACE being one of them. Then,
      -mfentry gets duplicated because it is not protected behind an ifndef
      block, like -pg.
      
      To complicate the problem a little bit more, architectures can define
      their own version CC_FLAGS_FTRACE, so our code not only has to
      consider recursive Makefiles, but also architecture overrides.
      
      So in this patch we move CC_FLAGS_FTRACE up and unconditionally
      define it to -pg. Then we let the architecture Makefiles possibly
      override it, and finally append the extra options later. This ensures
      the variable is always fully redefined at each invocation so recursive
      Makefiles don't keep appending, and hopefully it maintains the
      intended behavior on how architectures can override the defaults..
      
      Thanks Steven Rostedt and Vasily Gorbik for the help on this
      regression.
      
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: linux-kbuild@vger.kernel.org
      Fixes: commit f28bc3c3 ("tracing: Handle CC_FLAGS_FTRACE more accurately")
      Acked-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
      Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      b1f4ff74
  20. Sep 10, 2018
  21. Sep 05, 2018
  22. Sep 02, 2018
  23. Aug 31, 2018
  24. Aug 26, 2018
  25. Aug 23, 2018
Loading