Open mloskot opened 5 years ago
The compiler implicitly runs the cxx.makedep
action to collect header dependencies. That action doesn't use the cxxflags
variable, as it is only preprocessing. So, arguably, the "-std=c++11" should be a preprocessor flag, rather than a compiler switch. Or perhaps it needs to be both.
Can you try running faber cppflags=-std=c++11 cxxflags=-std=c++11 test.pixel
?
(Both the cxxflags
and cppflags
features are provided as a backdoor, so you can pass compiler- and platform-specific flags through. The portable way to express the language level is cxxstd=11
, but I see that this, too, isn't forwarded to the cxx.makedep
action, so you have clearly uncovered a bug.)
$ faber --version
Faber version 0.3.post6+93ab4c9d
(.env) mloskot@bionic:/mnt/d/boost.wsl/libs/gil$ faber --log=commands cppflags=-std=c++11 cxxflags=-std=c++11 test.pixel
g++ -std=c++11 -DBOOST_ALL_NO_LIB -Iinclude -MM -o test/g++-5.5.0/x86_64/pixel.d ./test/pixel.cpp
g++ -std=c++11 -DBOOST_ALL_NO_LIB -Iinclude -std=c++11 -m64 -c -o test/g++-5.5.0/x86_64/error_if.o ./test/error_if.cpp
(.env) mloskot@bionic:/mnt/d/boost.wsl/libs/gil$ faber cppflags=-std=c++11 cxxflags=-std=c++11 test.pixel
gxx.makedep test.pixel.d
In file included from include/boost/gil/pixel.hpp:12:0,
from include/boost/gil/bit_aligned_pixel_reference.hpp:11,
from include/boost/gil/bit_aligned_pixel_iterator.hpp:11,
from include/boost/gil/algorithm.hpp:11,
from include/boost/gil.hpp:12,
from ./test/pixel.cpp:8:
include/boost/gil/color_base.hpp:62:21: error: missing binary operator before token "("
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
^
include/boost/gil/color_base.hpp:326:21: error: missing binary operator before token "("
#if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
^
In file included from include/boost/gil.hpp:24:0,
from ./test/pixel.cpp:8:
include/boost/gil/planar_pixel_reference.hpp:77:21: error: missing binary operator before token "("
#if BOOST_WORKAROUND(__HP_aCC, >= 61700) || BOOST_WORKAROUND(__INTEL_COMPILER, >= 1000)
^
...skipped test/g++-5.5.0/x86_64/pixel.o for lack of test/g++-5.5.0/x86_64/pixel.d...
gxx.compile test.error_if.o
...skipped test/g++-5.5.0/x86_64/pixel for lack of test/g++-5.5.0/x86_64/pixel.o...
...skipped test.pixel for lack of test/g++-5.5.0/x86_64/pixel...
test.pixel: FAIL
...failed updating 1 artefact...
...updated 1 artefact...
I have seen that error before, but I'm not sure what it is. One likely issue is that you didn't explicitly specify the Boost header search path, and the default (likely system installation) might be too old.
Can you try adding --with-boost-prefix=/your/boost/installation
(or --with-boost-include
etc.) ? These --with-...
flags are sort of passed through, and this one is handled in https://github.com/boostorg/gil/blob/develop/fabscript#L17
Looks like we are on the right track, getting closer and closer:
$ faber --with-boost-include=/mnt/d/boost.wsl test.pixel
gxx.makedep test.pixel.d
In file included from /usr/include/c++/5/cstdint:35:0,
from include/boost/gil/channel.hpp:19,
from include/boost/gil/pixel.hpp:11,
from include/boost/gil/bit_aligned_pixel_reference.hpp:11,
from include/boost/gil/bit_aligned_pixel_iterator.hpp:11,
from include/boost/gil/algorithm.hpp:11,
from include/boost/gil.hpp:12,
from ./test/pixel.cpp:8:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support \
^
...skipped test/g++-5.5.0/x86_64/pixel.o for lack of test/g++-5.5.0/x86_64/pixel.d...
gxx.compile test.error_if.o
...skipped test/g++-5.5.0/x86_64/pixel for lack of test/g++-5.5.0/x86_64/pixel.o...
...skipped test.pixel for lack of test/g++-5.5.0/x86_64/pixel...
test.pixel: FAIL
...failed updating 1 artefact...
...updated 1 artefact...
$ faber cppflags=-std=c++11 cxxflags=-std=c++11 --with-boost-include=/mnt/d/boost.wsl test.pixel
gxx.makedep test.pixel.d
gxx.compile test.pixel.o
gxx.compile test.error_if.o
gxx.link test.pixel
/usr/bin/ld: cannot find -lboost_filesystem
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
...skipped test.pixel for lack of test/g++-5.5.0/x86_64/pixel...
test.pixel: FAIL
...failed updating 1 artefact...
...updated 3 artefacts...
$ faber cppflags=-std=c++11 cxxflags=-std=c++11 --with-boost-include=/mnt/d/boost.wsl --with-boost-lib=/mnt/d/boost.wsl/stage/lib test.pixel
override existing options ? [y/N]:y
gxx.compile test.pixel.o
gxx.compile test.error_if.o
gxx.link test.pixel
test.pixel: PASS
...updated 3 artefacts...
So, my BOOST_ROOT
is /mnt/d/boost.wsl
but it is stage
folder/build, no Boost installed.''
I somewhat assumed the Boost default location is configured in fabscript
, since libs/gil
is inside the actual Boost tree.
Very nice ! No, I deliberately refrained from using any default, as my normal use-case is to build libraries out-of-tree. Given that this is all Python code, it's certainly possible to compute the default assuming this is in-tree, or checking whether it is in-tree and then setting the default accordingly.
No problem, as long as I know what command line arguments to use :)
To summary, AFAIU, since GIL requires C++11, I should be able to build with just this:
faber -with-boost-include=/mnt/d/boost.wsl --with-boost-lib=/mnt/d/boost.wsl/stage/lib test.pixel
that is, without need to specfiy the C++ version in command line. Correct?
As long as the default compiler found by faber
supports C++11, yes. If not, faber
supports the same mechanism as bjam
to add custom tools into a global config file (~/.faber
by default, plus <srcdir>/.faber
for project-specific settings), and then select among them using cxx.name=your-compiler-here
.
But, can we have -std=c++11
defaulted/forced in fabscript
?
Yeah, surely. It's a bit tricky, though, for once, because some compilers such as MSVC still don't qualify as C++11 (in the strict sense that they don't define __cplusplus = 201103L
), so we'd need to use some other config checks to determine whether a given compiler qualifies or not.
Configuration
Using the fabscripts in the current Boost.GIL
develop
:Problem
Since GIL requires C++11, but fabscripts do not specify the required language version, I follow the example
https://github.com/stefanseefeld/faber/blob/737784418ce7628077094dd852ea7007bbe5e470/examples/config/fabscript#L16
running
faber cxxflags=-std=c++11
:The commands logging
suggest,
-std=c++11
is missing from the command line compilingpixel.cpp
.Questions
C++11
requirement should be specified? Top-levelfabscript
like thisfeatures += include('-std=c++11')
?features=cxxflags('--std=c++11')
and other examples? Is it Faber thing or a typo and it should read-std=c++11
?