Boost C++ Libraries: Ticket #12616: Cannot build boost 1.62 for x32 ABI https://svn.boost.org/trac10/ticket/12616 <p> To build boost for the X32 ABI (which is x86-64 but with 32-bit pointers) we set CFLAGS to -mx32. </p> <p> However boost then decides that it knows best and also passes in -march=i686 -m32. </p> <p> For example: </p> <pre class="wiki">| "x86_64-poky-linux-gnux32-g++" "-mx32" "-Wl,-O1" "-Wl,--hash-style=gnu" "-Wl,--as-needed" "--sysroot=/data/poky-master/tmp-glibc/sysroots/intel-corei7-64" -ftemplate-depth-128 -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/poky-master/tmp-glibc/work/x86_64_x32-poky-linux-gnux32/boost/1.62.0-r1=/usr/src/debug/boost/1.62.0-r1 -fdebug-prefix-map=/data/poky-master/tmp-glibc/sysroots/x86_64-linux= -fdebug-prefix-map=/data/poky-master/tmp-glibc/sysroots/intel-corei7-64= -fvisibility-inlines-hidden -O3 -finline-functions -Wno-inline -Wall -march=i686 -pthread -fPIC -m32 -DBOOST_ALL_NO_LIB=1 -DBOOST_FILESYSTEM_DYN_LINK=1 -DBOOST_SYSTEM_DYN_LINK=1 -DNDEBUG -I"." -c -o "/data/poky-master/tmp-glibc/work/x86_64_x32-poky-linux-gnux32/boost/1.62.0-r1/boost_1_62_0/x86_64-poky-linux-gnux32/boost/bin.v2/libs/filesystem/build/aca09349fdb84d131321425f6c3a38ed/windows_file_codecvt.o" "libs/filesystem/src/windows_file_codecvt.cpp" | | In file included from /data/poky-master/tmp-glibc/sysroots/intel-corei7-64/usr/include/features.h:392:0, | from /data/poky-master/tmp-glibc/sysroots/intel-corei7-64/usr/include/c++/6.2.0/x86_64-poky-linux-gnux32/bits/os_defines.h:39, | from /data/poky-master/tmp-glibc/sysroots/intel-corei7-64/usr/include/c++/6.2.0/x86_64-poky-linux-gnux32/bits/c++config.h:495, | from /data/poky-master/tmp-glibc/sysroots/intel-corei7-64/usr/include/c++/6.2.0/cstddef:49, | from ./boost/config/compiler/gcc.hpp:165, | from ./boost/config.hpp:39, | from ./boost/filesystem/config.hpp:28, | from libs/filesystem/src/windows_file_codecvt.cpp:20: | /data/poky-master/tmp-glibc/sysroots/intel-corei7-64/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: No such file or directory | # include &lt;gnu/stubs-32.h&gt; </pre><p> The -mx32 is our CFLAGS. -m32 -march=i686 is from boost/tools/build. The compiler ends up thinking that its doing a i686 build and tries to open stubs-32.h which doesn't exist as this sysroot is x32 so only stubs-x32.h is present. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12616 Trac 1.4.3 Kohei Takahashi Mon, 21 Nov 2016 12:57:05 GMT component changed https://svn.boost.org/trac10/ticket/12616#comment:1 https://svn.boost.org/trac10/ticket/12616#comment:1 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">Building Boost</span> </li> </ul> <p> Try following. </p> <ol><li>Append below codes to project-config.jam <pre class="wiki">module gcc { import toolset ; toolset.flags gcc OPTIONS &lt;architecture&gt;x86/&lt;address-model&gt;32_64 : "-mx32" ; } </pre></li><li>Run b2 with address-model feature. <pre class="wiki">$ ./b2 address-model=32_64 </pre></li></ol> Ticket ross@… Mon, 21 Nov 2016 13:38:44 GMT <link>https://svn.boost.org/trac10/ticket/12616#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12616#comment:2</guid> <description> <p> In an attempt to have less magic I added the flags line to gcc.jam in build: </p> <pre class="wiki">diff --git a/src/tools/gcc.py b/src/tools/gcc.py index 270ca97..f31f4ef 100644 --- a/src/tools/gcc.py +++ b/src/tools/gcc.py @@ -746,2 +746,3 @@ def cpu_flags(toolset, variable, architecture, instruction_set, values, default= flags('gcc', 'OPTIONS', ['&lt;architecture&gt;x86/&lt;address-model&gt;32'], ['-m32']) +flags('gcc', 'OPTIONS', ['&lt;architecture&gt;x86/&lt;address-model&gt;32_64'], ['-mx32']) flags('gcc', 'OPTIONS', ['&lt;architecture&gt;x86/&lt;address-model&gt;64'], ['-m64']) </pre><p> Then passed address-model=32_64 to my externally built jam (we're cross-compiling). </p> <p> It's passing less stupid options now: </p> <pre class="wiki">| "x86_64-poky-linux-gnux32-g++" "-mx32" "-Wl,-O1" "-Wl,--hash-style=gnu" "-Wl,--as-needed" "--sysroot=/data/poky-master/tmp-glibc/sysroots/intel-corei7-64" -ftemplate-depth-128 -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/poky-master/tmp-glibc/work/x86_64_x32-poky-linux-gnux32/boost/1.62.0-r1=/usr/src/debug/boost/1.62.0-r1 -fdebug-prefix-map=/data/poky-master/tmp-glibc/sysroots/x86_64-linux= -fdebug-prefix-map=/data/poky-master/tmp-glibc/sysroots/intel-corei7-64= -fvisibility-inlines-hidden -O3 -finline-functions -Wno-inline -Wall -pedantic -pthread -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_REGEX_DYN_LINK=1 -DNDEBUG -I"." -c -o "/data/poky-master/tmp-glibc/work/x86_64_x32-poky-linux-gnux32/boost/1.62.0-r1/boost_1_62_0/x86_64-poky-linux-gnux32/boost/bin.v2/libs/regex/build/8b5ffabbece29b037869af5264487af2/winstances.o" "libs/regex/build/../src/winstances.cpp" </pre><p> Now it fails differently: </p> <pre class="wiki">libs/context/src/unsupported.cpp:7:2: error: #error "platform not supported" #error "platform not supported" </pre><p> Presumably because this new 32_64 address-model doesn't match the build rules for context which use a 64-bit address-model but abi to mark x32: </p> <pre class="wiki"># X86_64/SYSV/X32 alias asm_context_sources : [ make asm/make_x86_64_sysv_elf_gas.o : asm/make_x86_64_sysv_elf_gas.S : @gas64 ] [ make asm/jump_x86_64_sysv_elf_gas.o : asm/jump_x86_64_sysv_elf_gas.S : @gas64 ] [ make asm/ontop_x86_64_sysv_elf_gas.o : asm/ontop_x86_64_sysv_elf_gas.S : @gas64 ] : &lt;abi&gt;x32 &lt;address-model&gt;64 &lt;architecture&gt;x86 &lt;binary-format&gt;elf ; </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Kohei Takahashi</dc:creator> <pubDate>Mon, 21 Nov 2016 14:07:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12616#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12616#comment:3</guid> <description> <p> Ahh, I misunderstood about address-model feature, 32_64 is for the <a href="http://www.boost.org/build/doc/html/bbv2/reference/tools.html#bbv2.reference.tools.compiler.darwin">OS X fat binary</a> at this time. </p> <p> Hmm, it needs changing both of build and context, build should provide 'abi' feature (or address-model) and update setup-address-model, and context should change that requirements. </p> </description> <category>Ticket</category> </item> </channel> </rss>