[build2] Kconfig support in build2

Matthew Krupcale mkrupcale at matthewkrupcale.com
Wed Jan 27 14:35:24 UTC 2021


On Wed, Jan 27, 2021 at 5:34 AM Boris Kolpackov <boris at codesynthesis.com> wrote:
>
> A build system module must not be built in the same build configuration
> as a project that loads it (libbuild2-kconfig-tests in this case). What
> happens in this case is that the module is updated in two build contexts
> as part of the the same build system invocation, which is, to borrow a
> C++ term, UB-NDR (undefined behavior, no diagnostics required). See class
> context[1] for details.
>
> The way I would arrange this build is along these lines:
>
> /usr/bin/b [...] libbuild2-kconfig/
>
> /usr/bin/b [...] libbuild2-kconfig-tests/ \
> '!config.import.libbuild2_kconfig=libbuild2-kconfig/'

Unfortunately this actually results in three separate builds. What
happens in this case is that it
 1. builds libbuild2-kconfig first with the correct config.* options
 2. update: libbuild2-kconfig-tests/ then rebuilds libbuild2-kconfig
without the CLI config.* options (i.e. only using the buildfile
options)
 3. install: libbuild2-kconfig/ rebuilds libbuild2-kconfig again with
the correct config.* options
This third rebuild did not happen in the method I used since steps 1
and 2 were reversed, resulting in the correct libbuild2-kconfig build
before install. So steps 1 and 2 using the two different methods look
like:

# # method 1 (my original attempt)
# eval b -v "$build_config"
libbuild2-kconfig-0.1.0-a.0.20210108084836.3687e4b95226/
libbuild2-kconfig-tests-0.1.0-a.0.20210108084836.3687e4b95226/
'!config.import.libbuild2_kconfig=libbuild2-kconfig-0.1.0-a.0.20210108084836.3687e4b95226/'
gcc -I[...] -D[...] -Wno-extra -Wno-error -fPIC -o
[...]/lexer.lex.so.o -c -x c [...]/lexer.lex.c
...
gcc -I[...] -D[...] [config.c.coptions] -Wno-extra -Wno-error -fPIC -o
[...]/lexer.lex.so.o -c -x c [...]/lexer.lex.c
...
info: dir{libbuild2-kconfig-tests-0.1.0-a.0.20210108084836.3687e4b95226/}
is up to date

# # method 2 (your proposed method)
# eval b -v "$build_config"
libbuild2-kconfig-0.1.0-a.0.20210108084836.3687e4b95226/
gcc -I[...] -D[...] [config.c.coptions] -Wno-extra -Wno-error -fPIC -o
[...]/lexer.lex.so.o -c -x c [...]/lexer.lex.c
# eval b -v "$build_config"
libbuild2-kconfig-tests-0.1.0-a.0.20210108084836.3687e4b95226/
'!config.import.libbuild2_kconfig=libbuild2-kconfig-0.1.0-a.0.20210108084836.3687e4b95226/'
gcc -I[...] -D[...] -Wno-extra -Wno-error -fPIC -o
[...]/lexer.lex.so.o -c -x c [...]/lexer.lex.c
...
info: dir{libbuild2-kconfig-tests-0.1.0-a.0.20210108084836.3687e4b95226/}
is up to date

where [config.c.coptions] are the config.* options in $build_config.

I suppose I could just get rid of step 1 in method 2, and then only
step 3 will build libbuild2-kconfig with the correct config.* options.
Is this the correct way to avoid UB for build2? Is there a way to
avoid two builds (once with only buildfile options & once additionally
with config.* options, in that order)?



More information about the users mailing list