Boost logo

Boost-Build :

From: Andrey Melnikov (melnikov_at_[hidden])
Date: 2005-07-12 11:36:36


This is a toolset I develop for myself in order to be able to use x64
compiler shipped with MS Platform SDK. The solution is ugly, but it
works for me, so I hope it will be useful for someone else too.

I think that in the future we will need to have x64 support to be built
into main msvc toolset, because the compiler is still a flavour of MSVC-8.0.

I think we need <toolset-platform> and/or <toolset-arch> features to
support compilers which are able to cross-compile for multiple operating
systems and CPU architectures.

Now we have 4 msvc-8.0 compilers:

msvc-8.0-x64-psdk
msvc-8.0-x64-studio
msvc-8.0-IA64-psdk
msvc-8.0-IA64-studio

Also these compilers can be used with an external Platform SDK and/or
DDK. How we are going to specify all these configurations?

Andrey
 --------------010901000108010509030103 Content-Type: text/plain;
name="x64.jam"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="x64.jam"

# Copyright David Abrahams 2003. Permission to copy, use,
# modify, sell and distribute this software is granted provided this
# copyright notice appears in all copies. This software is provided
# "as is" without express or implied warranty, and with no claim as
# to its suitability for any purpose.
import property ;
import generators ;
import os ;
import type ;
import toolset : flags ;
import errors : error ;
import feature : feature get-values ;
import path ;
import sequence : unique ;
import common ;

import rc ;

if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
.debug-configuration = true ;
}

feature.extend toolset : x64 ;

feature.subfeature toolset x64 : vendor
: intel
: propagated optional
# intel and x64 supposedly have link-compatible objects... remains
# to be seen, though ;-)
;

RM = [ common.rm-command ] ;

# Initialize the toolset for a specific version. As the result, path to
# compiler and, possible, program names are set up, and will be used when
# that version of compiler is requested. For example, you might have::
#
# using x64 : 6.5 : X:/some_dir ;
# using x64 : 7.0 : Y:/some_dir ;
# using x64 : : Z:/some_dir
#
# If you have "x64-6.5" in build request, the version from X: drive will be used,
# and if you put only "x64", then drive "Z:" will be used. Note that it's not possible
# the specify that by default, version 7.0 must be used --- you should use 'using'
# without version number for that effect.
#
# version --
# path --
#
# When invoking tools, we'll first run vcvars32.bat from the configured path and
# then cl/link, without path.
#
# Note: for free VC7.1 tools, we don't correctly find vcvars32.bat when user
# explicitly provides a path.

rule init
{
local root = "c:/program files/microsoft platform sdk" ;
# CONSIDER: What's the point of 'call'. Can we invoke the script directly?
local setup = "call \"$(root)/setenv\" /XP64 /RETAIL > nul" ;

if [ os.name ] = NT
{
setup = $(setup)"
" ;
}
else
{
setup = "cmd /S /C "$(setup)" \"&&\" " ;
}

# prefix with setup, or quoted path if any
local prefix = $(setup) ;

local condition = [ common.check-init-parameters x64 : version $(version) ] ;

flags x64.compile .CC $(condition) : $(prefix)cl ;
flags x64.compile .RC $(condition) : $(prefix)rc ;
flags x64.link .LD $(condition) : $(prefix)link ;
flags x64.archive .LD $(condition) : $(prefix)link ;
}

# Declare generators

# is it possible to combine these?
# make the generators non-composing, so that they don't convert each source
# into separate rsp file.
generators.register-linker x64.link : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : EXE : <toolset>x64 ;
generators.register-linker x64.link.dll : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB : SHARED_LIB IMPORT_LIB : <toolset>x64 ;

generators.register-archiver x64.archive : OBJ : STATIC_LIB : <toolset>x64 ;
generators.register-c-compiler x64.compile.c++ : CPP : OBJ : <toolset>x64 ;
generators.register-c-compiler x64.compile.c : C : OBJ : <toolset>x64 ;
generators.register-standard x64.compile.rc : RC : OBJ(%_res) : <toolset>x64 ;
generators.override x64.compile.rc : rc.resource-compile ;

#
# Declare flags and action for compilation
#
# feature.feature debug-store : object database : propagated ;
flags x64.compile CFLAGS <debug-symbols>on/<debug-store>object : /Z7 ;
flags x64.compile CFLAGS <debug-symbols>on/<debug-store>database : /Zi ;
flags x64.compile CFLAGS <optimization>off : /Od ;
flags x64.compile CFLAGS <inlining>off : /Ob0 ;
flags x64.compile CFLAGS <inlining>on : /Ob1 ;
flags x64.compile CFLAGS <inlining>full : /Ob2 ;

flags x64.compile C++FLAGS <exception-handling>on/<asynch-exceptions>off/<extern-c-nothrow>off : /EHs ;
flags x64.compile C++FLAGS <exception-handling>on/<asynch-exceptions>off/<extern-c-nothrow>on : /EHsc ;
flags x64.compile C++FLAGS <exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>off : /EHa ;
flags x64.compile C++FLAGS <exception-handling>on/<asynch-exceptions>on/<extern-c-nothrow>on : /EHac ;

flags x64.compile CFLAGS <rtti>on : /GR ;
flags x64.compile CFLAGS <runtime-debugging>off/<runtime-link>shared/<threading>multi : /MD ;
flags x64.compile CFLAGS <runtime-debugging>on/<runtime-link>shared/<threading>multi : /MDd ;

flags x64.compile CFLAGS <runtime-debugging>off/<runtime-link>static/<threading>multi : /MT ;
flags x64.compile CFLAGS <runtime-debugging>on/<runtime-link>static/<threading>multi : /MTd ;

flags x64.compile USER_CFLAGS <cflags> : ;
flags x64.compile.c++ USER_CFLAGS <cxxflags> : ;

flags x64.compile PDB_CFLAG <debug-symbols>on/<debug-store>database : /Fd ; # not used yet

flags x64.compile DEFINES <define> ;
flags x64.compile UNDEFS <undef> ;
flags x64.compile INCLUDES <include> ;

# The actions differ only by explicit selection of input language
actions compile.c bind RSP
{
$(.CC) -wd4103 -nologo -TC -U$(UNDEFS) $(CFLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
}
actions compile.c++ bind RSP
{
$(.CC) -wd4103 -nologo -TP -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(USER_CFLAGS) @"$(RSP:W)" -c -Fo"$(<[1]:W)" && $(RM) "$(RSP)"
}

actions compile.rc
{
$(.RC) -l 0x409 -U$(UNDEFS) -D$(DEFINES) -I"$(INCLUDES)" -fo "$(<:W)" "$(>:W)"
}

# Declare flags and action for linking
flags x64.link PDB_LINKFLAG <debug-symbols>on/<debug-store>database : /PDB: ; # not used yet
flags x64.link LINKFLAGS <debug-symbols>on : /DEBUG ;
flags x64.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.
flags x64 LINKFLAGS <debug-symbols>on/<runtime-debugging>off : /OPT:REF,ICF ;

flags x64 LINKFLAGS <user-interface>console : /subsystem:console ;
flags x64 LINKFLAGS <user-interface>gui : /subsystem:windows ;
flags x64 LINKFLAGS <user-interface>wince : /subsystem:windowsce ;
flags x64 LINKFLAGS <user-interface>native : /subsystem:native ;
flags x64 LINKFLAGS <user-interface>auto : /subsystem:posix ;

flags x64 LINKFLAGS : bufferoverflowu.lib ;

flags x64 LINKFLAGS <main-target-type>LIB/<link>shared : /DLL ;

toolset.flags x64.link USER_LINKFLAGS <linkflags> ;
toolset.flags x64.link LINKPATH <library-path> ;

flags x64.link FINDLIBS_ST <find-static-library> ;
flags x64.link FINDLIBS_SA <find-shared-library> ;
flags x64.link LIBRARY_OPTION <toolset>x64 : "" : unchecked ;

rule archive ( targets + : sources * : properties * )
{
common.response-file $(targets) : $(sources) : $(targets[2]) : $(properties) ;
}

rule link ( targets + : sources * : properties * )
{
common.response-file $(targets) : $(sources) : $(targets[2])
: $(properties) ;
}

rule link.dll ( targets + : sources * : properties * )
{
common.response-file $(targets) : $(sources) : $(targets[3]) : $(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
# for rationale.
if [ os.name ] in NT
{
# The 'DEL' command would issue a message to stdout
# if the file does not exist, so need a check.
actions archive bind RSP
{
if exist "$(<[1])" DEL "$(<[1])"
$(.LD) /lib /NOLOGO /out:"$(<[1])" @"$(RSP)" && $(RM) "$(RSP)"
}
}
else
{
actions archive bind RSP
{
$(RM) "$(<[1])"
$(.LD) /lib /NOLOGO /out:"$(<[1])" @"$(RSP)" && $(RM) "$(RSP)"
}
}

# incremental linking a DLL causes no end of problems: if the
# actual exports don't change, the import .lib file is never
# updated. Therefore, the .lib is always out-of-date and gets
# rebuilt every time. I'm not sure that incremental linking is
# such a great idea in general, but in this case I'm sure we
# don't want it.
actions link bind DEF_FILE RSP
{
$(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /LIBPATH:"$(LINKPATH:W)" $(USER_LINKFLAGS) @"$(RSP:W)" && $(RM) "$(RSP)"
$(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);#2
}

actions link.dll bind DEF_FILE RSP
{
$(.LD) /NOLOGO $(LINKFLAGS) /out:"$(<[1]:W)" /INCREMENTAL:NO /IMPLIB:"$(<[2]:W)" /LIBPATH:"$(LINKPATH:W)" /def:$(DEF_FILE) $(USER_LINKFLAGS) @"$(RSP:W)" && $(RM) "$(RSP)"
$(MANIFEST)$(<[1]).manifest $(OUTPUTRESOURCE)$(<[1]);#2
}

rule compile.c++ ( targets + : sources * : properties * )
{
common.response-file $(targets) : $(sources) : $(response-file) : $(properties) ;
}

rule compile.c ( targets + : sources * : properties * )
{
common.response-file $(targets) : $(sources) : $(targets[2]) : $(properties) ;
}

 --------------010901000108010509030103--


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