|
Boost-Build : |
From: Mat Marcus (mat-lists_at_[hidden])
Date: 2008-05-18 15:45:30
On Sun, May 18, 2008 at 10:14 AM, Vladimir Prus <ghost_at_[hidden]> wrote:
> On Tuesday 13 May 2008 13:10:19 John Reid wrote:
>>
>> Mat Marcus wrote:
>> > Summary: In VC8 (Dev Studio 2005) and later, Microsoft's 'secure' STL
>> > feature (enabled by default) can cause a slowdown of more than an
>> > order of magnitude in the execution of performance critical algorithms
>> > in release builds. I suspect that many projects would benefit from
>> > ensuring that _SECURE_SCL=0 for release configurations. I recommend
>> > that boost ships with this feature disabled by default for (at least)
>> > release builds.
>> >
>>
>>
>> 2 things:
>>
>> 1) I wanted to point out a relatively straightforward way to ensure all
>> your code has _SECURE_SCL=0 defined. In your site-config.jam or
>> user-config.jam put the following using directive:
>>
>> using msvc : : : <define>_SECURE_SCL=0 ;
>>
>>
>> 2) I wanted to check I have the syntax correct as I do not see
>> _SECURE_SCL in the .rsp files in my bin directory.
>
> Per http://ln-s.net/1sG9 this syntax is not correct. You need:
>
> using msvc : : : <compileflags>-D_SECURE_SCL=0 ;
>
> - Volodya
Even with this improved syntax, the above approach has some
limitations. Code compiled with -D_SECURE_SCL=0 should be
link-incompatible with code compiled without it. Otherwise crashes
will occur at runtime. This is why I added the 'stl-security-theater'
bjam feature to the boost 1.35.0 patches that we distribute with the
Adobe Source Libraries (excerpt below or see
http://stlab.adobe.com:8080/@md=d&cd=//adobe_source_libraries/tools/&cdf=//adobe_source_libraries/tools/boost_1_35_0_patches.txt&c=ipI@//adobe_source_libraries/tools/boost_1_35_0_patches.txt?ac=64&rev1=2
in case of formatting errors). I'd still like to figure out how to
mangle the state of this feature into library names (can anyone advise
me on this?), but at least the feature turns off the performance
penalty by default, and gives some degree of protection against
inadvertent mixing and matching.
- Mat
--- ../diffable_boost_1_35_0/tools/build/v2/tools/msvc.jam 2008-03-15
11:55:28.000000000 -0700
+++ ../boost_libraries/tools/build/v2/tools/msvc.jam 2008-04-22
10:02:39.312500000 -0700
@@ -638,6 +638,11 @@
#
# Declare flags and action for compilation
#
+
+# Secure STL feature
+
+feature.feature stl-security-theater : off on : propagated link-incompatible ;
+
feature.feature debug-store : object database : propagated ;
flags msvc.compile CFLAGS <optimization>speed : /O2 ;
@@ -662,6 +667,9 @@
flags msvc.compile C++FLAGS
<exception-handling>on/<asynch-exceptions>off/<extern-c-nothrow>on :
/EHsc ;
flags msvc.compile C++FLAGS
<exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>off :
/EHa ;
flags msvc.compile C++FLAGS
<exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>on :
/EHac ;
+flags msvc.compile C++FLAGS <stl-security-theater>off : /D_SCL_SECURE=0 ;
+flags msvc.compile C++FLAGS <stl-security-theater>on : /D_SCL_SECURE=1 ;
+
# By default 8.0 enables rtti support while prior versions disabled it. We
# simply enable or disable it expliclty so we do not have to depend on this
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk