|
Boost-Build : |
From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-12-10 08:59:05
Hi all,
I have been working on improving the support for the msvc toolset and
here are the results of my efforts. This brings in support for most of
the compiler flags as is mentioned in the Wiki TODO list.
I plan to submit these in smaller chunks like Alexey has been doing with
his patches. This is how I intend to break this patch up:
[1] Resource-only DLL support;
[2] Alignment feature;
[3] CLR support [*];
[4] The remaining command-line options [*4];
[5] MS Platform SDK support and Windows defines [***] [*5];
[6] CPU architecture defines and -machine options [***];
[7] Windows CE support [**] [***];
[*] There is only partial support for CLR at the moment. I intend to add
a <using> feature that behaves similar to <include> for #using
directives. CLR also doesn't support things like RTTI and C++
exceptions, so the options that are not supported need turning off by
the toolset. I also haven't done any testing of this, just added the
support for the command line options.
[**] At the moment, Windows CE support is only available in the flags
that are defined. These flags are required to correctly build for a CE
target. I haven't been able to get full CE support because I haven't
been able to correctly set the path, include and lib directories in BBv2
(this probably requires order-sensitive include, lib and path features).
[***] These cross into each other, but it is easy to filter out the
changes to affect only one at a time.
[*4] This includes the addition of line only and Edit & Continue debug
information. NOTE: I have moved the <debug-store> feature so it is with
the other features that associate with compile and linker features.
[*5] Alexey Pakhunov has an msplatformsdk.jam toolset to detect and add
support for PlatformSDK installations. It is my intention that my
additions are to be ultimately merged into this toolset. It would make
sense to incorporate his toolset in before these changes.
- Reece
Index: builtin.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/builtin.jam,v
retrieving revision 1.180
diff -u -r1.180 builtin.jam
--- builtin.jam 22 Sep 2005 13:51:58 -0000 1.180
+++ builtin.jam 10 Dec 2005 13:30:13 -0000
@@ -91,6 +91,8 @@
on # fail the compilation if there are warnings
: incidental ;
+feature alignment : default 1 2 4 8 16 : propagated ;
+
feature source : : free dependency incidental ;
feature library : : free dependency incidental ;
feature file : : free dependency incidental ;
@@ -145,6 +147,12 @@
power
# MIPS/SGI
mips1 mips2 mips3 mips4 mips32 mips32r2 mips64
+ # sh
+ sh3 sh3dsp sh4 sh5
+ # arm
+ arm4 arm4t arm5 arm5t
+ # CLR CIL
+ clr
#
: propagated optional ;
Index: msvc.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/msvc.jam,v
retrieving revision 1.70
diff -u -r1.70 msvc.jam
--- msvc.jam 7 Dec 2005 08:30:12 -0000 1.70
+++ msvc.jam 10 Dec 2005 13:25:21 -0000
@@ -21,6 +21,7 @@
import midl ;
import mc ;
import pch ;
+import msplatformsdk ;
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
@@ -36,14 +37,55 @@
# to be seen, though ;-)
;
+feature clr : default managed cppcli : propagated ;
+feature pure-clr : no yes : propagated ;
+feature safe-clr : no yes : propagated ;
+feature have-assembly : yes no : propagated ;
+feature initial-app-domain : no yes : propagated ;
+
+feature resource-only : no yes : incidental ;
+feature debug-store : object database edit-and-continue lines-only : propagated ;
+
+feature improve-fp-consistency : no yes : propagated ;
+feature fiber-safe-optimization : no yes : propagated ;
+feature optimize-for-windows : no yes : propagated ;
+feature function-hooks : none enter exit both : propagated ;
+feature string-pooling : no yes : propagated ;
+feature minimal-rebuild : no yes : propagated ;
+feature security-checks : no yes : propagated ;
+feature separate-functions : no yes : propagated ;
+feature stack-checking : default force enable : propagated ;
+
+feature addressable-sections : 16 32 : propagated ;
+feature code-analysis : no yes : propagated ;
+feature consider-fp-exceptions : no yes : propagated ;
+feature fp-model : default fast precise strict : propagated ;
+feature function-padding : default hotpatch : propagated ;
+
+feature inheritance-model : virtual multiple single : propagated ;
+feature pointer-to-member : default class-first : propagated ;
+
+feature aliasing : default none cross-function : propagated ;
+feature language-extensions : on off : incidental ;
+
+feature smaller-checks : no yes : propagated ;
+feature runtime-checking
+ :
+ none
+ fast
+ stack-frame
+ uninitialized-locals
+ : propagated ;
+
+feature calling-convention : cdecl fastcall stdcall : propagated ;
+
# List of all registered configurations
.versions = [ new configurations ] ;
-# Inherit MIDL flags
+# Inherit flags
toolset.inherit-flags msvc : midl ;
-
-# Inherit MC flags
toolset.inherit-flags msvc : mc ;
+toolset.inherit-flags msvc : msplatformsdk ;
RM = [ common.rm-command ] ;
nl = "
@@ -152,6 +194,24 @@
<architecture>ia64/<address-model>
<architecture>ia64/<address-model>64 ;
+cpu-arch-arm =
+ <architecture>arm4
+ <architecture>arm4t
+ <architecture>arm5
+ <architecture>arm5t
+ ;
+
+cpu-arch-mips =
+ <architecture>mips4
+ ;
+
+cpu-arch-sh =
+ <architecture>sh3
+ <architecture>sh3dsp
+ <architecture>sh4
+ <architecture>sh5
+ ;
+
local rule configure-really (
version ? :
@@ -402,6 +462,24 @@
flags msvc.compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ;
flags msvc.compile.c++ C++FLAGS $(condition) : /wd4675 ;
flags msvc.compile CFLAGS $(condition)/<warnings>all : /Wp64 ; # 64-bit compatibility warning
+
+ flags msvc.compile CFLAGS <fiber-safe-optimization>yes : /GT ;
+ flags msvc.compile CFLAGS <function-hooks>enter : /Gh ;
+ flags msvc.compile CFLAGS <function-hooks>exit : /GH ;
+ flags msvc.compile CFLAGS <function-hooks>both : /Gh /GH ;
+ flags msvc.compile CFLAGS <security-checks>yes : /GS ;
+ flags msvc.compile CFLAGS <smaller-checks>yes : /RTCc ;
+ flags msvc.compile CFLAGS <runtime-checking>fast : /RTCsu ;
+ flags msvc.compile CFLAGS <runtime-checking>stack-frame : /RTCs ;
+ flags msvc.compile CFLAGS <runtime-checking>uninitialized-locals : /RTCu ;
+
+ flags msvc.compile CFLAGS <architecture>clr/<have-assembly>no : /clr:noAssembly ;
+ }
+ else # VC6
+ {
+ flags msvc.compile CFLAGS <function-hooks>enter : /Gh ;
+ flags msvc.compile CFLAGS <function-hooks>exit : /Gh ;
+ flags msvc.compile CFLAGS <function-hooks>both : /Gh ;
}
#
@@ -415,12 +493,35 @@
flags msvc.compile CFLAGS $(condition)/<optimization>speed : /Ot ;
flags msvc.compile CFLAGS $(condition)/<optimization>space : /Os ;
+ flags msvc.compile CFLAGS <improve-fp-consistency>yes : /Op ;
+ flags msvc.compile CFLAGS <aliasing>none : /Oa ;
+ flags msvc.compile CFLAGS <aliasing>cross-function : /Ow ;
+
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set> : /GB ;
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set>i386 : /G3 ;
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set>i486 : /G4 ;
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set>$(cpu-type-g5) : /G5 ;
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set>$(cpu-type-g6) : /G6 ;
flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/<instruction-set>$(cpu-type-g7) : /G7 ;
+
+ flags msvc.compile CFLAGS <architecture>clr : /clr ;
+ }
+ else # VC8+
+ {
+ flags msvc.compile CFLAGS <architecture>clr/<clr>default : /clr ;
+ flags msvc.compile CFLAGS <architecture>clr/<clr>cppcli : /clr ;
+ flags msvc.compile CFLAGS <architecture>clr/<clr>managed : /clr:oldSyntax ;
+ flags msvc.compile CFLAGS <architecture>clr/<pure-clr>yes : /clr:pure ;
+ flags msvc.compile CFLAGS <architecture>clr/<safe-clr>yes : /clr:safe ;
+ flags msvc.compile CFLAGS <architecture>clr/<initial-app-domain>yes : /clr:initialAppDomain ;
+
+ flags msvc.compile CFLAGS <consider-fp-exceptions>yes : /fp:except ;
+ flags msvc.compile CFLAGS <fp-model>fast : /fp:fast ;
+ flags msvc.compile CFLAGS <fp-model>precise : /fp:precise ;
+ flags msvc.compile CFLAGS <fp-model>strict : /fp:strict ;
+ flags msvc.compile CFLAGS <function-padding>hotpatch : /hotpatch ;
+ flags msvc.compile CFLAGS <code-analysis>yes : /analyse ;
+ flags msvc.compile CFLAGS <addressable-sections>32 : /bigobj ;
}
}
@@ -491,6 +592,9 @@
# into separate rsp file.
generators.register-linker msvc.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>msvc ;
generators.register-linker msvc.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>msvc ;
+generators.register-linker msvc.link.resource-dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB : <toolset>msvc <resource-only>yes ;
+generators.override msvc.link.resource-dll : msvc.link.dll ;
+
generators.register-archiver msvc.archive : OBJ : STATIC_LIB : <toolset>msvc ;
generators.register-c-compiler msvc.compile.c++ : CPP : OBJ : <toolset>msvc ;
@@ -512,10 +616,25 @@
#
# Declare flags and action for compilation
#
-feature.feature debug-store : object database : propagated ;
flags msvc.compile CFLAGS <optimization>speed : /O2 ;
flags msvc.compile CFLAGS <optimization>space : /O1 ;
+flags msvc.compile CFLAGS <optimize-for-windows>yes : /GA ;
+
+flags msvc.compile CFLAGS <string-pooling>yes : /GF ;
+flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>database/<minimal-rebuild>yes : /Gm ;
+flags msvc.compile CFLAGS <stack-checking>force : /Ge ;
+flags msvc.compile CFLAGS <stack-checking>enable : /Gs0 ;
+flags msvc.compile CFLAGS <language-extensions>off : /Za ;
+flags msvc.compile CFLAGS <calling-convention>cdecl : /Gd ;
+flags msvc.compile CFLAGS <calling-convention>fastcall : /Gr ;
+flags msvc.compile CFLAGS <calling-convention>stdcall : /Gz ;
+
+flags msvc.compile CFLAGS <inheritance-model>virtual : /vmv ;
+flags msvc.compile CFLAGS <inheritance-model>multiple : /vmm ;
+flags msvc.compile CFLAGS <inheritance-model>single : /vms ;
+flags msvc.compile CFLAGS <pointer-to-member>default : /vmg ;
+flags msvc.compile CFLAGS <pointer-to-member>class-first : /vmb ;
flags msvc.compile CFLAGS $(cpu-arch-amd64)/<instruction-set> : /favor:blend ;
flags msvc.compile CFLAGS $(cpu-arch-amd64)/<instruction-set>$(cpu-type-em64t) : /favor:EM64T ;
@@ -526,11 +645,20 @@
flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>object : /Z7 ;
flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>database : /Zi ;
+flags msvc.compile CFLAGS $(cpu-arch-i386)/<debug-symbols>on/<debug-store>edit-and-continue : /ZI ;
+flags msvc.compile CFLAGS <debug-symbols>on/<debug-store>lines-only : /Zd ;
+
flags msvc.compile CFLAGS <optimization>off : /Od ;
flags msvc.compile CFLAGS <inlining>off : /Ob0 ;
flags msvc.compile CFLAGS <inlining>on : /Ob1 ;
flags msvc.compile CFLAGS <inlining>full : /Ob2 ;
+flags msvc.compile CFLAGS <alignment>1 : /Zp1 ;
+flags msvc.compile CFLAGS <alignment>2 : /Zp2 ;
+flags msvc.compile CFLAGS <alignment>4 : /Zp4 ;
+flags msvc.compile CFLAGS <alignment>8 : /Zp8 ;
+flags msvc.compile CFLAGS <alignment>16 : /Zp16 ;
+
flags msvc.compile CFLAGS <warnings>on : /W3 ;
flags msvc.compile CFLAGS <warnings>off : /W0 ;
flags msvc.compile CFLAGS <warnings>all : /W4 ;
@@ -555,6 +683,14 @@
flags msvc.compile PDB_CFLAG <debug-symbols>on/<debug-store>database : /Fd ; # not used yet
+# CPU architecture and general windows version:
+flags msvc.compile CFLAGS $(cpu-arch-i386) : /DWIN32 /DX86 /D_X86_ ;
+flags msvc.compile CFLAGS $(cpu-arch-ia64) : /DWIN64 /DIA64 /D_IA64_ ;
+flags msvc.compile CFLAGS $(cpu-arch-amd64) : /DWIN64 /DAMD64 /D_AMD64_ ;
+flags msvc.compile CFLAGS $(cpu-arch-arm) : /DWINCE /DARM /D_ARM_ ;
+flags msvc.compile CFLAGS $(cpu-arch-sh) : /DWINCE ;
+flags msvc.compile CFLAGS $(cpu-arch-mips) : /DWINCE ;
+
flags msvc.compile DEFINES <define> ;
flags msvc.compile UNDEFS <undef> ;
flags msvc.compile INCLUDES <include> ;
@@ -594,7 +730,7 @@
actions compile.pch bind PCH_SOURCE
{
- $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(PCH_SOURCE:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" /Yc"$(>[1]:D=)" -Fp"$(<[2]:W)"
+ $(.CC) /Zm800 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(PCH_SOURCE:W)" $(nl)-D$(DEFINES) $(nl)"-I$(INCLUDES)")" -c -Fo"$(<[1]:W)" /Yc"$(>[1]:D=)" -Yl__bjam_pch_symbol -Fp"$(<[2]:W)"
}
@@ -620,18 +756,24 @@
# for the assembler the following options are turned on by default:
#
# -coff generate COFF format object file (compatible with cl.exe output)
-# -Zp4 align structures to 4 bytes
# -Cp preserve case of user identifiers
# -Cx preserve case in publics, externs
+flags msvc.compile ASMFLAGS <alignment>1 : /Zp1 ;
+flags msvc.compile ASMFLAGS <alignment>2 : /Zp2 ;
+flags msvc.compile ASMFLAGS <alignment>4 : /Zp4 ;
+flags msvc.compile ASMFLAGS <alignment>8 : /Zp8 ;
+flags msvc.compile ASMFLAGS <alignment>16 : /Zp16 ;
+
actions compile.asm
{
- $(.ASM) -nologo -c -coff -Zp4 -Cp -Cx $(USER_ASMFLAGS) -Fo "$(<:W)" "$(>:W)"
+ $(.ASM) -nologo -c -coff -Cp -Cx $(ASMFLAGS) $(USER_ASMFLAGS) -Fo "$(<:W)" "$(>:W)"
}
# Declare flags and action for linking
flags msvc.link PDB_LINKFLAG <debug-symbols>on/<debug-store>database : /PDB: ; # not used yet
flags msvc.link LINKFLAGS <debug-symbols>on : /DEBUG ;
+flags msvc.link LINKFLAGS <debug-symbols>off : /RELEASE ;
flags msvc.link DEF_FILE <def-file> ;
# The linker disables the default optimizations when using /DEBUG. Whe have
# to enable them manually for release builds with debug symbols.
@@ -644,6 +786,18 @@
flags msvc LINKFLAGS <user-interface>auto : /subsystem:posix ;
flags msvc LINKFLAGS <main-target-type>LIB/<link>shared : /DLL ;
+flags msvc LINKFLAGS <main-target-type>LIB/<link>shared/<resource-only>yes : /noentry ;
+
+# CPU architecture:
+flags msvc LINKFLAGS $(cpu-arch-i386) : -machine:x86 ;
+flags msvc LINKFLAGS $(cpu-arch-ia64) : -machine:ia64 ;
+flags msvc LINKFLAGS $(cpu-arch-amd64) : -machine:amd64 ;
+flags msvc LINKFLAGS $(cpu-arch-arm) : -machine:arm ;
+flags msvc LINKFLAGS $(cpu-arch-mips) : -machine:mips ;
+flags msvc LINKFLAGS <architecture>sh3 : -machine:sh3 ;
+flags msvc LINKFLAGS <architecture>sh3dsp : -machine:sh3dsp ;
+flags msvc LINKFLAGS <architecture>sh4 : -machine:sh4 ;
+flags msvc LINKFLAGS <architecture>sh5 : -machine:sh5 ;
flags msvc.link USER_LINKFLAGS <linkflags> ;
flags msvc.link LINKPATH <library-path> ;
@@ -660,6 +814,11 @@
DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ;
}
+rule link.resource-dll ( targets + : sources * : properties * )
+{
+ DEPENDS $(<) : [ on $(<) return $(DEF_FILE) ] ;
+}
+
# Declare action for creating static libraries
# If library exists, remove it before adding files. See
# http://article.gmane.org/gmane.comp.lib.boost.build/4241
@@ -697,13 +856,19 @@
actions link bind DEF_FILE
{
- $(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /LIBPATH:"$(LINKPATH:W)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
+ $(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /LIBPATH:"$(LINKPATH:W)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
$(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);1
}
actions link.dll bind DEF_FILE
{
- $(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:$(DEF_FILE) $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)$(LIBRARIES) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
+ $(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:$(DEF_FILE) $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
+ $(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);2
+}
+
+actions link.resource-dll bind DEF_FILE
+{
+ $(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:$(DEF_FILE) $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")"
$(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);2
}
# Copyright (C) Reece H. Dunn 2005.
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
import feature : feature compose ;
import toolset : flags ;
# Character Set
feature character-set : narrow wide mbcs : propagated composite ;
feature.compose <character-set>wide : <define>_UNICODE <define>UNICODE ;
feature.compose <character-set>mbcs : <define>_MBCS ;
# Windows version identification
feature windows
: none
95 98 me
nt 2k xp 2k3 vista
pocketpc2003 smartphone2003
: incidental composite ;
feature.compose <windows>95 : <define>WINVER=0x0400 <define>_WIN32_WINDOWS=0x0400 ;
feature.compose <windows>98 : <define>WINVER=0x0400 <define>_WIN32_WINDOWS=0x0410 ;
feature.compose <windows>me : <define>WINVER=0x0500 <define>_WIN32_WINDOWS=0x0500 ;
feature.compose <windows>nt : <define>WINVER=0x0400 <define>_WIN32_WINNT=0x0400 ;
feature.compose <windows>2k : <define>WINVER=0x0500 <define>_WIN32_WINNT=0x0500 ;
feature.compose <windows>xp : <define>WINVER=0x0501 <define>_WIN32_WINNT=0x0501 ;
feature.compose <windows>2k3 : <define>WINVER=0x0502 <define>_WIN32_WINNT=0x0502 ;
feature.compose <windows>vista : <define>WINVER=0x0600 <define>_WIN32_WINNT=0x0600 ;
feature.compose <windows>pocketpc2003
:
<define>WIN32_PLATFORM_PSPC
<define>_WIN32_WCE=0x0420
<define>UNDER_CE=0x0420
;
feature.compose <windows>smartphone2003
:
<define>WIN32_PLATFORM_WFSP
<define>_WIN32_WCE=0x0420
<define>UNDER_CE=0x0420
;
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