1. 13 4月, 2018 1 次提交
  2. 10 4月, 2018 1 次提交
    • R
      Kbuild: fix # escaping in .cmd files for future Make · 9564a8cf
      Rasmus Villemoes 提交于
      I tried building using a freshly built Make (4.2.1-69-g8a731d1), but
      already the objtool build broke with
      
      orc_dump.c: In function ‘orc_dump’:
      orc_dump.c:106:2: error: ‘elf_getshnum’ is deprecated [-Werror=deprecated-declarations]
        if (elf_getshdrnum(elf, &nr_sections)) {
      
      Turns out that with that new Make, the backslash was not removed, so cpp
      didn't see a #include directive, grep found nothing, and
      -DLIBELF_USE_DEPRECATED was wrongly put in CFLAGS.
      
      Now, that new Make behaviour is documented in their NEWS file:
      
        * WARNING: Backward-incompatibility!
          Number signs (#) appearing inside a macro reference or function invocation
          no longer introduce comments and should not be escaped with backslashes:
          thus a call such as:
            foo := $(shell echo '#')
          is legal.  Previously the number sign needed to be escaped, for example:
            foo := $(shell echo '\#')
          Now this latter will resolve to "\#".  If you want to write makefiles
          portable to both versions, assign the number sign to a variable:
            C := \#
            foo := $(shell echo '$C')
          This was claimed to be fixed in 3.81, but wasn't, for some reason.
          To detect this change search for 'nocomment' in the .FEATURES variable.
      
      This also fixes up the two make-cmd instances to replace # with $(pound)
      rather than with \#. There might very well be other places that need
      similar fixup in preparation for whatever future Make release contains
      the above change, but at least this builds an x86_64 defconfig with the
      new make.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=197847
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: NRasmus Villemoes <linux@rasmusvillemoes.dk>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      9564a8cf
  3. 07 4月, 2018 9 次提交
    • R
      kbuild: deb-pkg: split generating packaging and build · b41d920a
      Riku Voipio 提交于
      Move debian/ directory generation out of builddeb to a new script,
      mkdebian. The package build commands are kept in builddeb, which
      is now an internal command called from debian/rules.
      
      With these changes in place, we can now use dpkg-buildpackage from
      deb-pkg and bindeb-pkg removing need for handrolled source/changes
      generation.
      
      This patch is based on the criticism of the current state of builddeb
      discussed on:
      
      https://patchwork.kernel.org/patch/9656403/Signed-off-by: NRiku Voipio <riku.voipio@linaro.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      b41d920a
    • M
      kbuild: mark $(targets) as .SECONDARY and remove .PRECIOUS markers · 54a702f7
      Masahiro Yamada 提交于
      GNU Make automatically deletes intermediate files that are updated
      in a chain of pattern rules.
      
      Example 1) %.dtb.o <- %.dtb.S <- %.dtb <- %.dts
      Example 2) %.o <- %.c <- %.c_shipped
      
      A couple of makefiles mark such targets as .PRECIOUS to prevent Make
      from deleting them, but the correct way is to use .SECONDARY.
      
        .SECONDARY
          Prerequisites of this special target are treated as intermediate
          files but are never automatically deleted.
      
        .PRECIOUS
          When make is interrupted during execution, it may delete the target
          file it is updating if the file was modified since make started.
          If you mark the file as precious, make will never delete the file
          if interrupted.
      
      Both can avoid deletion of intermediate files, but the difference is
      the behavior when Make is interrupted; .SECONDARY deletes the target,
      but .PRECIOUS does not.
      
      The use of .PRECIOUS is relatively rare since we do not want to keep
      partially constructed (possibly corrupted) targets.
      
      Another difference is that .PRECIOUS works with pattern rules whereas
      .SECONDARY does not.
      
        .PRECIOUS: $(obj)/%.lex.c
      
      works, but
      
        .SECONDARY: $(obj)/%.lex.c
      
      has no effect.  However, for the reason above, I do not want to use
      .PRECIOUS which could cause obscure build breakage.
      
      The targets specified as .SECONDARY must be explicit.  $(targets)
      contains all targets that need to include .*.cmd files.  So, the
      intermediates you want to keep are mostly in there.  Therefore, mark
      $(targets) as .SECONDARY.  It means primary targets are also marked
      as .SECONDARY, but I do not see any drawback for this.
      
      I replaced some .SECONDARY / .PRECIOUS markers with 'targets'.  This
      will make Kbuild search for non-existing .*.cmd files, but this is
      not a noticeable performance issue.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NFrank Rowand <frowand.list@gmail.com>
      Acked-by: NIngo Molnar <mingo@kernel.org>
      54a702f7
    • M
      kbuild: rename *-asn1.[ch] to *.asn1.[ch] · 4fa8bc94
      Masahiro Yamada 提交于
      Our convention is to distinguish file types by suffixes with a period
      as a separator.
      
      *-asn1.[ch] is a different pattern from other generated sources such
      as *.lex.c, *.tab.[ch], *.dtb.S, etc.  More confusing, files with
      '-asn1.[ch]' are generated files, but '_asn1.[ch]' are checked-in
      files:
        net/netfilter/nf_conntrack_h323_asn1.c
        include/linux/netfilter/nf_conntrack_h323_asn1.h
        include/linux/sunrpc/gss_asn1.h
      
      Rename generated files to *.asn1.[ch] for consistency.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      4fa8bc94
    • M
      kbuild: add %.dtb.S and %.dtb to 'targets' automatically · a7f92419
      Masahiro Yamada 提交于
      Another common pattern that consists of chained commands is to compile
      a DTB as binary data into the kernel image or a module.  It is used in
      several places in the source tree.  Support it in the core Makefile.
      
      $(call if_changed,dt_S_dtb) is more suitable than $(call cmd,dt_S_dtb)
      in case cmd_dt_S_dtb is changed in the future.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NFrank Rowand <frowand.list@gmail.com>
      a7f92419
    • M
      kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically · b23d1a24
      Masahiro Yamada 提交于
      Files generated by if_changed* must be added to 'targets' to include
      *.cmd files.  Otherwise, they would be regenerated every time.
      
      The build system automatically adds objects to 'targets' where
      appropriate, such as obj-y, extra-y, etc. but does nothing for
      intermediate files.  So, each Makefile needs to add them by itself.
      
      There are some common cases where objects are generated by chained
      rules.  Lexers and parsers are compiled like follows:
      
         %.lex.o <- %.lex.c <- %.l
         %.tab.o <- %.tab.c <- %.y
      
      They are common patterns, so it is reasonable to take care of them
      in the core Makefile instead of requiring each Makefile to do so.
      
      At this moment, you cannot delete 'target += zconf.lex.c' in the
      Kconfig Makefile because zconf.lex.c is included from zconf.tab.c
      instead of being compiled separately.  It should be deleted after
      Kconfig is more refactored.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NFrank Rowand <frowand.list@gmail.com>
      b23d1a24
    • M
      genksyms: generate lexer and parser during build instead of shipping · 833e6224
      Masahiro Yamada 提交于
      Now that the kernel build supports flex and bison, remove the _shipped
      files and generate them during the build instead.
      
      There are no more shipped lexer and parser, so I ripped off the rules
      in scripts/Malefile.lib that were used for REGENERATE_PARSERS.
      
      The genksyms parser has ambiguous grammar, which would emit warnings:
      
       scripts/genksyms/parse.y: warning: 9 shift/reduce conflicts [-Wconflicts-sr]
       scripts/genksyms/parse.y: warning: 5 reduce/reduce conflicts [-Wconflicts-rr]
      
      They are normally suppressed, but displayed when W=1 is given.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      833e6224
    • M
      kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile · 9a8dfb39
      Masahiro Yamada 提交于
      Files suffixed by .lex.c, .tab.[ch] are generated lexers, parsers,
      respectively.  Clean them up globally from the top Makefile.
      
      Some of the final host programs those lexer/parser are linked into
      are necessary for building external modules, but the intermediates
      are unneeded.  They can be cleaned away by 'make clean' instead of
      'make mrproper'.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NFrank Rowand <frowand.list@gmail.com>
      9a8dfb39
    • M
      .gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore · 59889300
      Masahiro Yamada 提交于
      These patterns are common to host programs that require lexer and parser.
      Move them to the top .gitignore.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Acked-by: NFrank Rowand <frowand.list@gmail.com>
      59889300
    • R
      kbuild: use HOSTLDFLAGS for single .c executables · 63185b46
      Robin Jarry 提交于
      When compiling executables from a single .c file, the linker is also
      invoked. Pass the HOSTLDFLAGS like for other linker commands.
      Signed-off-by: NRobin Jarry <robin.jarry@6wind.com>
      Cc: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      63185b46
  4. 06 4月, 2018 1 次提交
    • C
      scripts/faddr2line: show the code context · 6870c016
      Changbin Du 提交于
      Inspired by gdb command 'list', show the code context of target lines.
      Here is a example:
      
      $ scripts/faddr2line vmlinux native_write_msr+0x6
      native_write_msr+0x6/0x20:
      arch_static_branch at arch/x86/include/asm/msr.h:105
      100             return EAX_EDX_VAL(val, low, high);
      101     }
      102
      103     static inline void notrace __wrmsr(unsigned int msr, u32 low, u32 high)
      104     {
      105             asm volatile("1: wrmsr\n"
      106                          "2:\n"
      107                          _ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_unsafe)
      108                          : : "c" (msr), "a"(low), "d" (high) : "memory");
      109     }
      110
      (inlined by) static_key_false at include/linux/jump_label.h:142
      137     #define JUMP_TYPE_LINKED        2UL
      138     #define JUMP_TYPE_MASK          3UL
      139
      140     static __always_inline bool static_key_false(struct static_key *key)
      141     {
      142             return arch_static_branch(key, false);
      143     }
      144
      145     static __always_inline bool static_key_true(struct static_key *key)
      146     {
      147             return !arch_static_branch(key, true);
      (inlined by) native_write_msr at arch/x86/include/asm/msr.h:150
      145     static inline void notrace
      146     native_write_msr(unsigned int msr, u32 low, u32 high)
      147     {
      148             __wrmsr(msr, low, high);
      149
      150             if (msr_tracepoint_active(__tracepoint_write_msr))
      151                     do_trace_write_msr(msr, ((u64)high << 32 | low), 0);
      152     }
      153
      154     /* Can be uninlined because referenced by paravirt */
      155     static inline int notrace
      
      Link: http://lkml.kernel.org/r/1521444205-2259-1-git-send-email-changbin.du@intel.comSigned-off-by: NChangbin Du <changbin.du@intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: NeilBrown <neilb@suse.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Kate Stewart <kstewart@linuxfoundation.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6870c016
  5. 03 4月, 2018 1 次提交
  6. 31 3月, 2018 1 次提交
    • M
      kbuild: get <linux/compiler_types.h> out of <linux/kconfig.h> · a95b37e2
      Masahiro Yamada 提交于
      Since commit 28128c61 ("kconfig.h: Include compiler types to avoid
      missed struct attributes"), <linux/kconfig.h> pulls in kernel-space
      headers to unrelated places.
      
      Commit 0f9da844 ("MIPS: boot: Define __ASSEMBLY__ for its.S build")
      suppress the build error by defining __ASSEMBLY__, but ITS (i.e. DTS)
      is not assembly, and should not include <linux/compiler_types.h> in the
      first place.
      
      Looking at arch/s390/tools/Makefile, host programs gen_facilities and
      gen_opcode_table now pull in <linux/compiler_types.h> as well.
      
      The motivation for that commit was to define necessary attributes
      before any struct is defined.  Obviously, this happens only in C.
      
      It is enough to include <linux/compiler_types.h> only when compiling
      C files, and only when compiling kernel space.  Move the include to
      c_flags.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      a95b37e2
  7. 30 3月, 2018 1 次提交
  8. 28 3月, 2018 2 次提交
  9. 26 3月, 2018 23 次提交
    • T
      scripts/checkstack.pl: remove blackfin support · e53a05a4
      Tobias Klauser 提交于
      The Blackfin port has been removed from the kernel, also remove the
      blackfin specific bits from the checkstack.pl script.
      Signed-off-by: NTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      e53a05a4
    • A
      recordmcount.pl: drop blackin and tile support · 82831598
      Arnd Bergmann 提交于
      These two architectures are getting removed, so we no longer
      need the special cases.
      Acked-by: NSteven Rostedt (VMware) <rostedt@goodmis.org>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      82831598
    • M
      kconfig: use yylineno option instead of manual lineno increments · 18492685
      Masahiro Yamada 提交于
      Tracking the line number by hand is error-prone since you need to
      increment it in every \n matching pattern.
      
      If '%option yylineno' is set, flex defines 'yylineno' to contain the
      current line number and automatically updates it each time it reads a
      \n character.  This is much more convenient although the lexer does
      not initializes yylineno, so you need to set it to 1 each time you
      start reading a new file, and restore it you go back to the previous
      file.
      
      I tested this with DEBUG_PARSE, and confirmed the same dump message
      was produced.
      
      I removed the perf-report option.  Otherwise, I see the following
      message:
        %option yylineno entails a performance penalty ONLY on rules that
        can match newline characters
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      18492685
    • M
      kconfig: detect recursive inclusion earlier · 379a8eb8
      Masahiro Yamada 提交于
      Currently, the recursive inclusion is not detected when the offending
      file is about to be included; it is detected the offending file is
      about to include the *next* file.  This is because the detection loop
      does not involve the file being included.
      
      Do this check against the file that is about to be included so that
      the recursive inclusion is detected before unneeded parsing happens.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      379a8eb8
    • M
      kconfig: remove duplicated file name and lineno of recursive inclusion · 32a94b8b
      Masahiro Yamada 提交于
      As in the unit test, the error message for the recursive inclusion
      looks like this:
      
        Kconfig.inc1:4: recursive inclusion detected. Inclusion path:
          current file : 'Kconfig.inc1'
          included from: 'Kconfig.inc3:1'
          included from: 'Kconfig.inc2:3'
          included from: 'Kconfig.inc1:4'
      
      The 'Kconfig.inc1:4' is duplicated in the first and last lines.
      Also, the single quotes do not help readability.
      
      Change the message like follows:
      
        Recursive inclusion detected.
        Inclusion path:
          current file : Kconfig.inc1
          included from: Kconfig.inc3:1
          included from: Kconfig.inc2:3
          included from: Kconfig.inc1:4
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      32a94b8b
    • M
      kconfig: do not include both curses.h and ncurses.h for nconfig · 26561514
      Masahiro Yamada 提交于
      nconf.h includes <curses.h> and "ncurses.h", but it does not need to
      include both.  Generally, it should fall back to curses.h only when
      ncurses.h is not found.  But, looks like it has never happened;
      these includes have been here for many years since commit 692d97c3
      ("kconfig: new configuration interface (nconfig)"), and nobody has
      complained about hard-coding of ncurses.h .  Let's simply drop the
      curses.h inclusion.
      
      I replaced "ncurses.h" with <ncurses.h> since it is not a local file.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      26561514
    • M
      kconfig: make unmet dependency warnings readable · f8f69dc0
      Masahiro Yamada 提交于
      Currently, the unmet dependency warnings end up with endlessly long
      expressions, most of which are false positives.
      
      Here is test code to demonstrate how it currently works.
      
      [Test Case]
      
        config DEP1
                def_bool y
      
        config DEP2
                bool "DEP2"
      
        config A
                bool "A"
                select E
      
        config B
                bool "B"
                depends on DEP2
                select E
      
        config C
                bool "C"
                depends on DEP1 && DEP2
                select E
      
        config D
                def_bool n
                select E
      
        config E
                bool
                depends on DEP1 && DEP2
      
      [Result]
      
        $ make config
        scripts/kconfig/conf  --oldaskconfig Kconfig
        *
        * Linux Kernel Configuration
        *
        DEP2 (DEP2) [N/y/?] (NEW) n
        A (A) [N/y/?] (NEW) y
        warning: (A && B && D) selects E which has unmet direct
        dependencies (DEP1 && DEP2)
      
      Here, I see some points to be improved.
      
      First, '(A || B || D)' would make more sense than '(A && B && D)'.
      I am not sure if this is intentional, but expr_simplify_unmet_dep()
      turns OR expressions into AND, like follows:
      
              case E_OR:
                      return expr_alloc_and(
      
      Second, we see false positives.  'A' is a real unmet dependency.
      'B' is false positive because 'DEP1' is fixed to 'y', and 'B' depends
      on 'DEP2'.  'C' was correctly dropped by expr_simplify_unmet_dep().
      'D' is also false positive because it has no chance to be enabled.
      Current expr_simplify_unmet_dep() cannot avoid those false positives.
      
      After all, I decided to use the same helpers as used for printing
      reverse dependencies in the help.
      
      With this commit, unreadable warnings (most of the reported symbols are
      false positives) in the real world:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      warning: (HWSPINLOCK_QCOM && AHCI_MTK && STMMAC_PLATFORM &&
       DWMAC_IPQ806X && DWMAC_LPC18XX && DWMAC_OXNAS && DWMAC_ROCKCHIP &&
       DWMAC_SOCFPGA && DWMAC_STI && TI_CPSW && PINCTRL_GEMINI &&
       PINCTRL_OXNAS && PINCTRL_ROCKCHIP && PINCTRL_DOVE &&
       PINCTRL_ARMADA_37XX && PINCTRL_STM32 && S3C2410_WATCHDOG &&
       VIDEO_OMAP3 && VIDEO_S5P_FIMC && USB_XHCI_MTK && RTC_DRV_AT91SAM9 &&
       LPC18XX_DMAMUX && VIDEO_OMAP4 && COMMON_CLK_GEMINI &&
       COMMON_CLK_ASPEED && COMMON_CLK_NXP && COMMON_CLK_OXNAS &&
       COMMON_CLK_BOSTON && QCOM_ADSP_PIL && QCOM_Q6V5_PIL && QCOM_GSBI &&
       ATMEL_EBI && ST_IRQCHIP && RESET_IMX7 && PHY_HI6220_USB &&
       PHY_RALINK_USB && PHY_ROCKCHIP_PCIE && PHY_DA8XX_USB) selects
       MFD_SYSCON which has unmet direct dependencies (HAS_IOMEM)
      warning: (PINCTRL_AT91 && PINCTRL_AT91PIO4 && PINCTRL_OXNAS &&
       PINCTRL_PISTACHIO && PINCTRL_PIC32 && PINCTRL_MESON &&
       PINCTRL_NOMADIK && PINCTRL_MTK && PINCTRL_MT7622 && GPIO_TB10X)
       selects OF_GPIO which has unmet direct dependencies (GPIOLIB && OF &&
       HAS_IOMEM)
      warning: (FAULT_INJECTION_STACKTRACE_FILTER && LATENCYTOP && LOCKDEP)
       selects FRAME_POINTER which has unmet direct dependencies
       (DEBUG_KERNEL && (CRIS || M68K || FRV || UML || SUPERH || BLACKFIN ||
       MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS)
      
      will be turned into:
      
      $ make ARCH=score allyesconfig
      scripts/kconfig/conf  --allyesconfig Kconfig
      
      WARNING: unmet direct dependencies detected for MFD_SYSCON
        Depends on [n]: HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_STM32 [=y] && PINCTRL [=y] && (ARCH_STM32 ||
       COMPILE_TEST [=y]) && OF [=y]
        - RTC_DRV_AT91SAM9 [=y] && RTC_CLASS [=y] && (ARCH_AT91 ||
       COMPILE_TEST [=y])
        - RESET_IMX7 [=y] && RESET_CONTROLLER [=y]
        - PHY_HI6220_USB [=y] && (ARCH_HISI && ARM64 ||
       COMPILE_TEST [=y])
        - PHY_RALINK_USB [=y] && (RALINK || COMPILE_TEST [=y])
        - PHY_ROCKCHIP_PCIE [=y] && (ARCH_ROCKCHIP && OF [=y] ||
       COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for OF_GPIO
        Depends on [n]: GPIOLIB [=y] && OF [=y] && HAS_IOMEM [=n]
        Selected by [y]:
        - PINCTRL_MTK [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y]
        - PINCTRL_MT7622 [=y] && PINCTRL [=y] && (ARCH_MEDIATEK ||
       COMPILE_TEST [=y]) && OF [=y] && (ARM64 || COMPILE_TEST [=y])
      
      WARNING: unmet direct dependencies detected for FRAME_POINTER
        Depends on [n]: DEBUG_KERNEL [=y] && (CRIS || M68K || FRV || UML ||
       SUPERH || BLACKFIN || MN10300 || METAG) || ARCH_WANT_FRAME_POINTERS [=n]
        Selected by [y]:
        - LATENCYTOP [=y] && DEBUG_KERNEL [=y] && STACKTRACE_SUPPORT [=y] &&
       PROC_FS [=y] && !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND &&
       !ARC && !X86
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NPetr Vorel <petr.vorel@gmail.com>
      f8f69dc0
    • M
      kconfig: warn unmet direct dependency of tristate symbols selected by y · f622f827
      Masahiro Yamada 提交于
      Commit 246cf9c2 ("kbuild: Warn on selecting symbols with unmet
      direct dependencies") forcibly promoted ->dir_dep.tri to yes from mod.
      So, the unmet direct dependencies of tristate symbols are not reported.
      
      [Test Case]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                tristate "B"
                depends on m
      
      This causes unmet dependency because 'B' is forced 'y' ignoring
      'depends on m'.  This should be warned.
      
      On the other hand, the following case ('B' is bool) should not be
      warned, so 'depends on m' for bool symbols should be naturally treated
      as 'depends on y'.
      
      [Test Case2 (not unmet dependency)]
      
        config MODULES
                def_bool y
                option modules
      
        config A
                def_bool y
                select B
      
        config B
                bool "B"
                depends on m
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      f622f827
    • M
      kconfig: tests: test if recursive inclusion is detected · e2c75e76
      Masahiro Yamada 提交于
      If recursive inclusion is detected, it should fail with error
      messages.  Test this.
      
      This also tests the line numbers in the error message, fixed by
      commit 5ae6fcc4 ("kconfig: fix line number in recursive inclusion
      error message").
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      e2c75e76
    • M
      kconfig: tests: test if recursive dependencies are detected · 29c434f3
      Masahiro Yamada 提交于
      Recursive dependency should be detected and warned.  Test this.
      
      This indirectly tests the line number increments.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      29c434f3
    • M
      kconfig: tests: test randconfig for choice in choice · 3e4888c2
      Masahiro Yamada 提交于
      Commit 3b9a19e0 ("kconfig: loop as long as we changed some symbols
      in randconfig") fixed randconfig where a choice contains a sub-choice.
      Prior to that commit, the sub-choice values were not set.
      
      I am not sure whether this is an intended feature or just something
      people discovered works, but it is used in the real world;
      drivers/usb/gadget/legacy/Kconfig is source'd in a choice context,
      then creates a sub-choice in it.
      
      For the test case in this commit, there are 3 possible results.
      
      Case 1:
        CONFIG_A=y
        # CONFIG_B is not set
      
      Case 2:
        # CONFIG_A is not set
        CONFIG_B=y
        CONFIG_C=y
        # CONFIG_D is not set
      
      Case 3:
        # CONFIG_A is not set
        CONFIG_B=y
        # CONFIG_C is not set
        CONFIG_D=y
        CONFIG_E=y
      
      So, this test iterates several times, and checks if the result is
      either of the three.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      3e4888c2
    • M
      kconfig: tests: test defconfig when two choices interact · beaaddb6
      Masahiro Yamada 提交于
      Commit fbe98bb9 ("kconfig: Fix defconfig when one choice menu
      selects options that another choice menu depends on") fixed defconfig
      when two choices interact (i.e. calculating the visibility of a choice
      requires to calculate another choice).
      
      The test code in that commit log was based on the real world example,
      and complicated.  So, I shrunk it down to the following:
      
      defconfig.choice:
      ---8<---
      CONFIG_CHOICE_VAL0=y
      ---8<---
      
      ---8<---
      config MODULES
              def_bool y
              option modules
      
      choice
              prompt "Choice"
      
      config CHOICE_VAL0
              tristate "Choice 0"
      
      config CHOICE_VAL1
              tristate "Choice 1"
      
      endchoice
      
      choice
              prompt "Another choice"
              depends on CHOICE_VAL0
      
      config DUMMY
              bool "dummy"
      
      endchoice
      ---8<---
      
      Prior to commit fbe98bb9,
      
        $ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice
      
      resulted in:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=m
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      where the expected result would be:
      
        CONFIG_MODULES=y
        CONFIG_CHOICE_VAL0=y
        # CONFIG_CHOICE_VAL1 is not set
        CONFIG_DUMMY=y
      
      Roughly, this weird behavior happened like this:
      
      Symbols are calculated a couple of times.  First, all symbols are
      calculated in conf_read().  The first 'choice' is evaluated to 'y'
      due to the SYMBOL_DEF_USER flag, but sym_calc_choice() clears it
      unless all of its choice values are explicitly set by the user.
      
      conf_set_all_new_symbols() clears all SYMBOL_VALID flags.  Then, only
      choices are calculated.  Here, the SYMBOL_DEF_USER for the first choice
      has been forgotten, so it is evaluated to 'm'.  set_all_choice_values()
      sets SYMBOL_DEF_USER again to choice symbols.
      
      When calculating the second choice, due to 'depends on CHOICE_VAL0',
      it triggers the calculation of CHOICE_VAL0.  As a result, SYMBOL_VALID
      is set for CHOICE_VAL0.
      
      Symbols except choices get the final chance of re-calculation in
      conf_write().  In a normal case, CHOICE_VAL0 would be re-calculated,
      then the first choice would be indirectly re-calculated with the
      SYMBOL_DEF_USER which has been recalled by set_all_choice_values(),
      which would be evaluated to 'y'.  But, in this case, CHOICE_VAL0 has
      already been marked as SYMBOL_VALID, so this re-calculation does not
      happen.  Then, =m from the conf_set_all_new_symbols() phase is written
      out to the .config file.
      
      Add a unit test for this naive case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      beaaddb6
    • M
      kconfig: tests: check visibility of tristate choice values in y choice · ee236610
      Masahiro Yamada 提交于
      If tristate choice values depend on symbols set to 'm', they should be
      hidden when the choice containing them is changed from 'm' to 'y'
      (i.e. exclusive choice).
      
      This issue was fixed by commit fa64e5f6 ("kconfig/symbol.c: handle
      choice_values that depend on 'm' symbols").
      
      Add a test case to avoid regression.
      
      For the input in this unit test, there is a room for argument if
      "# CONFIG_CHOICE1 is not set" should be written to the .config file.
      
      After commit fa64e5f6, this line was written to the .config file.
      
      With commit cb67ab2c ("kconfig: do not write choice values when
      their dependency becomes n"), it is not written now.
      
      In this test, "# CONFIG_CHOICE1 is not set" is don't care.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      ee236610
    • M
      kconfig: tests: check unneeded "is not set" with unmet dependency · 930c429a
      Masahiro Yamada 提交于
      Commit cb67ab2c ("kconfig: do not write choice values when their
      dependency becomes n") fixed a problem where "# CONFIG_... is not set"
      for choice values are wrongly written into the .config file when they
      are once visible, then become invisible later.
      
      Add a test for this naive case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      930c429a
    • M
      kconfig: tests: test if new symbols in choice are asked · b76960c0
      Masahiro Yamada 提交于
      If new choice values are added with new dependency, and they become
      visible during user configuration, oldconfig should recognize them
      as (NEW), and ask the user for choice.
      
      This issue was fixed by commit 5d09598d ("kconfig: fix new choices
      being skipped upon config update").
      
      This is a subtle corner case.  Add a test case to avoid breakage.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      b76960c0
    • M
      kconfig: tests: test automatic submenu creation · 49ac3c0c
      Masahiro Yamada 提交于
      If a symbols has dependency on the preceding symbol, the menu entry
      should become the submenu of the preceding one, and displayed with
      deeper indentation.
      
      This is done by restructuring the menu tree in menu_finalize().
      It is a bit complicated computation, so let's add a test case.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      49ac3c0c
    • M
      kconfig: tests: add basic choice tests · 1903c511
      Masahiro Yamada 提交于
      The calculation of 'choice' is a bit complicated part in Kconfig.
      
      The behavior of 'y' choice is intuitive.  If choice values are tristate,
      the choice can be 'm' where each value can be enabled independently.
      Also, if a choice is marked as 'optional', the whole choice can be
      invisible.
      
      Test basic functionality of choice.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      1903c511
    • M
      kconfig: tests: add framework for Kconfig unit testing · 022a4bf6
      Masahiro Yamada 提交于
      Many parts in Kconfig are so cryptic and need refactoring.  However,
      its complexity prevents us from moving forward.  There are several
      naive corner cases where it is difficult to notice breakage.  If
      those are covered by unit tests, we will be able to touch the code
      with more confidence.
      
      Here is a simple test framework based on pytest.  The conftest.py
      provides a fixture useful to run commands such as 'oldaskconfig' etc.
      and to compare the resulted .config, stdout, stderr with expectations.
      
      How to add test cases?
      ----------------------
      
      For each test case, you should create a subdirectory under
      scripts/kconfig/tests/ (so test cases are separated from each other).
      Every test case directory should contain the following files:
      
       - __init__.py: describes test functions
       - Kconfig: the top level Kconfig file for the test
      
      To do a useful job, test cases generally need additional data like
      input .config and information about expected results.
      
      How to run tests?
      -----------------
      
      You need python3 and pytest.  Then, run "make testconfig".  O= option
      is supported.  If V=1 is given, detailed logs captured during tests
      are displayed.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      022a4bf6
    • U
      kconfig: remove redundant streamline_config.pl prerequisite · 2a616258
      Ulf Magnusson 提交于
      The local{yes,mod}config targets currently have streamline_config.pl as
      a prerequisite. This is redundant, because streamline_config.pl is a
      checked-in file with no prerequisites.
      
      Remove the prerequisite and reference streamline_config.pl directly in
      the recipe of the rule instead.
      Signed-off-by: NUlf Magnusson <ulfalizer@gmail.com>
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      2a616258
    • M
      kconfig: rename silentoldconfig to syncconfig · 911a91c3
      Masahiro Yamada 提交于
      As commit cedd55d4 ("kconfig: Remove silentoldconfig from help
      and docs; fix kconfig/conf's help") mentioned, 'silentoldconfig' is a
      historical misnomer.  That commit removed it from help and docs since
      it is an internal interface.  If so, it should be allowed to rename
      it to something more intuitive.  'syncconfig' is the one I came up
      with because it updates the .config if necessary, then synchronize
      include/generated/autoconf.h and include/config/* with it.
      
      You should not manually invoke 'silentoldcofig'.  Display warning if
      used in case existing scripts are doing wrong.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      911a91c3
    • M
      kconfig: invoke oldconfig instead of silentoldconfig from local*config · 81d2bc22
      Masahiro Yamada 提交于
      The purpose of local{yes,mod}config is to arrange the .config file
      based on actually loaded modules.  It is unnecessary to update
      include/generated/autoconf.h and include/config/* stuff here.
      They will be updated as needed during the build.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      81d2bc22
    • M
      kconfig: hide irrelevant sub-menus for oldconfig · 2aad9b89
      Masahiro Yamada 提交于
      Historically, "make oldconfig" has changed its behavior several times,
      quieter or louder.  (I attached the history below.)  Currently, it is
      not as quiet as it should be.  This commit addresses it.
      
        Test Case
        ---------
      
      ---------------------------(Kconfig)----------------------------
      menu "menu"
      
      config FOO
              bool "foo"
      
      menu "sub menu"
      
      config BAR
              bool "bar"
      
      endmenu
      
      endmenu
      
      menu "sibling menu"
      
      config BAZ
              bool "baz"
      
      endmenu
      ----------------------------------------------------------------
      
      ---------------------------(.config)----------------------------
      CONFIG_BAR=y
      CONFIG_BAZ=y
      ----------------------------------------------------------------
      
      With the Kconfig and .config above, "make silentoldconfig" and
      "make oldconfig" work differently, like follows:
      
        $ make silentoldconfig
        scripts/kconfig/conf  --silentoldconfig Kconfig
        *
        * Restart config...
        *
        *
        * menu
        *
        foo (FOO) [N/y/?] (NEW) y
        #
        # configuration written to .config
        #
      
        $ make oldconfig
        scripts/kconfig/conf  --oldconfig Kconfig
        *
        * Restart config...
        *
        *
        * menu
        *
        foo (FOO) [N/y/?] (NEW) y
        *
        * sub menu
        *
        bar (BAR) [Y/n/?] y
        #
        # configuration written to .config
        #
      
      Both hide "sibling node" since it is irrelevant.  The difference is
      that silentoldconfig hides "sub menu" whereas oldconfig does not.
      The behavior of silentoldconfig is preferred since the "sub menu"
      does not contain any new symbol.
      
      The root cause is in conf().  There are three input modes that can
      call conf(); oldaskconfig, oldconfig, and silentoldconfig.
      
      Everytime conf() encounters a menu entry, it calls check_conf() to
      check if it contains new symbols.  If no new symbol is found, the
      menu is just skipped.
      
      Currently, this happens only when input_mode == silentoldconfig.
      The oldaskconfig enters into the check_conf() loop as silentoldconfig,
      so oldaskconfig works likewise for the second loop or later, but it
      never happens for oldconfig.  So, irrelevant sub-menus are shown for
      oldconfig.
      
      Change the test condition to "input_mode != oldaskconfig".  This is
      false only for the first loop of oldaskconfig; it must ask the user
      all symbols, so no need to call check_conf().
      
        History of oldconfig
        --------------------
      
      [0] Originally, "make oldconfig" was as loud as "make config"  (It
          showed the entire .config file)
      
      [1] Commit cd9140e1 ("kconfig: make oldconfig is now less chatty")
          made oldconfig quieter, but it was still less quieter than
          silentoldconfig.  (oldconfig did not hide sub-menus)
      
      [2] Commit 204c96f6 ("kconfig: fix silentoldconfig") changed
          the input_mode of oldconfig to "ask_silent" from "ask_new".
          So, oldconfig really became as quiet as silentoldconfig.
          (oldconfig hided irrelevant sub-menus)
      
      [3] Commit 4062f1a4 ("kconfig: use long options in conf") made
          oldconfig as loud as [0] due to misconversion.
      
      [4] Commit 14828349 ("kconfig: fix make oldconfig") addressed
          the misconversion of [3], but it made oldconfig quieter only to
          the same level as [1], not [2].
      
      This commit is restoring the behavior of [2].
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      2aad9b89
    • M
      kconfig: remove redundant input_mode test for check_conf() loop · 99f0b657
      Masahiro Yamada 提交于
      check_conf() never increments conf_cnt for listnewconfig, so conf_cnt
      is always zero.
      
      In other words, conf_cnt is not zero, "input_mode != listnewconfig"
      is met.
      Signed-off-by: NMasahiro Yamada <yamada.masahiro@socionext.com>
      Reviewed-by: NUlf Magnusson <ulfalizer@gmail.com>
      99f0b657