1. 14 12月, 2022 5 次提交
  2. 13 12月, 2022 6 次提交
    • M
      kbuild: use .NOTINTERMEDIATE for future GNU Make versions · 875ef1a5
      Masahiro Yamada 提交于
      In Kbuild, some files are generated by chains of pattern/implicit rules.
      For example, *.dtb.o files in drivers/of/unittest-data/Makefile are
      generated by the chain of 3 pattern rules, like this:
      
        %.dts  ->  %.dtb  ->  %.dtb.S  ->  %.dtb.o
      
      Here, %.dts is the real source, %.dtb.o is the final target.
      %.dtb and %.dtb.S are called "intermediate files".
      
      As GNU Make manual [1] says, intermediate files are treated differently
      in two ways:
      
       (a) The first difference is what happens if the intermediate file does
         not exist. If an ordinary file 'b' does not exist, and make considers
         a target that depends on 'b', it invariably creates 'b' and then
         updates the target from 'b'. But if 'b' is an intermediate file, then
         make can leave well enough alone: it won't create 'b' unless one of
         its prerequisites is out of date. This means the target depending
         on 'b' won't be rebuilt either, unless there is some other reason
         to update that target: for example the target doesn't exist or a
         different prerequisite is newer than the target.
      
       (b) The second difference is that if make does create 'b' in order to
         update something else, it deletes 'b' later on after it is no longer
         needed. Therefore, an intermediate file which did not exist before
         make also does not exist after make. make reports the deletion to
         you by printing a 'rm' command showing which file it is deleting.
      
      The combination of these is problematic for Kbuild because most of the
      build rules depend on FORCE and the if_changed* macros really determine
      if the target should be updated. So, all missing files, whether they
      are intermediate or not, are always rebuilt.
      
      To see the problem, delete ".SECONDARY:" from scripts/Kbuild.include,
      and repeat this command:
      
        $ make allmodconfig drivers/of/unittest-data/
      
      The intermediate files will be deleted, which results in rebuilding
      intermediate and final objects in the next run of make.
      
      In the old days, people suppressed (b) in inconsistent ways.
      As commit 54a702f7 ("kbuild: mark $(targets) as .SECONDARY and
      remove .PRECIOUS markers") noted, you should not use .PRECIOUS because
      .PRECIOUS has the following behavior (c), which is not likely what you
      want.
      
       (c) If make is killed or interrupted during the execution of their
         recipes, the target is not deleted. Also, the target is not deleted
         on error even if .DELETE_ON_ERROR is specified.
      
      .SECONDARY is a much better way to disable (b), but a small problem
      is that .SECONDARY enables (a), which gives a side-effect to $?;
      prerequisites marked as .SECONDARY do not appear in $?. This is a
      drawback for Kbuild.
      
      I thought it was a bug and opened a bug report. As Paul, the GNU Make
      maintainer, concluded in [2], this is not a bug.
      
      A good news is that, GNU Make 4.4 added the perfect solution,
      .NOTINTERMEDIATE, which cancels both (a) and (b).
      
      For clarificaton, my understanding of .INTERMEDIATE, .SECONDARY,
      .PRECIOUS and .NOTINTERMEDIATE are as follows:
      
                              (a)         (b)         (c)
        .INTERMEDIATE        enable      enable      disable
        .SECONDARY           enable      disable     disable
        .PRECIOUS            disable     disable     enable
        .NOTINTERMEDIATE     disable     disable     disable
      
      However, GNU Make 4.4 has a bug for the global .NOTINTERMEDIATE. [3]
      It was fixed by commit 6164608900ad ("[SV 63417] Ensure global
      .NOTINTERMEDIATE disables all intermediates"), and will be available
      in the next release of GNU Make.
      
      The following is the gain for .NOTINTERMEDIATE:
      
        [Current Make]
      
            $ make allnoconfig vmlinux
                [ full build ]
            $ rm include/linux/device.h
            $ make vmlinux
              CALL    scripts/checksyscalls.sh
      
        Make does not notice the removal of <linux/device.h>.
      
        [Future Make]
      
            $ make-latest allnoconfig vmlinux
                [ full build ]
            $ rm include/linux/device.h
            $ make-latest vmlinux
              CC      arch/x86/kernel/asm-offsets.s
            In file included from ./include/linux/writeback.h:13,
                             from ./include/linux/memcontrol.h:22,
                             from ./include/linux/swap.h:9,
                             from ./include/linux/suspend.h:5,
                             from arch/x86/kernel/asm-offsets.c:13:
            ./include/linux/blk_types.h:11:10: fatal error: linux/device.h: No such file or directory
               11 | #include <linux/device.h>
                  |          ^~~~~~~~~~~~~~~~
            compilation terminated.
            make-latest[1]: *** [scripts/Makefile.build:114: arch/x86/kernel/asm-offsets.s] Error 1
            make-latest: *** [Makefile:1282: prepare0] Error 2
      
        Make notices the removal of <linux/device.h>, and rebuilds objects
        that depended on <linux/device.h>. There exists a source file that
        includes <linux/device.h>, and it raises an error.
      
      To see detailed background information, refer to commit 2d3b1b8f
      ("kbuild: drop $(wildcard $^) check in if_changed* for faster rebuild").
      
      [1]: https://www.gnu.org/software/make/manual/make.html#Chained-Rules
      [2]: https://savannah.gnu.org/bugs/?55532
      [3]: https://savannah.gnu.org/bugs/?63417Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      875ef1a5
    • M
      kconfig: refactor Makefile to reduce process forks · 3122c844
      Masahiro Yamada 提交于
      Refactor Makefile and use read-file macro. For Make >= 4.2, it can read
      out a file by using the built-in function.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      3122c844
    • M
      kbuild: add read-file macro · 6768fa4b
      Masahiro Yamada 提交于
      Since GNU Make 4.2, $(file ...) supports the read operater '<', which
      is useful to read a file without forking a new process. No warning is
      shown even if the input file is missing.
      
      For older Make versions, it falls back to the cat command.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      Reviewed-by: NAlexander Lobakin <alexandr.lobakin@intel.com>
      Tested-by: NAlexander Lobakin <alexandr.lobakin@intel.com>
      6768fa4b
    • M
      kbuild: do not sort after reading modules.order · a5db80c6
      Masahiro Yamada 提交于
      modules.order lists modules in the deterministic order (that is why
      "modules order"), and there is no duplication in the list.
      
      $(sort ) is pointless.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      a5db80c6
    • M
      kbuild: add test-{ge,gt,le,lt} macros · fccb3d3e
      Masahiro Yamada 提交于
      GNU Make 4.4 introduced $(intcmp ...), which is useful to compare two
      integers without forking a new process.
      
      Add test-{ge,gt,le,lt} macros, which work more efficiently with GNU
      Make >= 4.4. For older Make versions, they fall back to the 'test'
      shell command.
      
      The first two parameters to $(intcmp ...) must not be empty. To avoid
      the syntax error, I appended '0' to them. Fortunately, '00' is treated
      as '0'. This is needed because CONFIG options may expand to an empty
      string when the kernel configuration is not included.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: Palmer Dabbelt <palmer@rivosinc.com> # RISC-V
      Reviewed-by: NNathan Chancellor <nathan@kernel.org>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      fccb3d3e
    • M
      Documentation: raise minimum supported version of binutils to 2.25 · e4412739
      Masahiro Yamada 提交于
      Binutils 2.23 was released in 2012. Almost 10 years old.
      
      We already require GCC 5.1, released in 2015.
      
      Bump the binutils version to 2.25, which was released some months
      before GCC 5.1.
      
      With this applied, some subsystems can start to clean up code.
      Examples:
        arch/arm/Kconfig.assembler
        arch/mips/vdso/Kconfig
        arch/powerpc/Makefile
        arch/x86/Kconfig.assembler
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Reviewed-by: NNick Desaulniers <ndesaulniers@google.com>
      e4412739
  3. 11 12月, 2022 2 次提交
  4. 10 12月, 2022 3 次提交
  5. 27 11月, 2022 1 次提交
  6. 23 11月, 2022 1 次提交
  7. 22 11月, 2022 2 次提交
    • M
      kbuild: warn objects shared among multiple modules · 598afa05
      Masahiro Yamada 提交于
      If an object is shared among multiple modules, and some of them are
      configured as 'm', but the others as 'y', the shared object is built
      as modular, then linked to the modules and vmlinux. This is a potential
      issue because the expected CFLAGS are different between modules and
      builtins.
      
      Commit 637a642f ("zstd: Fixing mixed module-builtin objects")
      reported that this could be even more fatal in some cases such as
      Clang LTO.
      
      That commit fixed lib/zlib/zstd_{compress,decompress}, but there are
      still more instances of breakage.
      
      This commit adds a W=1 warning for shared objects, so that the kbuild
      test robot, which provides build tests with W=1, will avoid a new
      breakage slipping in.
      
      Quick compile tests on v6.1-rc4 detected the following:
      
      scripts/Makefile.build:252: ./drivers/block/rnbd/Makefile: rnbd-common.o is added to multiple modules: rnbd-client rnbd-server
      scripts/Makefile.build:252: ./drivers/crypto/marvell/octeontx2/Makefile: cn10k_cpt.o is added to multiple modules: rvu_cptpf rvu_cptvf
      scripts/Makefile.build:252: ./drivers/crypto/marvell/octeontx2/Makefile: otx2_cptlf.o is added to multiple modules: rvu_cptpf rvu_cptvf
      scripts/Makefile.build:252: ./drivers/crypto/marvell/octeontx2/Makefile: otx2_cpt_mbox_common.o is added to multiple modules: rvu_cptpf rvu_cptvf
      scripts/Makefile.build:252: ./drivers/edac/Makefile: skx_common.o is added to multiple modules: i10nm_edac skx_edac
      scripts/Makefile.build:252: ./drivers/gpu/drm/bridge/imx/Makefile: imx-ldb-helper.o is added to multiple modules: imx8qm-ldb imx8qxp-ldb
      scripts/Makefile.build:252: ./drivers/mfd/Makefile: rsmu_core.o is added to multiple modules: rsmu-i2c rsmu-spi
      scripts/Makefile.build:252: ./drivers/mtd/tests/Makefile: mtd_test.o is added to multiple modules: mtd_nandbiterrs mtd_oobtest mtd_pagetest mtd_readtest mtd_speedtest mtd_stresstest mtd_subpagetest mtd_torturetest
      scripts/Makefile.build:252: ./drivers/net/dsa/ocelot/Makefile: felix.o is added to multiple modules: mscc_felix mscc_seville
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: cn23xx_pf_device.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: cn23xx_vf_device.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: cn66xx_device.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: cn68xx_device.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: lio_core.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: lio_ethtool.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: octeon_device.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: octeon_droq.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: octeon_mailbox.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: octeon_mem_ops.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: octeon_nic.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: request_manager.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/cavium/liquidio/Makefile: response_manager.o is added to multiple modules: liquidio liquidio_vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/freescale/dpaa2/Makefile: dpaa2-mac.o is added to multiple modules: fsl-dpaa2-eth fsl-dpaa2-switch
      scripts/Makefile.build:252: ./drivers/net/ethernet/freescale/dpaa2/Makefile: dpmac.o is added to multiple modules: fsl-dpaa2-eth fsl-dpaa2-switch
      scripts/Makefile.build:252: ./drivers/net/ethernet/freescale/enetc/Makefile: enetc_cbdr.o is added to multiple modules: fsl-enetc fsl-enetc-vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/freescale/enetc/Makefile: enetc_ethtool.o is added to multiple modules: fsl-enetc fsl-enetc-vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/freescale/enetc/Makefile: enetc.o is added to multiple modules: fsl-enetc fsl-enetc-vf
      scripts/Makefile.build:252: ./drivers/net/ethernet/hisilicon/hns3/Makefile: hns3_common/hclge_comm_cmd.o is added to multiple modules: hclge hclgevf
      scripts/Makefile.build:252: ./drivers/net/ethernet/hisilicon/hns3/Makefile: hns3_common/hclge_comm_rss.o is added to multiple modules: hclge hclgevf
      scripts/Makefile.build:252: ./drivers/net/ethernet/hisilicon/hns3/Makefile: hns3_common/hclge_comm_tqp_stats.o is added to multiple modules: hclge hclgevf
      scripts/Makefile.build:252: ./drivers/net/ethernet/marvell/octeontx2/nic/Makefile: otx2_dcbnl.o is added to multiple modules: rvu_nicpf rvu_nicvf
      scripts/Makefile.build:252: ./drivers/net/ethernet/marvell/octeontx2/nic/Makefile: otx2_devlink.o is added to multiple modules: rvu_nicpf rvu_nicvf
      scripts/Makefile.build:252: ./drivers/net/ethernet/ti/Makefile: cpsw_ale.o is added to multiple modules: keystone_netcp keystone_netcp_ethss ti_cpsw ti_cpsw_new
      scripts/Makefile.build:252: ./drivers/net/ethernet/ti/Makefile: cpsw_ethtool.o is added to multiple modules: ti_cpsw ti_cpsw_new
      scripts/Makefile.build:252: ./drivers/net/ethernet/ti/Makefile: cpsw_priv.o is added to multiple modules: ti_cpsw ti_cpsw_new
      scripts/Makefile.build:252: ./drivers/net/ethernet/ti/Makefile: cpsw_sl.o is added to multiple modules: ti_cpsw ti_cpsw_new
      scripts/Makefile.build:252: ./drivers/net/ethernet/ti/Makefile: davinci_cpdma.o is added to multiple modules: ti_cpsw ti_cpsw_new ti_davinci_emac
      scripts/Makefile.build:252: ./drivers/platform/x86/intel/int3472/Makefile: common.o is added to multiple modules: intel_skl_int3472_discrete intel_skl_int3472_tps68470
      scripts/Makefile.build:252: ./sound/soc/codecs/Makefile: wcd-clsh-v2.o is added to multiple modules: snd-soc-wcd9335 snd-soc-wcd934x snd-soc-wcd938x
      
      Once all the warnings are fixed, it can become an error without the
      W= option.
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NAlexander Lobakin <alobakin@pm.me>
      Tested-by: NAlexander Lobakin <alobakin@pm.me>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      598afa05
    • M
      kbuild: add kbuild-file macro · a2430b25
      Masahiro Yamada 提交于
      While building, installing, cleaning, Kbuild visits sub-directories
      and includes 'Kbuild' or 'Makefile' that exists there.
      
      Add 'kbuild-file' macro, and reuse it from scripts/Makefie.*
      Signed-off-by: NMasahiro Yamada <masahiroy@kernel.org>
      Reviewed-by: NNicolas Schier <nicolas@fjasle.eu>
      Reviewed-by: NAlexander Lobakin <alobakin@pm.me>
      Tested-by: NAlexander Lobakin <alobakin@pm.me>
      a2430b25
  8. 21 11月, 2022 17 次提交
  9. 20 11月, 2022 3 次提交