1. 25 Jul, 2018 12 commits
    • Masahiro Yamada's avatar
      kbuild: do not update config for 'make kernelrelease' · a29d4d8c
      Masahiro Yamada authored
      'make kernelrelease' depends on CONFIG_LOCALVERSION(_AUTO), but
      for the same reason as install targets, we do not want to update
      the configuration just for printing the kernelrelease string.
      
      This is likely to happen when you compiled the kernel with
      CROSS_COMPILE, but forget to pass it to 'make kernelrelease'.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a29d4d8c
    • Masahiro Yamada's avatar
      kbuild: do not update config when running install targets · d7942413
      Masahiro Yamada authored
      "make syncconfig" is automatically invoked when any of the following
      happens:
      
       - .config is updated
       - any of Kconfig files is updated
       - any of environment variables referenced in Kconfig is changed
      
      Then, it updates configuration files such as include/config/auto.conf
      include/generated/autoconf.h, etc.
      
      Even install targets (install, modules_install, etc.) are no exception.
      However, they should never ever modify the source tree.  Install
      targets are often run with root privileges.  Once those configuration
      files are owned by root, "make mrproper" would end up with permission
      error.
      
      Install targets should just copy things blindly.  They should not care
      whether the configuration is up-to-date or not.  This makes more sense
      because we are interested in the configuration that was used in the
      previous kernel building.
      
      This issue has existed since before, but rarely happened.  I expect
      more chance where people are hit by this; with the new Kconfig syntax
      extension, the .config now contains the compiler information.  If you
      cross-compile the kernel with CROSS_COMPILE, but forget to pass it
      for "make install", you meet "any of environment variables referenced
      in Kconfig is changed" because $(CC) is referenced in Kconfig.
      Another scenario is the compiler upgrade before the installation.
      
      Install targets need the configuration.  "make modules_install" refer
      to CONFIG_MODULES etc.  "make dtbs_install" also needs CONFIG_ARCH_*
      to decide which dtb files to install.  However, the auto-update of
      the configuration files should be avoided.  We already do this for
      external modules.
      
      Now, Make targets are categorized into 3 groups:
      
      [1] Do not need the kernel configuration at all
      
          help, coccicheck, headers_install etc.
      
      [2] Need the latest kernel configuration
      
          If new config options are added, Kconfig will show prompt to
          ask user's selection.
      
          Build targets such as vmlinux, in-kernel modules are the cases.
      
      [3] Need the kernel configuration, but do not want to update it
      
          Install targets except headers_install, and external modules
          are the cases.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d7942413
    • Masahiro Yamada's avatar
      kbuild: add .DELETE_ON_ERROR special target · 9c2af1c7
      Masahiro Yamada authored
      If Make gets a fatal signal while a shell is executing, it may delete
      the target file that the recipe was supposed to update.  This is needed
      to make sure that it is remade from scratch when Make is next run; if
      Make is interrupted after the recipe has begun to write the target file,
      it results in an incomplete file whose time stamp is newer than that
      of the prerequisites files.  Make automatically deletes the incomplete
      file on interrupt unless the target is marked .PRECIOUS.
      
      The situation is just the same as when the shell fails for some reasons.
      Usually when a recipe line fails, if it has changed the target file at
      all, the file is corrupted, or at least it is not completely updated.
      Yet the file’s time stamp says that it is now up to date, so the next
      time Make runs, it will not try to update that file.
      
      However, Make does not cater to delete the incomplete target file in
      this case.  We need to add .DELETE_ON_ERROR somewhere in the Makefile
      to request it.
      
      scripts/Kbuild.include seems a suitable place to add it because it is
      included from almost all sub-makes.
      
      Please note .DELETE_ON_ERROR is not effective for phony targets.
      
      The external module building should never ever touch the kernel tree.
      The following recipe fails if include/generated/autoconf.h is missing.
      However, include/config/auto.conf is not deleted since it is a phony
      target.
      
       PHONY += include/config/auto.conf
      
       include/config/auto.conf:
               $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
               echo >&2;                                                       \
               echo >&2 "  ERROR: Kernel configuration is invalid.";           \
               echo >&2 "         include/generated/autoconf.h or $@ are missing.";\
               echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it."; \
               echo >&2 ;                                                      \
               /bin/false)
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9c2af1c7
    • Masahiro Yamada's avatar
      kbuild: use 'include' directive to load auto.conf from top Makefile · 0a16d2e8
      Masahiro Yamada authored
      When you build targets that require the kernel configuration, dot-config
      is set to 1, then the top-level Makefile includes auto.conf.  However,
      Make considers its inclusion is optional because the '-include' directive
      is used here.
      
      If a necessary configuration file is missing for the external module
      building, the following error message is displayed:
      
        ERROR: Kernel configuration is invalid.
               include/generated/autoconf.h or include/config/auto.conf are missing.
               Run 'make oldconfig && make prepare' on kernel src to fix it.
      
      However, Make still continues building; /bin/false let the creation of
      'include/config/auto.config' fail, but Make can ignore the error since
      it is included by the '-include' directive.
      
      I guess the reason of using '-include' directive was to suppress
      the warning when you build the kernel from a pristine source tree:
      
        Makefile:605: include/config/auto.conf: No such file or directory
      
      The previous commit made sure include/config/auto.conf exists after
      the 'make *config' stage.  Now, we can use the 'include' directive
      without showing the warning.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0a16d2e8
    • Masahiro Yamada's avatar
      kconfig: allow all config targets to write auto.conf if missing · 00c864f8
      Masahiro Yamada authored
      Currently, only syncconfig creates or updates include/config/auto.conf
      and some other files.  Other config targets create or update only the
      .config file.
      
      When you configure and build the kernel from a pristine source tree,
      any config target is followed by syncconfig in the build stage since
      include/config/auto.conf is missing.
      
      We are moving compiler tests from Makefile to Kconfig.  It means that
      parsing Kconfig files will be more costly since Kconfig invokes the
      compiler commands internally.  Thus, we want to avoid invoking Kconfig
      twice (one for *config to create the .config, and one for syncconfig
      to synchronize the auto.conf).  If auto.conf does not exist, we can
      generate all configuration files in the first configuration stage,
      which will save the syncconfig in the build stage.
      
      Please note this should be done only when auto.conf is missing.  If
      *config blindly did this, time stamp files under include/config/ would
      be unnecessarily touched, triggering unneeded rebuild of objects.
      
      I assume a scenario like this:
      
       1. You have a source tree that has already been built
          with CONFIG_FOO disabled
      
       2. Run "make menuconfig" to enable CONFIG_FOO
      
       3. CONFIG_FOO turns out to be unnecessary.
          Run "make menuconfig" again to disable CONFIG_FOO
      
       4. Run "make"
      
      In this case, include/config/foo.h should not be touched since there
      is no change in CONFIG_FOO.  The sync process should be delayed until
      the user really attempts to build the kernel.
      
      This commit has another motivation; I want to suppress the 'No such
      file or directory' warning from the 'include' directive.
      
      The top-level Makefile includes auto.conf with '-include' directive,
      like this:
      
        ifeq ($(dot-config),1)
        -include include/config/auto.conf
        endif
      
      This looks strange because auto.conf is mandatory when dot-config is 1.
      I guess only the reason of using '-include' is to suppress the warning
      'include/config/auto.conf: No such file or directory' when building
      from a clean tree.  However, this has a side-effect; Make considers
      the files included by '-include' are optional.  Hence, Make continues
      to build even if it fails to generate include/config/auto.conf.  I will
      change this in the next commit, but the warning message is annoying.
      (At least, kbuild test robot reports it as a regression.)
      
      With this commit, Kconfig will generate all configuration files together
      with the .config and I guess it is a solution good enough to suppress
      the warning.
      
      Note:
      GNU Make 4.2 or later does not display the warning from the 'include'
      directive if include files are successfully generated.  See GNU Make
      commit 87a5f98d248f ("[SV 102] Don't show unnecessary include file
      errors.")  However, older GNU Make versions are still widely used.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      00c864f8
    • Masahiro Yamada's avatar
      kconfig: make syncconfig update .config regardless of sym_change_count · 16952b77
      Masahiro Yamada authored
      syncconfig updates the .config only when sym_change_count > 0, i.e.
      any change in config symbols has been detected.
      
      Not only symbols but also comments are contained in the .config file.
      If only comments are updated, they are not fed back to the .config,
      then the stale comments are left-over.  Of course, this is just a
      matter of comments, but why not fix it.
      
      I see some scenarios where this happens.
      
      Scenario A:
      
       1. You have a source tree that has already been configured.
      
       2. Linus increments the version number in the top-level Makefile
          (i.e. he commits a new release)
      
       3. You pull it, and run 'make'
      
       4. syncconfig is invoked because the environment variable,
          KERNELVERSION is updated, but the .config is not updated since
          no config symbol is changed.
      
       5. The .config file contains a kernel version in the top line:
      
          # Automatically generated file; DO NOT EDIT.
          # Linux/arm64 4.18.0-rc2 Kernel Configuration
      
          ... which points to a previous version.
      
      Scenario B:
      
       1. You have a source tree that has already been configured.
      
       2. You upgrade the compiler, but it still has the same version number.
          This may happen if you regularly build the latest compiler from
          the source code.
      
       3. You run 'make'
      
       4. syncconfig is invoked because the environment variable,
          CC_VERSION_TEXT is updated, but the .config is not updated since
          no config symbol is changed.
      
       5. The .config file contains the version string of the compiler:
      
          #
          # Compiler: aarch64-linux-gcc (GCC) 9.0.0 20180628 (experimental)
          #
      
          ... which carries the information of the old compiler.
      
      If KCONFIG_NOSILENTUPDATE is set, syncconfig is not allowed to update
      the .config file.  Otherwise, it is fine to update it regardless of
      sym_change_count.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      16952b77
    • Masahiro Yamada's avatar
      kconfig: create directories needed for syncconfig by itself · 79123b13
      Masahiro Yamada authored
      'make syncconfig' creates some files such as include/config/auto.conf,
      include/generate/autoconf.h, etc. but the necessary directory creation
      relies on scripts/kconfig/Makefile.
      
      To make Kconfig self-contained, create directories as needed in
      conf_write_autoconf().
      
      This change allows scripts/kconfig/Makefile cleanups; syncconfig can
      be merged into simple-targets.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      79123b13
    • Masahiro Yamada's avatar
      kconfig: remove unneeded directory generation from local*config · adc18acf
      Masahiro Yamada authored
      Commit 17263baf ("kconfig: Create include/generated for
      localmodconfig") added the 'mkdir' line because local{yes,mod}config
      ran streamline_config.pl followed by silentoldconfig at that time.
      
      Since commit 81d2bc22 ("kconfig: invoke oldconfig instead of
      silentoldconfig from local*config"), no sub-directory is required.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      adc18acf
    • Masahiro Yamada's avatar
      kconfig: split out useful helpers in confdata.c · 0608182a
      Masahiro Yamada authored
      Split out helpers:
       is_present() - check if the given path exists
       is_dir() - check if the given path exists and it is a directory
       make_parent_dir() - create the parent directories of the given path
      
      These helpers will be reused in later commits.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0608182a
    • Masahiro Yamada's avatar
      kconfig: rename file_write_dep and move it to confdata.c · a2ff4040
      Masahiro Yamada authored
      file_write_dep() is called only from conf_write_autoconf().
      Move it from util.c to confdata.c to make it static.
      Also, rename it to conf_write_dep() since it should belong to
      the group of conf_write* functions.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a2ff4040
    • Randy Dunlap's avatar
      kconfig: fix typos in description of "choice" in kconfig-language.txt · 08b220b3
      Randy Dunlap authored
      Fix a couple of punctuation "typos" in the description of the
      "choice" keyword.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      08b220b3
    • Masahiro Yamada's avatar
      kconfig: handle format string before calling conf_message_callback() · 5accd7f3
      Masahiro Yamada authored
      As you see in mconf.c and nconf.c, conf_message_callback() hooks are
      likely to end up with the boilerplate of vsnprintf().  Process the
      string format before calling conf_message_callback() so that it
      receives a simple string.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: default avatarDirk Gouders <dirk@gouders.net>
      5accd7f3
  2. 17 Jul, 2018 2 commits
  3. 15 Jul, 2018 2 commits
  4. 14 Jul, 2018 19 commits
  5. 13 Jul, 2018 5 commits