Boost C++ Libraries: Ticket #9704: b2: Compiler flavour has no flexibility for cross-compiling projects. https://svn.boost.org/trac10/ticket/9704 <p> Hi, </p> <p> I've been trying hard, but it is annoying, didn't find it elsewhere and it could really be improved. </p> <p> I am building my project (i.e. all of my project tree) </p> <blockquote> <p> on 2 platforms: </p> </blockquote> <ul><li>Windows, </li><li>Linux, </li></ul><p> for 3 different platforms: </p> <ul><li>Windows </li><li>Linux IA32 </li><li>Linux ARM HF </li></ul><p> Now, whilst b2 subsystem is quite flexible in specifying different types of compilers, it is not so much when using the same type of compiler, but using different versions of it. </p> <p> I have managed to define it somehow, i.e. in my project_config.jam (@ home dir): </p> <pre class="wiki">if [ os.name ] = NT { using gcc : : : &lt;cxxflags&gt;-std=c++11 &lt;cxxflags&gt;"-include cmath" &lt;cxxflags&gt;-Wdeprecated-declarations ; using gcc : armhf : arm-linux-gnueabihf-g++.exe : &lt;cxxflags&gt;-std=c++11 &lt;cxxflags&gt;"-include cmath" &lt;cxxflags&gt;-Wdeprecated-declarations ; } if [ os.name ] = LINUX { using gcc : : : &lt;cxxflags&gt;-std=c++11 &lt;cxxflags&gt;"-include cmath" ; using gcc : armhf : /usr/bin/arm-linux-gnueabihf-g++ : &lt;cxxflags&gt;-std=c++11 &lt;cxxflags&gt;"-include cmath" &lt;cxxflags&gt;-Wdeprecated-declarations ; } </pre><p> But now, in every sub-project, where I'm moving files to a 'release' location, (* and whenever I need to specify copmiler-flavor specific configuration) I need to perform something like: </p> <pre class="wiki">install copy_binaries_to_release : target_names.. : &lt;target-os&gt;linux:&lt;toolset-gcc:version&gt;4.7:&lt;location&gt;../../release/ &lt;target-os&gt;windows:&lt;toolset&gt;gcc-4.7.2-mingw:&lt;location&gt;../../release/ &lt;toolset-gcc:version&gt;armhf:&lt;location&gt;../../release_armhf/ &lt;toolset&gt;gcc-mingw-armhf:&lt;location&gt;../../release/ ; </pre><p> Is there a better way of doing it? </p> <p> If not, then the problem (and I guess a bug) is that b2 behaves differently on different platforms, somewhat lacks of mechanism to support what I need to do (and it's not really very uncommon). </p> <p> Problems: </p> <ol><li>Different toolset names when building on different OSes (and yes, I did try to specify a default flavor, but see Problem 2). </li></ol><table class="wiki"> <tr><td style="text-align: center"> </td><td> command </td><td> toolset </td><td> flavor </td></tr><tr><td> gcc XA32(linux) </td><td> b2 </td><td> gcc </td><td> 4.7 </td></tr><tr><td> gcc XA32(win) </td><td> b2 </td><td> gcc-4.7.2-mingw </td><td> ? </td></tr><tr><td> <strong>gcc armhf(linux)</strong> </td><td> <strong>b2 --toolset=gcc-armhf</strong> </td><td> <strong>gcc</strong> </td><td> <strong>armhf</strong> </td></tr><tr><td> gcc armhf(win) </td><td> b2 --toolset=gcc-armhf target-os=linux </td><td> gcc-mingw-armhf </td><td> ? </td></tr></table> <p> Only gcc-armhf seems to achieve requested results. BUt the main issue it, that it is all different on different platforms, and both: armhf should produce compatible binaries. </p> <p> BTW: is there really a need to distinguish between e.g. Cygwin and MinGW flavours if they produce the same target with the same version of compiler? If one builds from Cygwin and MinGW for the same platform: resulting executables should be compatible for the same target, so only in 'bin' build directory they can really be different (if needed), but it is unlikely that one builds both of them (target:gcc version) at the same time (like it is unlikely that I build under windows and linux at the same time). </p> <ol start="2"><li>It is not possible to specify a flavor for GCC (by explicitly giving it a name and compiler location) - because b2 is performing a version check. This check either fails, or if it does not (and default version is used) - automatic build-platform-specific flavor value is created behind the control) - probably because b2 is trying to be too clever at this. </li></ol><p> Couldn't it leave it alone, and use flavor that was explicitly specified? </p> <p> I really wish that I could specify above: </p> <pre class="wiki">using gcc : 4.7 : &lt;my-path-to-gcc47&gt; ... ; using gcc : armhf : &lt;my-path-to-gcc47 arm hf&gt; ... ; </pre><p> and wouldn't have to create links or worry about the build system changing/ coming up with a flavor by concatenating target name (e.g. on </p> <pre class="wiki">b2 --toolset=gcc-armhf </pre><p> with g++ (and having to hack/create symlinks to match this etc.) - </p> <p> It should just accept what I specify, and use it 'as-is' (and if someone does something stupid - let them fail and fix it). </p> <p> There could also be a support for something like: </p> <pre class="wiki">import toolset ; if [ toolset.name ] == gcc { if [ toolset.flavor ] == flav_1 { } } # and my verbosive Jamfiles could be re-written to something like: local gcc_flavor = [ toolset.flavor ] ; install copy_binaries_to_release : target_names.. : &lt;toolset&gt;gcc,&lt;flavor&gt;4.7:&lt;location&gt;../../release &lt;toolset&gt;gcc,&lt;flavor&gt;armhf:&lt;location&gt;../../release_$(gcc_flavor) # or even to: &lt;toolset&gt;gcc:&lt;location&gt;../../release_$(gcc_flavor) ; </pre><p> With a bit of guidance / advice from someone, who knows the build system well - I'm happy to help with implementing the above. </p> <p> Thanks, LUkasz. </p> <p> (BTW: what is the best component for build system / tools?) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9704 Trac 1.4.3 Steven Watanabe Fri, 04 Apr 2014 19:59:29 GMT status, component changed; owner set https://svn.boost.org/trac10/ticket/9704#comment:1 https://svn.boost.org/trac10/ticket/9704#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Steven Watanabe</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>component</strong> <span class="trac-field-old">Building Boost</span> → <span class="trac-field-new">build</span> </li> </ul> <p> Regarding (2), I believe that this used to work. If it's broken, it's probably to try to support uses that set flags for specific versions of gcc, which need the real gcc version number rather than some arbitrary identifier. I'll look into this. </p> <p> P.S. The correct component for Boost.Build is "build". "Building Boost" is for issues when building the Boost C++ libraries. It's often ambiguous, though and if you use the wrong component it doesn't matter much, since the same people are responsible for both, and we can reassign it if needed. </p> Ticket Steven Watanabe Fri, 04 Apr 2014 21:09:39 GMT <link>https://svn.boost.org/trac10/ticket/9704#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9704#comment:2</guid> <description> <p> Replying to <a class="assigned ticket" href="https://svn.boost.org/trac10/ticket/9704" title="#9704: Bugs: b2: Compiler flavour has no flexibility for cross-compiling projects. (assigned)">lukasz.forynski@…</a>: </p> <blockquote class="citation"> <pre class="wiki">import toolset ; if [ toolset.name ] == gcc { if [ toolset.flavor ] == flav_1 { } } &lt;snip&gt; </pre></blockquote> <p> This is fundamentally impossible in Boost.Build. The main reason being that there is no such thing as the value of a feature in a Jamfile. See <a href="http://www.boost.org/boost-build2/doc/html/bbv2/faq.html#bbv2.faq.featurevalue">http://www.boost.org/boost-build2/doc/html/bbv2/faq.html#bbv2.faq.featurevalue</a> </p> <p> You would need to write this using a conditional </p> <pre class="wiki">import feature ; rule calculate-install-dir ( properties * ) { local gcc-version = [ feature.get-values &lt;toolset-gcc:version&gt; : $(properties) ] ; return &lt;location&gt;../../release_$(gcc-version) ; } install copy_binaries_to_release : # target names : &lt;conditional&gt;@calculate-install-dir ; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 04 Apr 2014 22:13:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9704#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9704#comment:3</guid> <description> <p> Replying to <a class="assigned ticket" href="https://svn.boost.org/trac10/ticket/9704" title="#9704: Bugs: b2: Compiler flavour has no flexibility for cross-compiling projects. (assigned)">lukasz.forynski@…</a>: </p> <blockquote class="citation"> <p> Problems: </p> <ol><li>Different toolset names when building on different OSes (and yes, I did try to specify a default flavor, but see Problem 2). </li></ol><table class="wiki"> <tr><td style="text-align: center"> </td><td> command </td><td> toolset </td><td> flavor </td></tr><tr><td> gcc XA32(linux) </td><td> b2 </td><td> gcc </td><td> 4.7 </td></tr><tr><td> gcc XA32(win) </td><td> b2 </td><td> gcc-4.7.2-mingw </td><td> ? </td></tr><tr><td> <strong>gcc armhf(linux)</strong> </td><td> <strong>b2 --toolset=gcc-armhf</strong> </td><td> <strong>gcc</strong> </td><td> <strong>armhf</strong> </td></tr><tr><td> gcc armhf(win) </td><td> b2 --toolset=gcc-armhf target-os=linux </td><td> gcc-mingw-armhf </td><td> ? </td></tr></table> <p> Only gcc-armhf seems to achieve requested results. BUt the main issue it, that it is all different on different platforms, and both: armhf should produce compatible binaries. </p> </blockquote> <p> I'm sorry. I don't understand this table. On line 1, gcc XA32(linux), the properties should be &lt;toolset&gt;gcc &lt;toolset-gcc:version&gt;4.7.2 On line 2, gcc XA32(win), they should be &lt;toolset&gt;gcc &lt;toolset-gcc:version&gt;4.7.2 &lt;toolset-gcc:flavor&gt;mingw. For lines 3-4, just replace 4.7.2 with armhf. I suppose my issue is that I don't see how you're deciding what is the toolset and what is the flavor. </p> <p> I've been trying several things and the only issue that I ran into using multiple versions of gcc (including a cross-compiler) is the old problem when mixing MinGW with other versions of gcc (All versions of gcc are tagged as mingw). </p> <p> Here's what I suggest. It seems to work for me with a combination of mingw-w64 and native gcc on linux. </p> <pre class="wiki">using gcc : 4.7.2 : g++ : &lt;flavor&gt;host ; using gcc : 4.8.0 : /usr/local/gcc-4.8.0/bin/g++ : &lt;flavor&gt;host ; using gcc : 4.7.2 : i686-w64-mingw32-g++ : &lt;flavor&gt;mingw ; </pre><p> Then you can access &lt;toolset-gcc:flavor&gt; to get the flavor. (Adjust the version number, path, and flavor for your environment. If you leave the version blank, it will be auto-deduced.) </p> <p> Running </p> <pre class="wiki"># Uses g++ b2 b2 gcc b2 gcc-4.7.2 b2 gcc-linux b2 gcc-linux-4.7.2 b2 gcc-4.7.2-linux # Uses GCC 4.8 b2 gcc-4.8.0 b2 gcc-4.8.0-linux # Uses MinGW g++ b2 gcc-4.7.2-mingw b2 gcc-mingw </pre><p> You have to be a little careful, since Boost.Build is not smart about filling in defaults. It's safest to specify just gcc, which will always take the first version initialized, or to specify the full gcc-version-flavor. (b2 gcc-mingw will break if you put gcc 4.8.0 first, since it becomes gcc-4.8.0-mingw, which doesn't exist.) </p> </description> <category>Ticket</category> </item> </channel> </rss>