1. 01 12月, 2018 14 次提交
    • M
      kbuild: change if_changed_rule for multi-line recipe · 3a2429e1
      Masahiro Yamada 提交于
      The 'define' ... 'endef' directive is useful to confine a series of
      shell commands into a single macro:
      
        define foo
                [action1]
                [action2]
                [action3]
        endif
      
      Each action is executed in a separate subshell.
      
      However, rule_cc_o_c and rule_as_o_S in scripts/Makefile.build are
      written as follows (with a trailing semicolon in each cmd_*):
      
        define rule_cc_o_c
                [action1] ; \
                [action2] ; \
                [action3] ;
        endef
      
      All shell commands are concatenated with '; \' so that it looks like
      a single command from the Makefile point of view. This does not
      exploit the benefits of 'define' ... 'endef' form because a single
      shell command can be more simply written, like this:
      
        rule_cc_o_c = \
                [action1] ; \
                [action2] ; \
                [action3] ;
      
      I guess the intention for the command concatenation was to let the
      '@set -e' in if_changed_rule cover all the commands.
      
      We can improve the readability by moving '@set -e' to the 'cmd' macro.
      The combo of $(call echo-cmd,*) $(cmd_*) in rule_cc_o_c and rule_as_o_S
      have been replaced with $(call cmd,*). The trailing back-slashes have
      been removed.
      
      Here is a note about the performance: the commands in rule_cc_o_c and
      rule_as_o_S were previously executed all together in a single subshell,
      but now each line in a separate subshell. This means Make will spawn
      extra subshells [1]. I measured the build performance for
        x86_64_defconfig + CONFIG_MODVERSIONS + CONFIG_TRIM_UNUSED_KSYMS
      and I saw slight performance regression, but I believe code readability
      and maintainability wins.
      
      [1] Precisely, GNU Make may optimize this by executing the command
          directly instead of forking a subshell, if no shell special
          characters are found in the command line and omitting the subshell
          will not change the behavior.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      3a2429e1
    • M
      kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS · bbda5ec6
      Masahiro Yamada 提交于
      My main motivation of this commit is to clean up scripts/Kbuild.include
      and scripts/Makefile.build.
      
      Currently, CONFIG_TRIM_UNUSED_KSYMS works with a tricky gimmick;
      possibly exported symbols are detected by letting $(CPP) replace
      EXPORT_SYMBOL* with a special string '=== __KSYM_*===', which is
      post-processed by sed, and passed to fixdep. The extra preprocessing
      is costly, and hacking cmd_and_fixdep is ugly.
      
      I came up with a new way to find exported symbols; insert a dummy
      symbol __ksym_marker_* to each potentially exported symbol. Those
      dummy symbols are picked up by $(NM), post-processed by sed, then
      appended to .*.cmd files. I collected the post-process part to a
      new shell script scripts/gen_ksymdeps.sh for readability. The dummy
      symbols are put into the .discard.* section so that the linker
      script rips them off the final vmlinux or modules.
      
      A nice side-effect is building with CONFIG_TRIM_UNUSED_KSYMS will
      be much faster.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NNicolas Pitre <nico@linaro.org>
      bbda5ec6
    • M
      kbuild: refactor modversions build rules · ee3e46b7
      Masahiro Yamada 提交于
      Let $(CC) compile objects into normal files *.o instead of .tmp_*.o
      whether CONFIG_MODVERSIONS is enabled or not. With this, the input
      file for objtool is always *.o so objtool_o can go away.
      
      I guess the reason of using .tmp_*.o for intermediate objects was
      to avoid leaving incomplete *.o file (, whose timestamp says it is
      up-to-date) when the genksyms tool failed for some reasons.
      
      It no longer matters because any targets are deleted on errors since
      commit 9c2af1c7 ("kbuild: add .DELETE_ON_ERROR special target").
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      ee3e46b7
    • M
      kbuild: remove redundant 'set -e' from sub_cmd_record_mcount · 4317ee3b
      Masahiro Yamada 提交于
      This is executed inside the if_changed_rule, which already sets
      'set -e'.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      4317ee3b
    • M
      kbuild: remove redundant 'set -e' from filechk_offsets · f3fd4a3f
      Masahiro Yamada 提交于
      The filechk macro in scripts/Kbuild.include already sets 'set -e'.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      f3fd4a3f
    • M
      kbuild: let fixdep directly write to .*.cmd files · 392885ee
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      392885ee
    • M
      kbuild: descend into scripts/gcc-plugins/ via scripts/Makefile · ce2fd53a
      Masahiro Yamada 提交于
      Now that 'archprepare' depends on 'scripts', Kbuild can descend into
      scripts/gcc-plugins in a more standard way.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      ce2fd53a
    • M
      kbuild: move modpost out of 'scripts' target · 60df1aee
      Masahiro Yamada 提交于
      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: NMasahiro Yamada <yamada.masahiro@socionext.com>
      60df1aee
    • M
      modpost: move unresolved symbol checks to check_exports() · 3b415288
      Masahiro Yamada 提交于
      This will fit better in check_exports() than add_versions().
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      3b415288
    • M
      modpost: merge module iterations · c6826ad8
      Masahiro Yamada 提交于
      Probably, this is just a matter of the order of error/warning
      messages. Merge the two for-loops.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      c6826ad8
    • M
      modpost: refactor seen flag clearing in add_depends() · d2665ca8
      Masahiro Yamada 提交于
      You do not need to iterate over all modules for resetting ->seen flag
      because add_depends() is only interested in modules that export symbols
      referenced from the given 'mod'.
      
      This also avoids shadowing the 'modules' parameter of add_depends().
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      d2665ca8
    • M
      modpost: file2alias: check prototype of handler · f880eea6
      Masahiro Yamada 提交于
      Use specific prototype instead of an opaque pointer so that the
      compiler can catch function prototype mismatch.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NMathieu Malaterre <malat@debian.org>
      f880eea6
    • M
      modpost: file2alias: go back to simple devtable lookup · ec91e78d
      Masahiro Yamada 提交于
      Commit e49ce141 ("modpost: use linker section to generate table.")
      was not so cool as we had expected first; it ended up with ugly section
      hacks when commit dd2a3aca ("mod/file2alias: make modpost compile
      on darwin again") came in.
      
      Given a certain degree of unknowledge about the link stage of host
      programs, I really want to see simple, stupid table lookup so that
      this works in the same way regardless of the underlying executable
      format.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NMathieu Malaterre <malat@debian.org>
      ec91e78d
    • P
      modpost: skip ELF local symbols during section mismatch check · a4d26f1a
      Paul Walmsley 提交于
      During development of a serial console driver with a gcc 8.2.0
      toolchain for RISC-V, the following modpost warning appeared:
      
      ----
      WARNING: vmlinux.o(.data+0x19b10): Section mismatch in reference from the variable .LANCHOR1 to the function .init.text:sifive_serial_console_setup()
      The variable .LANCHOR1 references
      the function __init sifive_serial_console_setup()
      If the reference is valid then annotate the
      variable with __init* or __refdata (see linux/init.h) or name the variable:
      *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
      ----
      
      ".LANCHOR1" is an ELF local symbol, automatically created by gcc's section
      anchor generation code:
      
      https://gcc.gnu.org/onlinedocs/gccint/Anchored-Addresses.html
      
      https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/varasm.c;h=cd9591a45617464946dcf9a126dde277d9de9804;hb=9fb89fa845c1b2e0a18d85ada0b077c84508ab78#l7473
      
      This was verified by compiling the kernel with -fno-section-anchors
      and observing that the ".LANCHOR1" ELF local symbol disappeared, and
      modpost no longer warned about the section mismatch.  The serial
      driver code idiom triggering the warning is standard Linux serial
      driver practice that has a specific whitelist inclusion in modpost.c.
      
      I'm neither a modpost nor an ELF expert, but naively, it doesn't seem
      useful for modpost to report section mismatch warnings caused by ELF
      local symbols by default.  Local symbols have compiler-generated
      names, and thus bypass modpost's whitelisting algorithm, which relies
      on the presence of a non-autogenerated symbol name.  This increases
      the likelihood that false positive warnings will be generated (as in
      the above case).
      
      Thus, disable section mismatch reporting on ELF local symbols.  The
      rationale here is similar to that of commit 2e3a10a1 ("ARM: avoid
      ARM binutils leaking ELF local symbols") and of similar code already
      present in modpost.c:
      
      https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/mod/modpost.c?h=v4.19-rc4&id=7876320f88802b22d4e2daf7eb027dd14175a0f8#n1256
      
      This third version of the patch implements a suggestion from Masahiro
      Yamada <yamada.masahiro@socionext.com> to restructure the code as an
      additional pattern matching step inside secref_whitelist(), and
      further improves the patch description.
      Signed-off-by: NPaul Walmsley <paul.walmsley@sifive.com>
      Signed-off-by: NPaul Walmsley <paul@pwsan.com>
      Acked-by: NSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      a4d26f1a
  2. 21 11月, 2018 3 次提交
  3. 11 11月, 2018 4 次提交
  4. 06 11月, 2018 2 次提交
    • M
      kbuild: deb-pkg: fix bindeb-pkg breakage when O= is used · 02826a6b
      Masahiro Yamada 提交于
      Ard Biesheuvel reports bindeb-pkg with O= option is broken in the
      following way:
      
        ...
          LD [M]  sound/soc/rockchip/snd-soc-rk3399-gru-sound.ko
          LD [M]  sound/soc/rockchip/snd-soc-rockchip-pcm.ko
          LD [M]  sound/soc/rockchip/snd-soc-rockchip-rt5645.ko
          LD [M]  sound/soc/rockchip/snd-soc-rockchip-spdif.ko
          LD [M]  sound/soc/sh/rcar/snd-soc-rcar.ko
         fakeroot -u debian/rules binary
        make KERNELRELEASE=4.19.0-12677-g19beffaf7a99-dirty ARCH=arm64 KBUILD_SRC= intdeb-pkg
        /bin/bash /home/ard/linux/scripts/package/builddeb
        Makefile:600: include/config/auto.conf: No such file or directory
        ***
        *** Configuration file ".config" not found!
        ***
        *** Please run some configurator (e.g. "make oldconfig" or
        *** "make menuconfig" or "make xconfig").
        ***
        make[12]: *** [syncconfig] Error 1
        make[11]: *** [syncconfig] Error 2
        make[10]: *** [include/config/auto.conf] Error 2
        make[9]: *** [__sub-make] Error 2
        ...
      
      Prior to commit 80463f1b ("kbuild: add --include-dir flag only
      for out-of-tree build"), both srctree and objtree were added to
      --include-dir redundantly, and the wrong code '$MAKE image_name'
      was working by relying on that. Now, the potential issue that had
      previously been hidden just showed up.
      
      '$MAKE image_name' recurses to the generated $(objtree)/Makefile and
      ends up with running in srctree, which is incorrect. It should be
      invoked with '-f $srctree/Makefile' (or KBUILD_SRC=) to be executed
      in objtree.
      
      Fixes: 80463f1b ("kbuild: add --include-dir flag only for out-of-tree build")
      Reported-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Tested-by: NArd Biesheuvel <ard.biesheuvel@linaro.org>
      02826a6b
    • M
      kbuild: rpm-pkg: fix binrpm-pkg breakage when O= is used · 21b42eb4
      Masahiro Yamada 提交于
      Zhenzhong Duan reported that running 'make O=/build/kernel binrpm-pkg'
      failed with the following errors:
      
        Running 'make O=/build/kernel binrpm-pkg' failed with below two errors.
      
        Makefile:600: include/config/auto.conf: No such file or directory
      
        + cp make -C /mnt/root/kernel O=/build/kernel image_name make -f
        /mnt/root/kernel/Makefile ...
        cp: invalid option -- 'C'
        Try 'cp --help' for more information.
      
      Prior to commit 80463f1b ("kbuild: add --include-dir flag only
      for out-of-tree build"), both srctree and objtree were added to
      --include-dir redundantly, and the wrong code 'make image_name'
      was working by relying on that. Now, the potential issue that had
      previously been hidden just showed up.
      
      'make image_name' recurses to the generated $(objtree)/Makefile and
      ends up with running in srctree, which is incorrect. It should be
      invoked with '-f $srctree/Makefile' (or KBUILD_SRC=) to be executed
      in objtree.
      
      Fixes: 80463f1b ("kbuild: add --include-dir flag only for out-of-tree build")
      Reported-by: NZhenzhong Duan <zhenzhong.duan@oracle.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      21b42eb4
  5. 02 11月, 2018 2 次提交
  6. 01 11月, 2018 4 次提交
  7. 31 10月, 2018 1 次提交
  8. 28 10月, 2018 2 次提交
  9. 27 10月, 2018 1 次提交
  10. 19 10月, 2018 4 次提交
  11. 17 10月, 2018 1 次提交
    • H
      extract-vmlinux: Check for uncompressed image as fallback · db139d71
      Helge Deller 提交于
      As on x86-64 and other architectures, the boot kernel on parisc (vmlinuz
      and bzImage) contains a full compressed copy of the final kernel
      executable (vmlinux.bin.gz), which one should be able to extract with
      the extract-vmlinux script.
      
      But on parisc extracting the kernel with extract-vmlinux fails.
      Currently the script first checks if the given file is an ELF file
      (which is true on parisc) and if so returns it.  Thus on parisc we
      unexpectedly get back the vmlinuz boot file instead of the uncompressed
      vmlinux image.
      
      This patch fixes this issue by reverting the logic. It now first tries
      to find a compression signature in the given file and if that fails it
      checks the file itself as fallback.
      Signed-off-by: NHelge Deller <deller@gmx.de>
      db139d71
  12. 11 10月, 2018 1 次提交
  13. 04 10月, 2018 1 次提交