Skip to content
  • Masahiro Yamada's avatar
    kbuild: turn auto.conf.cmd into a mandatory include file · d2f8ae0e
    Masahiro Yamada authored
    syncconfig is responsible for keeping auto.conf up-to-date, so if it
    fails for any reason, the build must be terminated immediately.
    
    However, since commit 9390dff6 ("kbuild: invoke syncconfig if
    include/config/auto.conf.cmd is missing"), Kbuild continues running
    even after syncconfig fails.
    
    You can confirm this by intentionally making syncconfig error out:
    
      diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
      index 08ba146..307b9de 100644
      --- a/scripts/kconfig/confdata.c
      +++ b/scripts/kconfig/confdata.c
      @@ -1023,6 +1023,9 @@ int conf_write_autoconf(int overwrite)
              FILE *out, *tristate, *out_h;
              int i;
    
      +       if (overwrite)
      +               return 1;
      +
              if (!overwrite && is_present(autoconf_name))
                      return 0;
    
    Then, syncconfig fails, but Make would not stop:
    
      $ make -s mrproper allyesconfig defconfig
      $ make
      scripts/kconfig/conf  --syncconfig Kconfig
    
      *** Error during sync of the configuration.
    
      make[2]: *** [scripts/kconfig/Makefile;69: syncconfig] Error 1
      make[1]: *** [Makefile;557: syncconfig] Error 2
      make: *** [include/config/auto.conf.cmd] Deleting file 'include/config/tristate.conf'
      make: Failed to remake makefile 'include/config/auto.conf'.
        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
      [ continue running ... ]
    
    The reason is in the behavior of a pattern rule with multi-targets.
    
      %/auto.conf %/auto.conf.cmd %/tristate.conf: $(KCONFIG_CONFIG)
              $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
    
    GNU Make knows this rule is responsible for making all the three files
    simultaneously. As far as examined, auto.conf.cmd is the target in
    question when this rule is invoked. It is probably because auto.conf.cmd
    is included below the inclusion of auto.conf.
    
    The inclusion of auto.conf is mandatory, while that of auto.conf.cmd
    is optional. GNU Make does not care about the failure in the process
    of updating optional include files.
    
    I filed this issue (https://savannah.gnu.org/bugs/?56301) in case this
    behavior could be improved somehow in future releases of GNU Make.
    Anyway, it is quite easy to fix our Makefile.
    
    Given that auto.conf is already a mandatory include file, there is no
    reason to stick auto.conf.cmd optional. Make it mandatory as well.
    
    Cc: linux-stable <stable@vger.kernel.org> # 5.0+
    Fixes: 9390dff6
    
     ("kbuild: invoke syncconfig if include/config/auto.conf.cmd is missing")
    Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
    d2f8ae0e