[build2] [bug] Targets not built if not used by the first target appearing in a buildfile

Klaim - Joël Lamotte mjklaim at gmail.com
Fri Mar 23 20:55:08 UTC 2018


(b and bpkg versions at the end of this email)
Repro sources:
https://klaimsden.net/temp/jlamotte-build2-bugreport-fail-build-all-targets.zip
Windows 10 64bit - VS2017 15.6.x

When building the following buildfile scripts separately (after a "clean")
I observe that only case B builds all the library and exe targets (also
tested with shared libs).
With all other cases there is no error. The build just stops after the
first target and there is no mention of the others. (I suspect that syntax
issues appearing after the first library/exe
target in the buildfile  were also ignored,
so maybe it's just the lexer that stops too early.)

The only condition I found so far to trigger this problem is to not
use/refer-to the other
targets in the first exe or library target appearing in the file.
If any library is used by the first exe/lib target, it will be built.

My understanding so far was that the target name order is not important for
build2.
Looking at the build2 repo I realized before that it might not be important
(like in make?).

Even if my assumption is incorrect, not building declared targets looks
like a real bug.
In particular for packages that are only a set of libraries.

Its easy to reproduce this with dummy files, the repro sources are just
setup for that.
I don't now how exactly but maybe they can be setup as unit tests.

A. Joël Lamotte

-------------------------------------------------------------------------------

Case B output (as expected):

PS E:\Tests\build2-experiment> bpkg build .\fail_build_all_libs\ -d
.\whoops\
c++ fail_build_all_libs\cxx{y}@whoops\fail_build_all_libs\
c++ fail_build_all_libs\cxx{app_linking}@whoops\fail_build_all_libs\
c++ fail_build_all_libs\cxx{x}@whoops\fail_build_all_libs\
c++ fail_build_all_libs\cxx{z}@whoops\fail_build_all_libs\
ld whoops\fail_build_all_libs\liba{lib_x}
ld whoops\fail_build_all_libs\liba{lib_y}
ld whoops\fail_build_all_libs\liba{lib_z}
ld whoops\fail_build_all_libs\exe{app}
updated fail_build_all_libs/0.1.0

Case A output (not expected):

PS E:\Tests\build2-experiment> bpkg build .\fail_build_all_libs\ -d
.\whoops\ -v
E:\tools\build2\build2-install\bin\b -v info: .\fail_build_all_libs\
E:\tools\build2\build2-install\bin\b -v
update('.\whoops\fail_build_all_libs\')
cl /std:c++latest /D__cpp_modules=201704 /experimental:module /nologo /EHsc
/MD /Fo: whoops\fail_build_all_libs\x.lib.obj /c /TP
E:\Tests\build2-experiment\fail_build_all_libs\x.cpp
lib /NOLOGO /MACHINE:x64 /OUT:whoops\fail_build_all_libs\lib_x.lib
whoops\fail_build_all_libs\x.lib.obj
updated fail_build_all_libs/0.1.0



-------------------------------------------------------------------------------
# buildfile cases:

#####################################################
## A. The following stops building after the first target:

# OK:built
liba{lib_x}: cxx{x}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# ISSUE: not built?
liba{lib_z}: cxx{z}

# ISSUE: not built?
exe{app} : cxx{app_linking} liba{lib_x} liba{lib_y} liba{lib_z}

####################################################
## B. The following works as expected, compiles everything:

# OK:built
exe{app} : cxx{app_linking} liba{lib_x} liba{lib_y} liba{lib_z}

# OK:built
liba{lib_x}: cxx{x}

# OK:built
liba{lib_y}: cxx{y}

# OK:built
liba{lib_z}: cxx{z}

###################################################
## C. Stops at the first target, whatever the order:

# OK:built
liba{lib_z}: cxx{z}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# ISSUE: not built?
liba{lib_x}: cxx{x}

# ISSUE: not built?
exe{app} : cxx{app_linking} liba{lib_x} liba{lib_y} liba{lib_z}

##################################################
# D. Stops at the first target, whatever the target type (same with shared
libraries):

# OK:built
exe{app_1}: cxx{app_standalone}

# ISSUE: not built?
exe{app_2}: cxx{app_standalone}

# ISSUE: not built?
exe{app_3}: cxx{app_standalone}


###################################################
## E. Stops at the first target if not used by the first target:

# OK:built
exe{app} : cxx{app_standalone}

# ISSUE: not built?
liba{lib_x}: cxx{x}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# ISSUE: not built?
liba{lib_z}: cxx{z}

###################################################
## F Only build targets used by the first one:

# OK:built
exe{app} : cxx{app_standalone} liba{lib_x}

# OK:built
liba{lib_x}: cxx{x}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# ISSUE: not built?
liba{lib_z}: cxx{z}


###################################################
## G Only build targets used by the first one:

# OK:built
exe{app} : cxx{app_standalone} liba{lib_z}

# ISSUE: not built?
liba{lib_x}: cxx{x}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# OK:built
liba{lib_z}: cxx{z}

###################################################
## H Only build targets recursively used by the first one:

# OK:built
exe{app} : cxx{app_standalone} liba{lib_z}

# OK:built
liba{lib_x}: cxx{x}

# ISSUE: not built?
liba{lib_y}: cxx{y}

# OK:built
liba{lib_z}: cxx{z} lib{lib_x}


###################################################
## I Only build targets used by the first one:

# OK:built
liba{lib_x}: cxx{x} liba{lib_y}

# OK:built
liba{lib_y}: cxx{y} liba{lib_z}

# OK:built
liba{lib_z}: cxx{z}

# ISSUE: not built?
exe{app} : cxx{app_standalone} liba{lib_x}




--------------------------------------------------------------------------------



PS E:\Tests\build2-experiment> bpkg --version
bpkg 0.7.0-a.0.d6e7058475ee
libbpkg 0.7.0-a.0.f8bee7e57187
libbutl 0.7.0-a.0.26efe301f4a7
Copyright (c) 2014-2017 Code Synthesis Ltd
This is free software released under the MIT license.

PS E:\Tests\build2-experiment> b --version
build2 0.7.0-a.0.903eeb2c681f
libbutl 0.7.0-a.0.26efe301f4a7
host x86_64-microsoft-win32-msvc14.1
Copyright (c) 2014-2017 Code Synthesis Ltd
This is free software released under the MIT license.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.build2.org/archives/users/attachments/20180323/ead11b4d/attachment-0001.html>


More information about the users mailing list