[Boost-users] Build Boost.Context with Visual Studio

74 views
Skip to first unread message

Thomas Ziegenhagen

unread,
Feb 26, 2016, 7:27:09 AM2/26/16
to boost...@lists.boost.org
Hi there,

I'm building the required portions of Boost myself, along with all my
other projects. It turned out that even the smallest compiler setting
changes lead to strange crashes, some of which only occured on 5% of the
client's systems, so I will not use externally built boost libraries
anymore.

So now I'm building the parts of boost which I require, which works fine
so far.

The trouble starts when I tried to use Boost.Context. It also contains ASM
code, which I now need to build in Visual Studio 2015. VS2015 does not
have builtin Asm support, for x64 it never had. So I'm invoking the
Microsoft assembler as a custom build step. Command line is as follows:

ml64 /Fo path/to/obj/file.obj /c path/to/source/jump_x86_64_ms_pe_masm.asm

Documentation is as scarce as usual, but I figured from the filename that
jump_x86_64_ms_pe_masm.asm is the correct file for Microsoft Visual
Studio, x64. But assembling failed, and to add insult to injury, the error
messages are lost somewhere in the output piping process. The complete
output reads like this:

------
1>------ Erstellen gestartet: Projekt: boost, Konfiguration: Debug x64
------
1> Microsoft (R) Macro Assembler (x64) Version 14.00.23506.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> Assembling:
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(80)ied
size
1>: error A2008 : syntax error : FRAME
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(81)ied
size
1>CUSTOMBUILD : warning A4020: directive ignored outside a procedure
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(215
1>CUSTOMBUILD : fatal error A1010: unmatched block nesting : jump_fcontext
------

Please note that the actual error messages are overwritten by the filename
- I can only guess at what buffer magic happens there, but I'm pretty sure
it's not intended.

But that's just a funny anecdote. My actual question is: how do I build
Boost.Context in Visual Studio? Is there maybe some way to see the
effective command line when building using Boost.Jam? Is this even the
right ASM file for x86_64, Visual Studio?

Thanks in advance!

Bye, Thomas
_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Oliver Kowalke

unread,
Feb 26, 2016, 7:48:27 AM2/26/16
to boost-users
you need to build boost or a subset of  boost with b2/bjam
MASM, the assembler tool, ist part of MS Windows Driver Kit as you can read in the docu http://www.boost.org/doc/libs/1_60_0/libs/context/doc/html/context/requirements.html

Alex Perry

unread,
Feb 26, 2016, 8:05:38 AM2/26/16
to boost...@lists.boost.org
On 26 February 2016 12:27 Thomas Ziegenhagen [mailto:tho...@dreamworlds.de] wrote:-

> I'm building the required portions of Boost myself, along with all my
> other projects. It turned out that even the smallest compiler setting
> changes lead to strange crashes, some of which only occured on 5% of the
> client's systems, so I will not use externally built boost libraries
> anymore.
>
> So now I'm building the parts of boost which I require, which works fine
> so far.

Why not use boost.build to build the boost libraries with whatever compiler flags you require?

See http://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html#simplified-build-from-source

HTH

Alex

Edward Diener

unread,
Feb 26, 2016, 8:27:49 AM2/26/16
to boost...@lists.boost.org
MASM is also part of Visual Studio 2015, despite what the OP says about
it. In my installation of Visual Studio 2015 I find ml.exe in C:\Program
Files (x86)\Microsoft Visual Studio 14.0\VC\bin and ml64.exe in
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64. Yes,
Microsoft installs Visual Studio 2015 in a directory that says "Visual
Studio 2014". Call it their sense of humor <g>. Visual Studio 2015
Community Edition is completely free.

Thomas Ziegenhagen

unread,
Feb 26, 2016, 9:58:29 AM2/26/16
to boost...@lists.boost.org
Hi Oliver,
Thanks for your response, but please read again the command line I stated
in my first mail:

ml64 /Fo path/to/obj/file.obj /c path/to/source/jump_x86_64_ms_pe_masm.asm

Please note that this already *is* the 64bit MASM executable as stated in
the documentation. And using MASM64 leads to the aforementioned errors.
The error messages were as follows:

------
1>------ Erstellen gestartet: Projekt: boost, Konfiguration: Debug x64
------
1> Microsoft (R) Macro Assembler (x64) Version 14.00.23506.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> Assembling:
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(80)ied
size
1>: error A2008 : syntax error : FRAME
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(81)ied
size
1>CUSTOMBUILD : warning A4020: directive ignored outside a procedure
1>
C:\Projekte\DeadPlanet\SourceExt\boost\context\asm\jump_x86_64_ms_pe_masm.asm(215
1>CUSTOMBUILD : fatal error A1010: unmatched block nesting : jump_fcontext
------

So again the questions:

a) Is this the correct asm file for Visual Studio, x64 architecture?
b) If yes, where do those error messages come from? It's the same source
file, the same build tool, the correct invocation parameters, and no
includes or configuration referenced from that ASM file - should result in
the same object file, shouldn't it?

For reference: the 32bit version builds and links fine. Command line for
32bit is:

ml /Fo path/to/obj/file.obj /c path/to/source/jump_i386_ms_pe_masm.asm


All:
I will not use bjam, as stated before: it does not allow the necessary
fine control over the compiler settings, e.g. the compiler choice v140 vs.
v140_xp. Ignoring this will build just fine but leads to rare crashes
which unfortunately do NOT happen on systems with debugging capabilities
but only on some client systems with *days* of response time. This is not
fun. So please, do not discuss the environment. Discuss the actual issue
at hand instead.

Thanks again.

Thomas Ziegenhagen

unread,
Feb 26, 2016, 10:26:58 AM2/26/16
to boost...@lists.boost.org
Hi again,

just a quick heads-up: Boost.Context builds and links correctly now. I
inspected the command line used by bjam and noticed a few things. Mainly
it was one missing define provided at the command line.

Working command line to build the ASM file for Visual Studio x64 is:

ml64 /nologo /Cp /Cx /Zp4 /DBOOST_CONTEXT_EXPORT= /Fo
$(IntDir)%(Filename).obj /c %(FullPath)

"jump_x86_64_ms_pe_masm.asm" and "make_x86_64_ms_pe_masm.asm" have been
the correct files. Difference to previous attempt is the
"/DBOOST_CONTEXT_EXPORT=".

Have a nice day.
Reply all
Reply to author
Forward
0 new messages