Christian Lamparter [Fri, 5 Feb 2021 09:24:38 +0000 (10:24 +0100)]
carl9170 firmware: prepare header update
This patch brings the shared firmware headers in line with the carl9170
linux kernel driver.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Thomas Gleixner [Wed, 29 May 2019 23:57:40 +0000 (16:57 -0700)]
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 325
Based on 1 normalized pattern(s):
this program is free software you can redistribute it and or modify
it under the terms of the gnu general public license as published by
the free software foundation either version 2 of the license this
program is distributed in the hope that it will be useful but
without any warranty without even the implied warranty of
merchantability or fitness for a particular purpose see the gnu
general public license for more details you should have received a
copy of the gnu general public license along with this program see
the file copying if not see http www gnu org licenses
extracted by the scancode license scanner the SPDX license identifier
GPL-2.0-only
has been chosen to replace the boilerplate/reference in 1 file(s).
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Reviewed-by: Armijn Hemel <armijn@tjaldur.nl>
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190530000435.742096485@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Arnd Bergmann [Thu, 4 Feb 2021 16:29:17 +0000 (17:29 +0100)]
carl9170: fix struct alignment conflict
Multiple structures in the carl9170 driver have alignment
impossible alignment constraints that gcc warns about when
building with 'make W=1':
include/shared/fwcmd.h:243:2: warning: alignment 1 of 'union <anonymous>' is less than 4 [-Wpacked-not-aligned]
include/shared/wlan.h:373:1: warning: alignment 1 of 'struct ar9170_rx_frame_single' is less than 2 [-Wpacked-not-aligned]
In the carl9170_cmd structure, multiple members that have an explicit
alignment requirement of four bytes are added into a union with explicit
byte alignment, but this in turn is part of a structure that also has
four-byte alignment.
In the wlan.h header, multiple structures contain a ieee80211_hdr member
that is required to be two-byte aligned to avoid alignmnet faults when
processing network headers, but all members are forced to be byte-aligned
using the __packed tag at the end of the struct definition.
In both cases, leaving out the packing does not change the internal
layout of the structure but changes the alignment constraint of the
structure itself.
Change all affected structures to only apply packing where it does
not violate the alignment requirement of the contained structure.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Gustavo A. R. Silva [Thu, 7 May 2020 15:19:21 +0000 (10:19 -0500)]
carl9170: Replace zero-length array with flexible-array
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:
struct foo {
int stuff;
struct boo array[];
};
By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.
Also, notice that, dynamic memory allocations won't be affected by
this change:
"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]
sizeof(flexible-array-member) triggers a warning because flexible array
members have incomplete type[1]. There are some instances of code in
which the sizeof operator is being incorrectly/erroneously applied to
zero-length arrays and the result is zero. Such instances may be hiding
some bugs. So, this work (flexible-array member conversions) will also
help to get completely rid of those sorts of issues.
This issue was found with the help of Coccinelle.
[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit
76497732932f ("cxgb3/l2t: Fix undefined behaviour")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20200507151921.GA5083@embeddedor
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Fri, 24 Jul 2020 22:47:12 +0000 (00:47 +0200)]
carl9170 toolchain: update to gcc 10.2.0
This patch also removes some of SHA256SUMS' old entries.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sat, 9 May 2020 20:33:20 +0000 (22:33 +0200)]
carl9170 toolchain: update to gcc 10.1.0
This patch also removes some of SHA256SUMS' old entries.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Fri, 20 Mar 2020 19:27:34 +0000 (20:27 +0100)]
carl9170 toolchain: update to gcc 9.3.0
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Thomas Hebb [Mon, 9 Dec 2019 08:19:17 +0000 (00:19 -0800)]
kconfig: don't crash on NULL expressions in expr_eq()
NULL expressions are taken to always be true, as implemented by the
expr_is_yes() macro and by several other functions in expr.c. As such,
they ought to be valid inputs to expr_eq(), which compares two
expressions.
Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Laura Abbott [Mon, 4 Nov 2019 22:10:08 +0000 (17:10 -0500)]
kconfig: Add option to get the full help text with listnewconfig
make listnewconfig will list the individual options that need to be set.
This is useful but there's no easy way to get the help text associated
with the options at the same time. Introduce a new targe
'make helpnewconfig' which lists the full help text of all the
new options as well. This makes it easier to automatically generate
changes that are easy for humans to review. This command also adds
markers between each option for easier parsing.
Signed-off-by: Laura Abbott <labbott@redhat.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Sun, 25 Aug 2019 17:28:33 +0000 (02:28 +0900)]
kconfig: split util.c out of parser.y
util.c exists both in scripts/kconfig/ and scripts/kconfig/lxdialog.
Prior to commit
54b8ae66ae1a ("kbuild: change *FLAGS_<basetarget>.o
to take the path relative to $(obj)"), Kbuild could not pass different
flags to source files with the same basename. Now that this issue
was solved, you can split util.c out of parser.y and compile them
independently of each other.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sat, 1 Feb 2020 17:54:28 +0000 (18:54 +0100)]
carl9170 toolchain: update binutils, newlib and gmp
This patch updates three toolchain sources:
binutils - 2.34
newlib - 3.3.0
gmp - 6.2.0
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sat, 26 Oct 2019 16:29:18 +0000 (18:29 +0200)]
carl9170 toolchain: update to binutils 2.33.1
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Fri, 27 Sep 2019 20:49:51 +0000 (22:49 +0200)]
carl9170: config: update CMakeFiles
- parser and lexer were renamed from the previous generic zconf.*.*
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
M. Vefa Bicakci [Sat, 3 Aug 2019 10:02:12 +0000 (06:02 -0400)]
kconfig: Clear "written" flag to avoid data loss
Prior to this commit, starting nconfig, xconfig or gconfig, and saving
the .config file more than once caused data loss, where a .config file
that contained only comments would be written to disk starting from the
second save operation.
This bug manifests itself because the SYMBOL_WRITTEN flag is never
cleared after the first call to conf_write, and subsequent calls to
conf_write then skip all of the configuration symbols due to the
SYMBOL_WRITTEN flag being set.
This commit resolves this issue by clearing the SYMBOL_WRITTEN flag
from all symbols before conf_write returns.
Fixes: 8e2442a5f86e ("kconfig: fix missing choice values in auto.conf")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Signed-off-by: M. Vefa Bicakci <m.v.b@runbox.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 12 Jul 2019 06:07:09 +0000 (15:07 +0900)]
kconfig: fix missing choice values in auto.conf
Since commit
00c864f8903d ("kconfig: allow all config targets to write
auto.conf if missing"), Kconfig creates include/config/auto.conf in the
defconfig stage when it is missing.
Joonas Kylmälä reported incorrect auto.conf generation under some
circumstances.
To reproduce it, apply the following diff:
| --- a/arch/arm/configs/imx_v6_v7_defconfig
| +++ b/arch/arm/configs/imx_v6_v7_defconfig
| @@ -345,14 +345,7 @@ CONFIG_USB_CONFIGFS_F_MIDI=y
| CONFIG_USB_CONFIGFS_F_HID=y
| CONFIG_USB_CONFIGFS_F_UVC=y
| CONFIG_USB_CONFIGFS_F_PRINTER=y
| -CONFIG_USB_ZERO=m
| -CONFIG_USB_AUDIO=m
| -CONFIG_USB_ETH=m
| -CONFIG_USB_G_NCM=m
| -CONFIG_USB_GADGETFS=m
| -CONFIG_USB_FUNCTIONFS=m
| -CONFIG_USB_MASS_STORAGE=m
| -CONFIG_USB_G_SERIAL=m
| +CONFIG_USB_FUNCTIONFS=y
| CONFIG_MMC=y
| CONFIG_MMC_SDHCI=y
| CONFIG_MMC_SDHCI_PLTFM=y
And then, run:
$ make ARCH=arm mrproper imx_v6_v7_defconfig
You will see CONFIG_USB_FUNCTIONFS=y is correctly contained in the
.config, but not in the auto.conf.
Please note drivers/usb/gadget/legacy/Kconfig is included from a choice
block in drivers/usb/gadget/Kconfig. So USB_FUNCTIONFS is a choice value.
This is probably a similar situation described in commit
beaaddb62540
("kconfig: tests: test defconfig when two choices interact").
When sym_calc_choice() is called, the choice symbol forgets the
SYMBOL_DEF_USER unless all of its choice values are explicitly set by
the user.
The choice symbol is given just one chance to recall it because
set_all_choice_values() is called if SYMBOL_NEED_SET_CHOICE_VALUES
is set.
When sym_calc_choice() is called again, the choice symbol forgets it
forever, since SYMBOL_NEED_SET_CHOICE_VALUES is a one-time aid.
Hence, we cannot call sym_clear_all_valid() again and again.
It is crazy to repeat set and unset of internal flags. However, we
cannot simply get rid of "sym->flags &= flags | ~SYMBOL_DEF_USER;"
Doing so would re-introduce the problem solved by commit
5d09598d488f
("kconfig: fix new choices being skipped upon config update").
To work around the issue, conf_write_autoconf() stopped calling
sym_clear_all_valid().
conf_write() must be changed accordingly. Currently, it clears
SYMBOL_WRITE after the symbol is written into the .config file. This
is needed to prevent it from writing the same symbol multiple times in
case the symbol is declared in two or more locations. I added the new
flag SYMBOL_WRITTEN, to track the symbols that have been written.
Anyway, this is a cheesy workaround in order to suppress the issue
as far as defconfig is concerned.
Handling of choices is totally broken. sym_clear_all_valid() is called
every time a user touches a symbol from the GUI interface. To reproduce
it, just add a new symbol drivers/usb/gadget/legacy/Kconfig, then touch
around unrelated symbols from menuconfig. USB_FUNCTIONFS will disappear
from the .config file.
I added the Fixes tag since it is more fatal than before. But, this
has been broken since long long time before, and still it is.
We should take a closer look to fix this correctly somehow.
Fixes: 00c864f8903d ("kconfig: allow all config targets to write auto.conf if missing")
Cc: linux-stable <stable@vger.kernel.org> # 4.19+
Reported-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 11 Jul 2019 07:33:17 +0000 (16:33 +0900)]
kconfig: remove meaningless if-conditional in conf_read()
sym_is_choice(sym) has already been checked by previous if-block:
if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
continue;
Hence, the following code is redundant, and the comment is misleading:
if (!sym_is_choice(sym))
continue;
/* fall through */
It always takes 'continue', never falls though.
Clean up the dead code.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Marco Ammon [Thu, 4 Jul 2019 10:50:41 +0000 (12:50 +0200)]
kconfig: Fix spelling of sym_is_changable
There is a spelling mistake in "changable", it is corrected to
"changeable" and all call sites are updated accordingly.
Signed-off-by: Marco Ammon <marco.ammon@fau.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Mauro Carvalho Chehab [Wed, 12 Jun 2019 17:52:48 +0000 (14:52 -0300)]
docs: kbuild: convert docs to ReST and rename to *.rst
The kbuild documentation clearly shows that the documents
there are written at different times: some use markdown,
some use their own peculiar logic to split sections.
Convert everything to ReST without affecting too much
the author's style and avoiding adding uneeded markups.
The conversion is actually:
- add blank lines and identation in order to identify paragraphs;
- fix tables markups;
- add some lists markups;
- mark literal blocks;
- adjust title markups.
At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 27 May 2019 14:37:23 +0000 (23:37 +0900)]
kconfig: add static qualifier to expand_string()
Now expand_string() is only used in preprocess.c
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 27 May 2019 14:37:22 +0000 (23:37 +0900)]
kconfig: require the argument of --defconfig
Currently, the argument for --defconfig is optional. If the argument
is not passed, the hard-coded default arch/$(ARCH)/defconfig is used.
It no longer happens in Linux since the last users of the default are
gone by the following commits:
- Commit
f3e20ad67b4c ("s390: move arch/s390/defconfig to
arch/s390/configs/defconfig")
- Commit
986a13769c4b ("alpha: move arch/alpha/defconfig to
arch/alpha/configs/defconfig")
I want to kill the Linux-specific directory path embedded in the
Kconfig binary.
The --savedefconfig (reverse operation of --defconfig) requires an
argument, so it should not hurt to do likewise for --defconfig.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Alexander Popov [Fri, 17 May 2019 19:42:22 +0000 (22:42 +0300)]
kconfig: Terminate menu blocks with a comment in the generated config
Currently menu blocks start with a pretty header but end with nothing in
the generated config. So next config options stick together with the
options from the menu block.
Let's terminate menu blocks in the generated config with a comment and
a newline if needed. Example:
...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y
#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y
# end of Network testing
# end of Networking options
CONFIG_HAMRADIO=y
...
Signed-off-by: Alexander Popov <alex.popov@linux.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Sun, 12 May 2019 16:00:53 +0000 (01:00 +0900)]
kconfig: make conf_get_autoconfig_name() static
This is only used in confdata.c
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Jacob Garber [Fri, 10 May 2019 19:28:52 +0000 (13:28 -0600)]
kconfig: use snprintf for formatting pathnames
Valid pathnames will never exceed PATH_MAX, but these file names
are unsanitized and can cause buffer overflow if set incorrectly.
Use snprintf to avoid this. This was flagged during a Coverity scan
of the coreboot project, which also uses kconfig for its build system.
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 10 May 2019 16:56:48 +0000 (01:56 +0900)]
kconfig: remove useless NULL pointer check in conf_write_dep()
conf_write_dep() has just one caller:
conf_write_dep("include/config/auto.conf.cmd");
"name" always points to a valid string.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 10 May 2019 16:56:01 +0000 (01:56 +0900)]
kconfig: make parent directories for the saved .config as needed
With menuconfig / nconfig, users can input any file path from the
"Save" menu, but it fails if the parent directory does not exist.
Why not create the parent directory automatically. I think this is
a user-friendly behavior.
I changed the error messages in menuconfig / nconfig.
"Nonexistent directory" is no longer the most likely reason of the
failure. Perhaps, the user specified the existing directory, or
attempted to write to the location without write permission.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 10 May 2019 06:12:05 +0000 (15:12 +0900)]
kconfig: do not write .config if the content is the same
Kconfig updates the .config when it exits even if its content is
exactly the same as before. Since its timestamp becomes newer than
that of other build artifacts, additional processing is invoked,
which is annoying.
- syncconfig is invoked to update include/config/auto.conf, etc.
- kernel/configs.o is recompiled if CONFIG_IKCONFIG is enabled,
then vmlinux is relinked as well.
If the .config is not changed at all, we do not have to even
touch it. Just bail out showing "No change to .config".
$ make allmodconfig
config/conf --allmodconfig Kconfig
#
# configuration written to .config
#
$ make allmodconfig
config/conf --allmodconfig Kconfig
#
# No change to .config
#
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 10 May 2019 06:12:04 +0000 (15:12 +0900)]
kconfig: do not accept a directory for configuration output
Currently, conf_write() can be called with a directory name instead
of a file name. As far as I see, this can happen for menuconfig,
nconfig, gconfig.
If it is given with a directory path, conf_write() kindly appends
getenv("KCONFIG_CONFIG"), but this ends up with hacky dir/basename
handling, and screwed up in corner-cases like "what if KCONFIG_CONFIG
is an absolute path?" as discussed before:
https://patchwork.kernel.org/patch/
9910037/
Since conf_write() is already messed up, I'd say "do not do it".
Please pass a file path all the time. If a directory path is specified
for the configuration output, conf_write() will simply error out.
Now that the tmp file is created in the same directory as the .config,
the previously reported "what if KCONFIG_CONFIG points to a different
file system?" has been solved.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Nicolas Porcel <nicolasporcel06@gmail.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 22 Feb 2019 07:40:11 +0000 (16:40 +0900)]
kbuild: move ".config not found!" message from Kconfig to Makefile
If you run "make" in a pristine source tree, currently Kbuild will
start to build Kconfig to let it show the error message.
It would be more straightforward to check it in Makefile and let
it fail immediately.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 24 Jan 2019 10:47:30 +0000 (19:47 +0900)]
kconfig: rename zconf.y to parser.y
Use a more logical name.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 24 Jan 2019 10:47:29 +0000 (19:47 +0900)]
kconfig: rename zconf.l to lexer.l
Use a more logical name.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sun, 18 Aug 2019 19:17:06 +0000 (21:17 +0200)]
carl9170 toolchain: update to gcc 9.2.0
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sun, 5 May 2019 09:17:45 +0000 (11:17 +0200)]
carl9170 toolchain: update to gcc 9.1.0
gcc will now be warning about conflicting alignments
when a pointer from a packed structure is in play.
the include headers will likely need further fixes, but
we can wait until the linux kernel folks know how they
want to deal with ieee80211.h.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Mon, 4 Mar 2019 11:50:12 +0000 (12:50 +0100)]
carl9170: fix printf.c file permission
This was set to executable.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Mon, 4 Mar 2019 11:53:02 +0000 (12:53 +0100)]
carl9170 firmware: config: fix missing lkc_proto.h update
Commit:
2396dc74a1e0 ("kconfig: allow all config targets to write auto.conf if missing")
included a hunk for lkc_proto.h that was dropped.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Mon, 4 Mar 2019 11:21:31 +0000 (12:21 +0100)]
carl9170: config: re-add config.cmake
This patch re-adds the custom config.cmake support that was
removed by the cleanup patch.
Reported-by: Jason Self <j@jxself.org>
Fixes: 786134321b6e ("carl9170: config: fix patching errors and update CMakeFiles")
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sun, 24 Feb 2019 20:45:48 +0000 (21:45 +0100)]
carl9170 toolchain: update to gcc 8.3.0
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 21 Dec 2018 06:23:02 +0000 (15:23 +0900)]
kconfig: remove unused "file" field of yylval union
This has never been used.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 21 Dec 2018 08:33:05 +0000 (17:33 +0900)]
kconfig: split the lexer out of zconf.y
Compile zconf.lex.c independently of the other files.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Christian Lamparter [Sun, 10 Feb 2019 21:53:14 +0000 (22:53 +0100)]
carl9170: config: fix patching errors and update CMakeFiles
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 21 Dec 2018 08:33:04 +0000 (17:33 +0900)]
kconfig: split some C files out of zconf.y
I want to compile each C file independently instead of including all
of them from zconf.y.
Split out confdata.c, expr.c, symbol.c, and preprocess.c .
These are low-hanging fruits.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 18 Dec 2018 12:13:35 +0000 (21:13 +0900)]
kconfig: convert to SPDX License Identifier
All files in lxdialog/ are licensed under GPL-2.0+, and the rest are
under GPL-2.0. I added GPL-2.0 tags to test scripts in tests/.
Documentation/process/license-rules.rst does not suggest anything
about the flex/bison files. Because flex does not accept the C++
comment style at the very top of a file, I used the C style for
zconf.l, and so for zconf.y for consistency.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:10 +0000 (20:01 +0900)]
kconfig: remove keyword lookup table entirely
Commit
7a88488bbc23 ("[PATCH] kconfig: use gperf for kconfig keywords")
introduced gperf for the keyword lookup.
Then, commit
bb3290d91695 ("Remove gperf usage from toolchain") killed
the gperf use. As a result, the linear keyword search was left behind.
If we do not use gperf, there is no reason to have the separate table
of the keywords. Move all keywords back to the lexer.
I also refactored the lexer to remove the COMMAND and PARAM states.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:09 +0000 (20:01 +0900)]
kconfig: update current_pos in the second lexer
To simplify the generated lexer, let the hand-made lexer update the
file name and line number for the parser.
I tested this with DEBUG_PARSE, and confirmed the same file names
and line numbers were dumped.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:08 +0000 (20:01 +0900)]
kconfig: switch to ASSIGN_VAL state in the second lexer
To simplify the generated lexer, switch to the ASSIGN_VAL state in
the hand-made lexer.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:07 +0000 (20:01 +0900)]
kconfig: stop associating kconf_id with yylval
The lexer has conventionally associated kconf_id data with yylval
to carry additional information to the parser.
No token is relying on this any more.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:06 +0000 (20:01 +0900)]
kconfig: refactor end token rules
T_ENDMENU, T_ENDCHOICE, T_ENDIF are the last users of kconf_id
associated with yylval. Refactor them to not use it.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:05 +0000 (20:01 +0900)]
kconfig: stop supporting '.' and '/' in unquoted words
In my understanding, special characters such as '.' and '/' are
supported in unquoted words to use bare file paths in the "source"
statement.
With the previous commit surrounding all file paths with double
quotes, we can drop this.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:02 +0000 (20:01 +0900)]
kconfig: use T_WORD instead of T_VARIABLE for variables
There is no grammatical ambiguity by using T_WORD for variables.
The parser can distinguish variables from symbols from the context.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:01 +0000 (20:01 +0900)]
kconfig: use specific tokens instead of T_ASSIGN for assignments
Currently, the lexer returns T_ASSIGN for all of =, :=, and +=
associating yylval with the flavor.
I want to make the generated lexer as simple as possible. So, the
lexer should convert keywords to tokens without thinking about the
meaning.
= -> T_EQUAL
:= -> T_COLON_EQUAL
+= -> T_PLUS_EQUAL
Unfortunately, Kconfig uses = instead of == for the equal operator.
So, the same token T_EQUAL is used for assignment and comparison.
The parser can still distinguish them from the context.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:01:00 +0000 (20:01 +0900)]
kconfig: refactor scanning and parsing "option" properties
For the keywords "modules", "defconfig_list", and "allnoconfig_y",
the lexer should pass specific tokens instead of generic T_WORD.
This simplifies both the lexer and the parser.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:59 +0000 (20:00 +0900)]
kconfig: use distinct tokens for type and default properties
This commit removes kconf_id::stype to prepare for the entire
removal of kconf_id.c
To simplify the lexer, I want keywords straight-mapped to tokens.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:58 +0000 (20:00 +0900)]
kconfig: remove redundant token defines
These are already defined as %left.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:57 +0000 (20:00 +0900)]
kconfig: rename depends_list to comment_option_list
Now the comment_stmt is the only user of depends_list. Rename it to
comment_option_list
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:56 +0000 (20:00 +0900)]
kconfig: loosen the order of "visible" and "depends on" in menu entry
Currently, "visible" and "depends on", if defined in a menu entry,
must appear in that order.
The real example is in drivers/media/tuners/Kconfig:
menu "Customize TV tuners"
visible if <expr1>
depends on <expr2>
... is fine, but you cannot change the property order like this:
menu "Customize TV tuners"
depends on <expr2>
visible if <expr1>
Kconfig does not require a specific order of properties. In this case,
menu_add_visibility(() and menu_add_dep() are orthogonal.
Loosen this unreasonable restriction.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:55 +0000 (20:00 +0900)]
kconfig: remove redundant menu_block rule
The code block surrounded by "menu" ... "endmenu" is stmt_list.
Remove the redundant menu_block symbol entirely.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:54 +0000 (20:00 +0900)]
kconfig: remove redundant if_block rule
The code block surrounded by "if" ... "endif" is stmt_list.
Remove the redundant if_block symbol entirely.
Remove "stmt_list: stmt_list end" rule as well since it would
obviously cause conflicts.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:53 +0000 (20:00 +0900)]
kconfig: remove grammatically ambiguous option_error
This commit decreases 6 shift/reduce conflicts, and finally achieves
conflict-free parser.
Since Kconfig has no terminator for a config block, detecting the end
of config_stmt is not easy.
For example, there are two ways for handling the error in the following
code:
1 config FOO
2 =
[A] Print "unknown option" error, assuming the line 2 is a part of
config_option_list
[B] Print "invalid statement", assuming the line 1 is reduced into
a config_stmt by itself
Bison actually chooses [A] because it performs the shift rather than
the reduction where both are possible.
However, there is no reason to choose one over the other.
Let's remove the option_error, and let it fall back to [B].
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:52 +0000 (20:00 +0900)]
kconfig: remove grammatically ambiguous "unexpected option" diagnostic
This commit decreases 15 shift/reduce conflicts.
The location of this error recovery is ambiguous.
For example, there are two ways to interpret the following code:
1 config FOO
2 bool "foo"
[A] Both lines are reduced together into a config_stmt.
[B] The only line 1 is reduced into a config_stmt, and the line 2
matches to "option_name error T_EOL"
Of course, we expect [A], but [B] could be grammatically possible.
Kconfig has no terminator for a config block. So, we cannot detect its
end until we see a non-property keyword. People often insert a blank
line between two config blocks, but it is just a coding convention.
Blank lines are actually allowed anywhere in Kconfig files.
The real error is when a property keyword appears right after "endif",
"endchoice", "endmenu", "source", "comment", or variable assignment.
Instead of fixing the grammatical ambiguity, I chose to simply remove
this error recovery.
The difference is
unexpected option "bool"
... is turned into a more generic message:
invalid statement
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:51 +0000 (20:00 +0900)]
kconfig: warn no new line at end of file
It would be nice to warn if a new line is missing at end of file.
We could do this by checkpatch.pl for arbitrary files, but new line
is rather essential as a statement terminator in Kconfig.
The warning message looks like this:
kernel/Kconfig.preempt:60:warning: no new line at end of file
Currently, kernel/Kconfig.preempt is the only file with no new line
at end of file. Fix it.
I know there are some false negative cases. For example, no warning
is displayed when the last line contains some whitespaces/comments,
but no new line. Yet, this commit works well for most cases.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:50 +0000 (20:00 +0900)]
kconfig: clean up EOF handling in the lexer
A new file should always start in the INITIAL state.
When the lexer bumps into EOF, the lexer must get back to the INITIAL
state anyway. Remove the redundant <<EOF>> pattern in the PARAM state.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:49 +0000 (20:00 +0900)]
kconfig: fix ambiguous grammar in terms of new lines
This commit decreases 8 shift/reduce conflicts.
A certain amount of grammatical ambiguity comes from how to reduce
excessive T_EOL tokens.
Let's take a look at the example code below:
1 config A
2 bool "a"
3
4 depends on B
5
6 config B
7 def_bool y
The line 3 is melt into "config_option_list", but the line 5 can be
either a part of "config_option_list" or "common_stmt" by itself.
Currently, the lexer converts '\n' to T_EOL verbatim. In Kconfig,
a new line works as a statement terminator, but new lines in empty
lines are not critical since empty lines (or lines that contain only
whitespaces/comments) are just no-op.
If the lexer simply discards no-op lines, the parser will not be
bothered by excessive T_EOL tokens.
Of course, this means we are shifting the complexity from the parser
to the lexer, but it is much easier than tackling on shift/reduce
conflicts.
I introduced the second stage lexer to tweak the behavior.
Discard T_EOL if the previous token is T_EOL or T_HELPTEXT.
Two T_EOL tokens in a row is meaningless. T_HELPTEXT is a special
token that is reduced without T_EOL.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:48 +0000 (20:00 +0900)]
kconfig: refactor pattern matching in STRING state
Here, similar matching patters are duplicated in order to look ahead
the '\n' character. If the next character is '\n', the lexer returns
T_WORD_QUOTE because it must be prepared to return T_EOL at the next
match.
Use unput('\n') trick to reduce the code duplication.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:47 +0000 (20:00 +0900)]
kconfig: remove unneeded pattern matching to whitespaces
Whitespaces are consumed in the COMMAND state anyway.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:46 +0000 (20:00 +0900)]
kconfig: require T_EOL to reduce visible statement
All line-oriented statements should be reduced when seeing a T_EOL
token. I guess missing T_EOL for the "visible" statement is just a
mistake. This commit decreases one shift/reduce conflict.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:45 +0000 (20:00 +0900)]
kconfig: fix memory leak when EOF is encountered in quotation
An unterminated string literal followed by new line is passed to the
parser (with "multi-line strings not supported" warning shown), then
handled properly there.
On the other hand, an unterminated string literal at end of file is
never passed to the parser, then results in memory leak.
[Test Code]
----------(Kconfig begin)----------
source "Kconfig.inc"
config A
bool "a"
-----------(Kconfig end)-----------
--------(Kconfig.inc begin)--------
config B
bool "b\No new line at end of file
---------(Kconfig.inc end)---------
[Summary from Valgrind]
Before the fix:
LEAK SUMMARY:
definitely lost: 16 bytes in 1 blocks
...
After the fix:
LEAK SUMMARY:
definitely lost: 0 bytes in 0 blocks
...
Eliminate the memory leak path by handling this case. Of course, such
a Kconfig file is wrong already, so I will add an error message later.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Tue, 11 Dec 2018 11:00:44 +0000 (20:00 +0900)]
kconfig: fix file name and line number of warn_ignored_character()
Currently, warn_ignore_character() displays invalid file name and
line number.
The lexer should use current_file->name and yylineno, while the parser
should use zconf_curname() and zconf_lineno().
This difference comes from that the lexer is always going ahead
of the parser. The parser needs to look ahead one token to make a
shift/reduce decision, so the lexer is requested to scan more text
from the input file.
This commit fixes the warning message from warn_ignored_character().
[Test Code]
----(Kconfig begin)----
/
-----(Kconfig end)-----
[Output]
Before the fix:
<none>:0:warning: ignoring unsupported character '/'
After the fix:
Kconfig:1:warning: ignoring unsupported character '/'
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 30 Nov 2018 09:15:52 +0000 (18:15 +0900)]
kconfig: remove k_invalid from expr_parse_string() return type
The only possibility of k_invalid being returned was when
expr_parse_sting() parsed S_OTHER type symbol. This actually never
happened, and this is even clearer since S_OTHER has gone.
Clean up unreachable code.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 30 Nov 2018 09:15:51 +0000 (18:15 +0900)]
kconfig: remove S_OTHER symbol type and correct dependency tracking
The S_OTHER type could be set only when conf_read_simple() is reading
include/config/auto.conf file.
For example, CONFIG_FOO=y exists in include/config/auto.conf but it is
missing from the currently parsed Kconfig files, sym_lookup() allocates
a new symbol, and sets its type to S_OTHER.
Strangely, it will be set to S_STRING by conf_set_sym_val() a few lines
below while it is obviously bool or tristate type. On the other hand,
when CONFIG_BAR="bar" is being dropped from include/config/auto.conf,
its type remains S_OTHER. Because for_all_symbols() omits S_OTHER
symbols, conf_touch_deps() misses to touch include/config/bar.h
This behavior has been a pretty mystery for me, and digging the git
histroy did not help. At least, touching depfiles is broken for string
type symbols.
I removed S_OTHER entirely, and reimplemented it more simply.
If CONFIG_FOO was visible in the previous syncconfig, but is missing
now, what we want to do is quite simple; just call conf_touch_dep()
to touch include/config/foo.h instead of allocating a new symbol data.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 30 Nov 2018 09:15:50 +0000 (18:15 +0900)]
kconfig: split out code touching a file to conf_touch_dep()
conf_touch_deps() iterates over symbols, touching corresponding
include/config/*.h files as needed.
Split the part that touches a single file into a new helper so it can
be reused.
The new helper, conf_touch_dep(), takes a symbol name as a parameter,
and touches the corresponding include/config/*.h file.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 30 Nov 2018 09:15:49 +0000 (18:15 +0900)]
kconfig: rename conf_split_config() to conf_touch_deps()
According to commit
2e3646e51b2d ("kconfig: integrate split config
into silentoldconfig"), this function was named after split-include
tool, which used to exist in old versions of Linux.
Setting aside the historical reason, rename it into a more intuitive
name. This function touches timestamp files under include/config/
in order to interact with the fixdep tool.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 30 Nov 2018 09:15:48 +0000 (18:15 +0900)]
kconfig: remove unneeded setsym label in conf_read_simple()
The two 'goto setsym' statements are reachable only when sym == NULL.
The code below the 'setsym:' label does nothing when sym == NULL
since there is just one if-block guarded by 'if (sym && ...)'.
Hence, 'goto setsym' can be replaced with 'continue'.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 29 Oct 2018 15:41:27 +0000 (00:41 +0900)]
kconfig: remove oldnoconfig target
As commit
312ee68752fa ("kconfig: announce removal of oldnoconfig if
used") announced, it is time for the removal.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 16 Aug 2018 07:48:26 +0000 (16:48 +0900)]
kconfig: suppress "configuration written to .config" for syncconfig
The top-level Makefile invokes "make syncconfig" when necessary.
Then, Kconfig displays the following message when .config is updated.
#
# configuration written to .config
#
It is distracting because "make syncconfig" happens during the build
stage, and does nothing important in most cases.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Wed, 15 Aug 2018 05:59:45 +0000 (14:59 +0900)]
kconfig: improve the recursive dependency report
This commit improves the messages of the recursive dependency.
Currently, sym->dir_dep.expr is not checked. Hence, any dependency
in property visibility is regarded as the dependency of the symbol.
[Test Code 1]
config A
bool "a"
depends on B
config B
bool "b"
depends on A
[Test Code 2]
config A
bool "a" if B
config B
bool "b"
depends on A
For both cases above, the same message is displayed:
symbol B depends on A
symbol A depends on B
This commit changes the message for the latter, like this:
symbol B depends on A
symbol A prompt is visible depending on B
Also, 'select' and 'imply' are distinguished.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Wed, 15 Aug 2018 05:59:44 +0000 (14:59 +0900)]
kconfig: report recursive dependency involving 'imply'
Currently, Kconfig does not complain about the recursive dependency
where 'imply' keywords are involved.
[Test Code]
config A
bool "a"
config B
bool "b"
imply A
depends on A
In the code above, Kconfig cannot calculate the symbol values correctly
due to the circular dependency. For example, allyesconfig followed by
syncconfig results in an odd behavior because CONFIG_B becomes visible
in syncconfig.
$ make allyesconfig
scripts/kconfig/conf --allyesconfig Kconfig
#
# configuration written to .config
#
$ cat .config
#
# Automatically generated file; DO NOT EDIT.
# Main menu
#
CONFIG_A=y
$ make syncconfig
scripts/kconfig/conf --syncconfig Kconfig
*
* Restart config...
*
*
* Main menu
*
a (A) [Y/n/?] y
b (B) [N/y/?] (NEW)
To detect this correctly, sym_check_expr_deps() should recurse to
not only sym->rev_dep.expr but also sym->implied.expr .
At this moment, sym_check_print_recursive() cannot distinguish
'select' and 'imply' since it does not know the precise context
where the recursive dependency has been hit. This will be solved
by the next commit.
In fact, even the document and the unit-test are confused. Using
'imply' does not solve recursive dependency since 'imply' addresses
the unmet direct dependency, which 'select' could cause.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Wed, 15 Aug 2018 05:59:43 +0000 (14:59 +0900)]
kconfig: error out when seeing recursive dependency
Originally, recursive dependency was a fatal error for Kconfig
because Kconfig cannot compute symbol values in such a situation.
Commit
d595cea62403 ("kconfig: print more info when we see a recursive
dependency") changed it to a warning, which I guess was not intentional.
Get it back to an error again.
Also, rename the unit test directory "warn_recursive_dep" to
"err_recursive_dep" so that it matches to the behavior.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Tested-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 13 Aug 2018 16:48:39 +0000 (01:48 +0900)]
kconfig: remove P_ENV property type
This property is not set by anyone since commit
104daea149c4 ("kconfig:
reference environment variables directly and remove 'option env='").
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 13 Aug 2018 16:48:38 +0000 (01:48 +0900)]
kconfig: remove unused sym_get_env_prop() function
This function is unused since commit
104daea149c4 ("kconfig: reference
environment variables directly and remove 'option env='").
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 9 Aug 2018 06:47:06 +0000 (15:47 +0900)]
kconfig: fix the rule of mainmenu_stmt symbol
The rule of mainmenu_stmt does not have debug print of zconf_lineno(),
but if it had, it would print a wrong line number for the same reason
as commit
b2d00d7c61c8 ("kconfig: fix line numbers for if-entries in
menu tree").
The mainmenu_stmt does not need to eat following empty lines because
they are reduced to common_stmt.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 20 Jul 2018 07:46:31 +0000 (16:46 +0900)]
kconfig: allow all config targets to write auto.conf if missing
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 20 Jul 2018 07:46:30 +0000 (16:46 +0900)]
kconfig: make syncconfig update .config regardless of sym_change_count
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 20 Jul 2018 07:46:29 +0000 (16:46 +0900)]
kconfig: create directories needed for syncconfig by itself
'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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 20 Jul 2018 07:46:27 +0000 (16:46 +0900)]
kconfig: split out useful helpers in confdata.c
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Fri, 20 Jul 2018 07:46:26 +0000 (16:46 +0900)]
kconfig: rename file_write_dep and move it to confdata.c
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Thu, 5 Jul 2018 02:46:12 +0000 (11:46 +0900)]
kconfig: handle format string before calling conf_message_callback()
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: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Dirk Gouders [Tue, 3 Jul 2018 12:43:31 +0000 (14:43 +0200)]
kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE
Over time, the use of the flag SYMBOL_AUTO changed from initially
marking three automatically generated symbols ARCH, KERNELRELEASE and
UNAME_RELEASE to today's effect of protecting symbols from being
written out.
Currently, only symbols of type CHOICE and those with option
defconf_list set have that flag set.
Reflect that change in semantics in the flag's name.
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Jerry James [Sat, 23 Jun 2018 20:49:04 +0000 (22:49 +0200)]
kconfig: loop boundary condition fix
If buf[-1] just happens to hold the byte 0x0A, then nread can wrap around
to (size_t)-1, leading to invalid memory accesses.
This has caused segmentation faults when trying to build the latest
kernel snapshots for i686 in Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=
1592374
Signed-off-by: Jerry James <loganjerry@gmail.com>
[alexpl@fedoraproject.org: reformatted patch for submission]
Signed-off-by: Alexander Ploumistos <alexpl@fedoraproject.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Dirk Gouders [Fri, 22 Jun 2018 19:27:38 +0000 (21:27 +0200)]
kconfig: handle P_SYMBOL in print_symbol()
Each symbol has a property of type P_SYMBOL since commit
59e89e3ddf85 (kconfig: save location of config symbols).
Handle those properties in print_symbol().
Further, place a pointer to print_symbol() in the comment above the
list of known property type.
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Dirk Gouders [Thu, 21 Jun 2018 13:30:54 +0000 (15:30 +0200)]
kconfig: fix line numbers for if-entries in menu tree
The line numers for if-entries in the menu tree are off by one or more
lines which is confusing when debugging for correctness of unrelated changes.
According to the git log, commit
a02f0570ae201c49 (kconfig: improve
error handling in the parser) was the last one that changed that part
of the parser and replaced
"if_entry: T_IF expr T_EOL"
by
"if_entry: T_IF expr nl"
but the commit message does not state why this has been done.
When reverting that part of the commit, only the line numers are
corrected (checked with cdebug = DEBUG_PARSE in zconf.y), otherwise
the menu tree remains unchanged (checked with zconfdump() enabled in
conf.c).
An example for the corrected line numbers:
drivers/soc/Kconfig:15:source drivers/soc/tegra/Kconfig
drivers/soc/tegra/Kconfig:4:if
drivers/soc/tegra/Kconfig:6:if
changes to:
drivers/soc/Kconfig:15:source drivers/soc/tegra/Kconfig
drivers/soc/tegra/Kconfig:1:if
drivers/soc/tegra/Kconfig:4:if
Signed-off-by: Dirk Gouders <dirk@gouders.net>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Nathan Chancellor [Sat, 2 Jun 2018 16:02:09 +0000 (09:02 -0700)]
kconfig: Avoid format overflow warning from GCC 8.1
In file included from scripts/kconfig/zconf.tab.c:2485:
scripts/kconfig/confdata.c: In function ‘conf_write’:
scripts/kconfig/confdata.c:773:22: warning: ‘%s’ directive writing likely 7 or more bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
sprintf(newname, "%s%s", dirname, basename);
^~
scripts/kconfig/confdata.c:773:19: note: assuming directive output of 7 bytes
sprintf(newname, "%s%s", dirname, basename);
^~~~~~
scripts/kconfig/confdata.c:773:2: note: ‘sprintf’ output 1 or more bytes (assuming 4104) into a destination of size 4097
sprintf(newname, "%s%s", dirname, basename);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/kconfig/confdata.c:776:23: warning: ‘.tmpconfig.’ directive writing 11 bytes into a region of size between 1 and 4097 [-Wformat-overflow=]
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
^~~~~~~~~~~
scripts/kconfig/confdata.c:776:3: note: ‘sprintf’ output between 13 and 4119 bytes into a destination of size 4097
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Increase the size of tmpname and newname to make GCC happy.
Cc: stable@vger.kernel.org
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:55 +0000 (18:21 +0900)]
kconfig: error out if a recursive variable references itself
When using a recursively expanded variable, it is a common mistake
to make circular reference.
For example, Make terminates the following code:
X = $(X)
Y := $(X)
Let's detect the circular expansion in Kconfig, too.
On the other hand, a function that recurses itself is a commonly-used
programming technique. So, Make does not check recursion in the
reference with 'call'. For example, the following code continues
running eternally:
X = $(call X)
Y := $(X)
Kconfig allows circular expansion if one or more arguments are given,
but terminates when the same function is recursively invoked 1000 times,
assuming it is a programming mistake.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:54 +0000 (18:21 +0900)]
kconfig: add 'filename' and 'lineno' built-in variables
The special variables, $(filename) and $(lineno), are expanded to a
file name and its line number being parsed, respectively.
Suggested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:53 +0000 (18:21 +0900)]
kconfig: add 'info', 'warning-if', and 'error-if' built-in functions
Syntax:
$(info,<text>)
$(warning-if,<condition>,<text>)
$(error-if,<condition>,<text)
The 'info' function prints a message to stdout as in Make.
The 'warning-if' and 'error-if' are similar to 'warning' and 'error'
in Make, but take the condition parameter. They are effective only
when the <condition> part is y.
Kconfig does not implement the lazy expansion as used in the 'if'
'and, 'or' functions in Make. In other words, Kconfig does not
support conditional expansion. The unconditional 'error' function
would always terminate the parsing, hence would be useless in Kconfig.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:52 +0000 (18:21 +0900)]
kconfig: expand lefthand side of assignment statement
Make expands the lefthand side of assignment statements. In fact,
Kbuild relies on it since kernel makefiles mostly look like this:
obj-$(CONFIG_FOO) += foo.o
Do likewise in Kconfig.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:51 +0000 (18:21 +0900)]
kconfig: support append assignment operator
Support += operator. This appends a space and the text on the
righthand side to a variable.
The timing of the evaluation of the righthand side depends on the
flavor of the variable. If the lefthand side was originally defined
as a simple variable, the righthand side is expanded immediately.
Otherwise, the expansion is deferred. Appending something to an
undefined variable results in a recursive variable.
To implement this, we need to remember the flavor of variables.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:50 +0000 (18:21 +0900)]
kconfig: support simply expanded variable
The previous commit added variable and user-defined function. They
work similarly in the sense that the evaluation is deferred until
they are used.
This commit adds another type of variable, simply expanded variable,
as we see in Make.
The := operator defines a simply expanded variable, expanding the
righthand side immediately. This works like traditional programming
language variables.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:49 +0000 (18:21 +0900)]
kconfig: support user-defined function and recursively expanded variable
Now, we got a basic ability to test compiler capability in Kconfig.
config CC_HAS_STACKPROTECTOR
def_bool $(shell,($(CC) -Werror -fstack-protector -E -x c /dev/null -o /dev/null 2>/dev/null) && echo y || echo n)
This works, but it is ugly to repeat this long boilerplate.
We want to describe like this:
config CC_HAS_STACKPROTECTOR
bool
default $(cc-option,-fstack-protector)
It is straight-forward to add a new function, but I do not like to
hard-code specialized functions like that. Hence, here is another
feature, user-defined function. This works as a textual shorthand
with parameterization.
A user-defined function is defined by using the = operator, and can
be referenced in the same way as built-in functions. A user-defined
function in Make is referenced like $(call my-func,arg1,arg2), but I
omitted the 'call' to make the syntax shorter.
The definition of a user-defined function contains $(1), $(2), etc.
in its body to reference the parameters. It is grammatically valid
to pass more or fewer arguments when calling it. We already exploit
this feature in our makefiles; scripts/Kbuild.include defines cc-option
which takes two arguments at most, but most of the callers pass only
one argument.
By the way, a variable is supported as a subset of this feature since
a variable is "a user-defined function with zero argument". In this
context, I mean "variable" as recursively expanded variable. I will
add a different flavored variable in the next commit.
The code above can be written as follows:
[Example Code]
success = $(shell,($(1)) >/dev/null 2>&1 && echo y || echo n)
cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
config CC_HAS_STACKPROTECTOR
def_bool $(cc-option,-fstack-protector)
[Result]
$ make -s alldefconfig && tail -n 1 .config
CONFIG_CC_HAS_STACKPROTECTOR=y
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:48 +0000 (18:21 +0900)]
kconfig: begin PARAM state only when seeing a command keyword
Currently, any statement line starts with a keyword with TF_COMMAND
flag. So, the following three lines are dead code.
alloc_string(yytext, yyleng);
zconflval.string = text;
return T_WORD;
If a T_WORD token is returned in this context, it will cause syntax
error in the parser anyway.
The next commit will support the assignment statement where a line
starts with an arbitrary identifier. So, I want the lexer to switch
to the PARAM state only when it sees a command keyword.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:46 +0000 (18:21 +0900)]
kconfig: add 'shell' built-in function
This accepts a single command to execute. It returns the standard
output from it.
[Example code]
config HELLO
string
default "$(shell,echo hello world)"
config Y
def_bool $(shell,echo y)
[Result]
$ make -s alldefconfig && tail -n 2 .config
CONFIG_HELLO="hello world"
CONFIG_Y=y
Caveat:
Like environments, functions are expanded in the lexer. You cannot
pass symbols to function arguments. This is a limitation to simplify
the implementation. I want to avoid the dynamic function evaluation,
which would introduce much more complexity.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
Masahiro Yamada [Mon, 28 May 2018 09:21:45 +0000 (18:21 +0900)]
kconfig: add built-in function support
This commit adds a new concept 'function' to do more text processing
in Kconfig.
A function call looks like this:
$(function,arg1,arg2,arg3,...)
This commit adds the basic infrastructure to expand functions.
Change the text expansion helpers to take arguments.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>