1. 29 Aug, 2019 9 commits
  2. 28 Aug, 2019 3 commits
    • Masahiro Yamada's avatar
      init/Kconfig: rework help of CONFIG_CC_OPTIMIZE_FOR_SIZE · ce3b487f
      Masahiro Yamada authored
      CONFIG_CC_OPTIMIZE_FOR_SIZE was originally an independent boolean
      option, but commit 877417e6 ("Kbuild: change CC_OPTIMIZE_FOR_SIZE
      definition") turned it into a choice between _PERFORMANCE and _SIZE.
      
      The phrase "If unsure, say N." sounds like an independent option.
      Reword the help text to make it appropriate for the choice menu.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      ce3b487f
    • Masahiro Yamada's avatar
      docs: kbuild: remove cc-ldoption from document again · d20558d1
      Masahiro Yamada authored
      Commit 055efab3 ("kbuild: drop support for cc-ldoption") correctly
      removed the cc-ldoption from Documentation/kbuild/makefiles.txt, but
      commit cd238eff ("docs: kbuild: convert docs to ReST and rename
      to *.rst") revived it. I guess it was a rebase mistake.
      
      Remove it again.
      
      Fixes: cd238eff ("docs: kbuild: convert docs to ReST and rename to *.rst")
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      d20558d1
    • Masahiro Yamada's avatar
      docs: kbuild: fix invalid ReST syntax · 4fef9dec
      Masahiro Yamada authored
      I see the following warnings when I open this document with a ReST
      viewer, retext:
      
      /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1142: (WARNING/2) Inline emphasis start-string without end-string.
      /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1152: (WARNING/2) Inline emphasis start-string without end-string.
      /home/masahiro/ref/linux/Documentation/kbuild/makefiles.rst:1154: (WARNING/2) Inline emphasis start-string without end-string.
      
      These hunks were added by commit e846f0dc ("kbuild: add support
      for ensuring headers are self-contained") and commit 1e21cbfa
      ("kbuild: support header-test-pattern-y"), respectively. They were
      written not for ReST but for the plain text, and merged via the
      kbuild tree.
      
      In the same development cycle, this document was converted to ReST
      by commit cd238eff ("docs: kbuild: convert docs to ReST and rename
      to *.rst"), and merged via the doc sub-system.
      
      Merging them together into Linus' tree resulted in the current situation.
      
      To fix the syntax, surround the asterisks with back-quotes, and
      use :: for the code sample.
      
      Fixes: 39ceda5c ("Merge tag 'kbuild-v5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild")
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      4fef9dec
  3. 25 Aug, 2019 1 commit
  4. 24 Aug, 2019 3 commits
  5. 21 Aug, 2019 15 commits
    • Mark Brown's avatar
      merge_config.sh: Check error codes from make · cdfca821
      Mark Brown authored
      When we execute make after merging the configurations we ignore any
      errors it produces causing whatever is running merge_config.sh to be
      unaware of any failures.  This issue was noticed by Guillaume Tucker
      while looking at problems with testing of clang only builds in KernelCI
      which caused Kbuild to be unable to find a working host compiler.
      
      This implementation was suggested by Yamada-san.
      Suggested-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Reported-by: default avatarGuillaume Tucker <guillaume.tucker@collabora.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      cdfca821
    • Masahiro Yamada's avatar
      kbuild: move modkern_{c,a}flags to Makefile.lib from Makefile.build · eb27ea5c
      Masahiro Yamada authored
      Makefile.lib is included by Makefile.modfinal as well as Makefile.build.
      
      Move modkern_cflags to Makefile.lib in order to simplify cmd_cc_o_c
      in Makefile.modfinal. Move modkern_cflags as well for consistency.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      eb27ea5c
    • Masahiro Yamada's avatar
      kbuild: add CONFIG_ASM_MODVERSIONS · 2ff2b7ec
      Masahiro Yamada authored
      Add CONFIG_ASM_MODVERSIONS. This allows to remove one if-conditional
      nesting in scripts/Makefile.build.
      
      scripts/Makefile.build is run every time Kbuild descends into a
      sub-directory. So, I want to avoid $(wildcard ...) evaluation
      where possible although computing $(wildcard ...) is so cheap that
      it may not make measurable performance difference.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      2ff2b7ec
    • Masahiro Yamada's avatar
      .gitignore: ignore modules.order explicitly · a564bdeb
      Masahiro Yamada authored
      The pattern '*.order' was added by commit c6025f4c ("kbuild: ignore
      *.order files") to ignore modules.order files.
      
      I do not see any other user of the '.order' extension.
      
      Ignore 'modules.order' explicitly instead of '*.order'.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      a564bdeb
    • Masahiro Yamada's avatar
      kbuild: split final module linking out into Makefile.modfinal · 9b9a3f20
      Masahiro Yamada authored
      I think splitting the modpost and linking modules into separate
      Makefiles will be useful especially when more complex build steps
      come in. The main motivation of this commit is to integrate the
      proposed klp-convert feature cleanly.
      
      I moved the logging 'Building modules, stage 2.' to Makefile.modpost
      to avoid the code duplication although I do not know whether or not
      this message is needed in the first place.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      9b9a3f20
    • Masahiro Yamada's avatar
      kbuild: rebuild modules when module linker scripts are updated · 10df0638
      Masahiro Yamada authored
      Currently, the timestamp of module linker scripts are not checked.
      Add them to the dependency of modules so they are correctly rebuilt.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      10df0638
    • Masahiro Yamada's avatar
      kbuild: move KBUILD_LDS, KBUILD_VMLINUX_{OBJS,LIBS} to makefiles.rst · 888f0c34
      Masahiro Yamada authored
      These three variables are not intended to be tweaked by users.
      Move them from kbuild.rst to makefiles.rst.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      888f0c34
    • Masahiro Yamada's avatar
      treewide: remove dummy Makefiles for single targets · cbdf59ad
      Masahiro Yamada authored
      Now that the single target build descends into sub-directories in the
      same way as the normal build, these dummy Makefiles are not needed
      any more.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      cbdf59ad
    • Masahiro Yamada's avatar
      kbuild: make single targets work more correctly · 394053f4
      Masahiro Yamada authored
      Currently, the single target build directly descends into the directory
      of the target. For example,
      
        $ make foo/bar/baz.o
      
      ... directly descends into foo/bar/.
      
      On the other hand, the normal build usually descends one directory at
      a time, i.e. descends into foo/, and then foo/bar/.
      
      This difference causes some problems.
      
      [1] miss subdir-asflags-y, subdir-ccflags-y in upper Makefiles
      
          The options in subdir-{as,cc}flags-y take effect in the current
          and its sub-directories. In other words, they are inherited
          downward. In the example above, the single target will miss
          subdir-{as,cc}flags-y if they are defined in foo/Makefile.
      
      [2] could be built in a different directory
      
          As Documentation/kbuild/modules.rst section 4.3 says, Kbuild can
          handle files that are spread over several sub-directories.
      
          The build rule of foo/bar/baz.o may not necessarily be specified in
          foo/bar/Makefile. It might be specifies in foo/Makefile as follows:
      
          [foo/Makefile]
          obj-y := bar/baz.o
      
          This often happens when a module is so big that its source files
          are divided into sub-directories.
      
          In this case, there is no Makefile in the foo/bar/ directory, yet
          the single target descends into foo/bar/, then fails due to the
          missing Makefile. You can still do 'make foo/bar/' for partial
          building, but cannot do 'make foo/bar/baz.s'. I believe the single
          target '%.s' is a useful feature for inspecting the compiler output.
      
          Some modules work around this issue by putting an empty Makefile
          in every sub-directory.
      
      This commit fixes those problems by making the single target build
      descend in the same way as the normal build does.
      
      Another change is the single target build will observe the CONFIG
      options. Previously, it allowed users to build the foo.o even when
      the corresponding CONFIG_FOO is disabled:
      
         obj-$(CONFIG_FOO) += foo.o
      
      In the new behavior, the single target build will just fail and show
      "No rule to make target ..." (or "Nothing to be done for ..." if the
      stale object already exists, but cannot be updated).
      
      The disadvantage of this commit is the build speed. Now that the
      single target build visits every directory and parses lots of
      Makefiles, it is slower than before. (But, I hope it will not be
      too slow.)
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      394053f4
    • Kees Cook's avatar
      kbuild: Parameterize kallsyms generation and correct reporting · 8959e392
      Kees Cook authored
      When kallsyms generation happens, temporary vmlinux outputs are linked
      but the quiet make output didn't report it, giving the impression that
      the prior command is taking longer than expected.
      
      Instead, report the linking step explicitly. While at it, this
      consolidates the repeated "kallsyms generation step" into a single
      function and removes the existing copy/pasting.
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      8959e392
    • Masahiro Yamada's avatar
      kbuild: re-implement detection of CONFIG options leaked to user-space · c7c0eecf
      Masahiro Yamada authored
      scripts/headers_check.pl can detect references to CONFIG options in
      exported headers, but it has been disabled for more than a decade.
      
      Reverting commit 7e3fa561 ("kbuild: drop check for CONFIG_ in
      headers_check") would emit the following warnings for headers_check
      on x86:
      
      usr/include/mtd/ubi-user.h:283: leaks CONFIG_MTD_UBI_BEB_LIMIT to userspace where it is not valid
      usr/include/linux/cm4000_cs.h:26: leaks CONFIG_COMPAT to userspace where it is not valid
      usr/include/linux/pkt_cls.h:301: leaks CONFIG_NET_CLS_ACT to userspace where it is not valid
      usr/include/linux/videodev2.h:2465: leaks CONFIG_VIDEO_ADV_DEBUG to userspace where it is not valid
      usr/include/linux/bpf.h:249: leaks CONFIG_EFFICIENT_UNALIGNED_ACCESS to userspace where it is not valid
      usr/include/linux/bpf.h:819: leaks CONFIG_CGROUP_NET_CLASSID to userspace where it is not valid
      usr/include/linux/bpf.h:1011: leaks CONFIG_IP_ROUTE_CLASSID to userspace where it is not valid
      usr/include/linux/bpf.h:1742: leaks CONFIG_BPF_KPROBE_OVERRIDE to userspace where it is not valid
      usr/include/linux/bpf.h:1747: leaks CONFIG_FUNCTION_ERROR_INJECTION to userspace where it is not valid
      usr/include/linux/bpf.h:1936: leaks CONFIG_XFRM to userspace where it is not valid
      usr/include/linux/bpf.h:2184: leaks CONFIG_BPF_LIRC_MODE2 to userspace where it is not valid
      usr/include/linux/bpf.h:2210: leaks CONFIG_BPF_LIRC_MODE2 to userspace where it is not valid
      usr/include/linux/bpf.h:2227: leaks CONFIG_SOCK_CGROUP_DATA to userspace where it is not valid
      usr/include/linux/bpf.h:2311: leaks CONFIG_NET to userspace where it is not valid
      usr/include/linux/bpf.h:2348: leaks CONFIG_NET to userspace where it is not valid
      usr/include/linux/bpf.h:2422: leaks CONFIG_BPF_LIRC_MODE2 to userspace where it is not valid
      usr/include/linux/bpf.h:2528: leaks CONFIG_NET to userspace where it is not valid
      usr/include/linux/pktcdvd.h:37: leaks CONFIG_CDROM_PKTCDVD_WCACHE to userspace where it is not valid
      usr/include/linux/hw_breakpoint.h:27: leaks CONFIG_HAVE_MIXED_BREAKPOINTS_REGS to userspace where it is not valid
      usr/include/linux/raw.h:17: leaks CONFIG_MAX_RAW_DEVS to userspace where it is not valid
      usr/include/linux/elfcore.h:62: leaks CONFIG_BINFMT_ELF_FDPIC to userspace where it is not valid
      usr/include/linux/eventpoll.h:82: leaks CONFIG_PM_SLEEP to userspace where it is not valid
      usr/include/linux/atmdev.h:104: leaks CONFIG_COMPAT to userspace where it is not valid
      usr/include/asm-generic/unistd.h:651: leaks CONFIG_MMU to userspace where it is not valid
      usr/include/asm-generic/bitsperlong.h:9: leaks CONFIG_64BIT to userspace where it is not valid
      usr/include/asm-generic/fcntl.h:119: leaks CONFIG_64BIT to userspace where it is not valid
      usr/include/asm/auxvec.h:14: leaks CONFIG_IA32_EMULATION to userspace where it is not valid
      usr/include/asm/e820.h:14: leaks CONFIG_NODES_SHIFT to userspace where it is not valid
      usr/include/asm/e820.h:39: leaks CONFIG_X86_PMEM_LEGACY to userspace where it is not valid
      usr/include/asm/e820.h:49: leaks CONFIG_INTEL_TXT to userspace where it is not valid
      usr/include/asm/mman.h:7: leaks CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS to userspace where it is not valid
      
      Most of these are false positives because scripts/headers_check.pl
      parses comment lines.
      
      It is also false negative. arch/x86/include/uapi/asm/auxvec.h contains
      CONFIG_IA32_EMULATION and CONFIG_X86_64, but the only former is reported.
      
      It would be possible to fix scripts/headers_check.pl, of course.
      However, we already have some duplicated checks between headers_check
      and CONFIG_UAPI_HEADER_TEST. At this moment of time, there are still
      dozens of headers excluded from the header test (usr/include/Makefile),
      but we might be able to remove headers_check eventually.
      
      I re-implemented it in scripts/headers_install.sh by using sed because
      the most of code in scripts/headers_install.sh is written in sed.
      
      This patch works like this:
      
      [1] Run scripts/unifdef first because we need to drop the code
          surrounded by #ifdef __KERNEL__ ... #endif
      
      [2] Remove all C style comments. The sed code is somewhat complicated
          since we need to deal with both single and multi line comments.
      
          Precisely speaking, a comment block is replaced with a space just
          in case.
      
            CONFIG_FOO/* this is a comment */CONFIG_BAR
      
          should be converted into:
      
            CONFIG_FOO CONFIG_BAR
      
          instead of:
      
            CONFIG_FOOCONFIG_BAR
      
      [3] Match CONFIG_... pattern. It correctly matches to all CONFIG
          options that appear in a single line.
      
      After this commit, this would detect the following warnings, all of
      which are real ones.
      
      warning: include/uapi/linux/pktcdvd.h: leak CONFIG_CDROM_PKTCDVD_WCACHE to user-space
      warning: include/uapi/linux/hw_breakpoint.h: leak CONFIG_HAVE_MIXED_BREAKPOINTS_REGS to user-space
      warning: include/uapi/linux/raw.h: leak CONFIG_MAX_RAW_DEVS to user-space
      warning: include/uapi/linux/elfcore.h: leak CONFIG_BINFMT_ELF_FDPIC to user-space
      warning: include/uapi/linux/eventpoll.h: leak CONFIG_PM_SLEEP to user-space
      warning: include/uapi/linux/atmdev.h: leak CONFIG_COMPAT to user-space
      warning: include/uapi/asm-generic/fcntl.h: leak CONFIG_64BIT to user-space
      warning: arch/x86/include/uapi/asm/auxvec.h: leak CONFIG_IA32_EMULATION to user-space
      warning: arch/x86/include/uapi/asm/auxvec.h: leak CONFIG_X86_64 to user-space
      warning: arch/x86/include/uapi/asm/mman.h: leak CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS to user-space
      
      However, it is not nice to show them right now. I created a list of
      existing leakages. They are not warned, but a new leakage will be
      blocked by the 0-day bot.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: default avatarSam Ravnborg <sam@ravnborg.org>
      c7c0eecf
    • Masahiro Yamada's avatar
      kbuild: unify clean-dirs rule for in-kernel and external module · 76cd306d
      Masahiro Yamada authored
      Factor out the duplicated code for in-kernel and external module
      cleaning.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      76cd306d
    • Masahiro Yamada's avatar
      kbuild: unify vmlinux-dirs and module-dirs rules · c99f3918
      Masahiro Yamada authored
      The in-kernel build and external module build have similar code
      for descending into sub-directories.
      
      Factor out the code into the common place.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      c99f3918
    • Masahiro Yamada's avatar
      kbuild: unset variables in top Makefile instead of setting 0 · 2042b548
      Masahiro Yamada authored
      There is no need to set 0 to variables such as config-targets,
      mixed-targets, etc.
      
      Unset instead of setting 0 in order to use 'ifdef' to test them.
      
      I also renamed:
      
        config-targets  ->  config-build
        mixed-targets   ->  mixed-build
        dot-config      ->  need-config
      
      to clarify what we are doing.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      2042b548
    • Masahiro Yamada's avatar
      kbuild: do not descend to ./Kbuild when cleaning · 125d059b
      Masahiro Yamada authored
      'make clean' descends into ./Kbuild, but does not clean anything
      since everything is added to no-clean-files.
      
      There is no need to descend to ./Kbuild in the first place.
      We can drop the no-clean-files assignment.
      
      With this, there is no more user of no-clean-files. I will keep it
      for a while to see whether a new user will appear.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      125d059b
  6. 14 Aug, 2019 6 commits
  7. 13 Aug, 2019 3 commits