|
Boost-Build : |
From: Jim Douglas (jim_at_[hidden])
Date: 2006-02-13 05:45:10
Vladimir Prus wrote:
> On Friday 10 February 2006 19:21, Jim Douglas wrote:
>>And what about the qcc tools for QNX6?
>
> You are the only one with qcc/QNX6, I believe. If you'll agree to test the
> toolset,
Ready and waiting...
> I can port it from V1 rather fast.
Negative. The v1 file is only a holding measure. The v2 file needs to be
derived as a sibling of gcc not a child as in v1. There are many
requirements that are not addressed in v1. Much of this has been
discussed in this NG, but to summarise:
qcc supports:
- two compilers GNU gcc & Intel, with versions of both.
- two C++ standard laibraries GNU & Dinkumware with sub-variations
- self hosted (native) compilation on QNX
- cross compilation on Windows & Linux
- mutilple hardware targets: MIPS, PowerPC, SH-4, ARM, StrongArm, Intel®
XScale Microarchitecture, and x86
One further requirement is that in order to run the regression tests in
a cross-development environment, bbv2 should support some form of remote
execution. (But that's for later...)
It has been suggested by Reese Dunn (see thread started 3/11/2005) that
the bjam command line options could look something like:
$ bjam qcc-3.3 architecture=power stdlib=dinkum
$ bjam qcc-2.95 architecture=x86 stdlib=default
I have already ported a very crude version of qcc.jam for bbv2 that
works, but it is far from complete/perfect. However, we do not have to
implement all the features for v1.34. The "first cut" file is attached.
I thank you for your response. I was was becoming concerned that this
might not be finished in time.
Jim
# Copyright (c) 2001 David Abrahams.
# Copyright (c) 2002-2003 Rene Rivera.
# Copyright (c) 2002-2003 Vladimir Prus.
#
# 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 toolset : flags ;
import property ;
import generators ;
import os ;
import type ;
import feature ;
import "class" : new ;
import set ;
import common ;
import errors ;
feature.extend toolset : qcc ;
import unix ;
toolset.inherit-generators qcc : unix : unix.link unix.link.dll ;
generators.override builtin.lib-generator : qcc.prebuilt ;
toolset.inherit-flags qcc : unix ;
toolset.inherit-rules qcc : unix ;
# Make the "o" suffix used for qcc toolset on all
# platforms
type.set-generated-target-suffix OBJ : <toolset>qcc : o ;
type.set-generated-target-suffix STATIC_LIB : <toolset>qcc : a ;
# Initializes the qcc toolset for the given version.
# If necessary, command may be used to specify where the compiler
# is located.
# The parameter 'options' is a space-delimited list of options, each
# one being specified as <option-name>option-value. Valid option names
# are: cxxflags, linkflags and linker-type. Accepted values for linker-type
# are gnu and sun, gnu being the default.
# Example:
# using qcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ;
rule init ( version ? : command * : options * )
{
local condition = [ common.check-init-parameters qcc : version $(version) ] ;
local command = [ common.get-invocation-command qcc : QCC : $(command) ] ;
common.handle-options qcc : $(condition) : $(command) : $(options) ;
local linker = [ feature.get-values <linker-type> : $(options) ] ;
if ! $(linker) {
linker = gnu ;
}
init-link-flags qcc $(linker) $(condition) ;
}
if [ os.name ] = NT
{
# This causes single-line command invocation to not go through
# .bat files, thus avoiding command-line length limitations
JAMSHELL = % ;
}
generators.register-c-compiler qcc.compile.c++ : CPP : OBJ : <toolset>qcc ;
generators.register-c-compiler qcc.compile.c : C : OBJ : <toolset>qcc ;
generators.register-c-compiler qcc.compile.asm : ASM : OBJ : <toolset>qcc ;
# Declare flags and action for compilation
flags qcc.compile OPTIONS <optimization>off : -O0 ;
flags qcc.compile OPTIONS <optimization>speed : -O3 ;
flags qcc.compile OPTIONS <optimization>space : -Os ;
flags qcc.compile OPTIONS <inlining>off : -Wc,-fno-inline ;
flags qcc.compile OPTIONS <inlining>on : -Wc,-Wno-inline ;
flags qcc.compile OPTIONS <inlining>full : -Wc,-finline-functions -Wc,-Wno-inline ;
flags qcc.compile OPTIONS <warnings>off : -w ;
flags qcc.compile OPTIONS <warnings>all : -Wc,-Wall ;
flags qcc.compile OPTIONS <warnings-as-errors>on : -Wc,-Werror ;
flags qcc.compile OPTIONS <debug-symbols>on : -gstabs+ ;
flags qcc.compile OPTIONS <profiling>on : -pg ;
# On cygwin and mingw, qcc generates position independent code by default,
# and warns if -fPIC is specified. This might not be the right way
# of checking if we're using cygwin. For example, it's possible
# to run cygwin qcc from NT shell, or using crosscompiling.
# But we'll solve that problem when it's time. In that case
# we'll just add another parameter to 'init' and move this login
# inside 'init'.
if [ os.name ] != CYGWIN && [ os.name ] != NT
{
# This logic will add -fPIC for all compilations:
#
# lib a : a.cpp b ;
# obj b : b.cpp ;
# exe c : c.cpp a d ;
# obj d : d.cpp ;
#
# This all is fine, except that 'd' will be compiled with
# -fPIC even though it's not needed, as 'd' is used only in
# exe. However, it's hard to detect where a target is going to
# be used. Alternative, we can set -fPIC only when main target type
# is LIB but than 'b' will be compiled without -fPIC. In x86-64 that
# will lead to link errors. So, compile everything with -fPIC.
#
# Yet another alternative would be to create propagated <sharedable>
# feature, and set it when building shared libraries, but that's hard
# to implement and will increase target path length even more.
flags qcc.compile OPTIONS <link>shared : -Wc,-fPIC ;
}
if [ os.name ] != NT
{
HAVE_SONAME = "" ;
}
flags qcc.compile OPTIONS <cflags> ;
flags qcc.compile.c++ OPTIONS <cxxflags> ;
flags qcc.compile DEFINES <define> ;
flags qcc.compile INCLUDES <include> ;
rule compile.c++
{
# Some extensions are compiled as C++ by default. For others, we need
# to pass -x c++.
# We could always pass -x c++ but distcc does not work with it.
if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C
{
LANG on $(<) = "-x c++" ;
}
}
actions compile.c++
{
"$(CONFIG_COMMAND)" $(LANG) -Wc,-ftemplate-depth-100 $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
}
rule compile.c
{
# If we use the name g++ then default file suffix -> language mapping
# does not work. So have to pass -x option. Maybe, we can work around this
# by allowing the user to specify both C and C++ compiler names.
#if $(>:S) != .c
#{
LANG on $(<) = "-x c" ;
#}
}
actions compile.c
{
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
}
rule compile.asm
{
LANG on $(<) = "-x assembler-with-cpp" ;
}
actions compile.asm
{
"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
}
# The class which check that we don't try to use
# the <runtime-link>static property while creating or using shared library,
# since it's not supported by qcc/libc.
class qcc-linking-generator : unix-linking-generator
{
rule generated-targets ( sources + : property-set : project name ? )
{
if <runtime-link>static in [ $(property-set).raw ]
{
local m ;
if [ id ] = "qcc.link.dll"
{
m = "on qcc, DLL can't be build with <runtime-link>static" ;
}
if ! $(m) {
for local s in $(sources)
{
local type = [ $(s).type ] ;
if $(type) && [ type.is-derived $(type) SHARED_LIB ]
{
m = "on qcc, using DLLS together with the <runtime-link>static options is not possible " ;
}
}
}
if $(m)
{
errors.user-error $(m) :
"it's suggested to use <runtime-link>static together with the <link>static" ;
}
}
return [ unix-linking-generator.generated-targets
$(sources) : $(property-set) : $(project) $(name) ] ;
}
}
generators.register [ new qcc-linking-generator qcc.link : LIB OBJ : EXE
: <toolset>qcc ] ;
generators.register [ new qcc-linking-generator qcc.link.dll : LIB OBJ : SHARED_LIB
: <toolset>qcc ] ;
generators.override qcc.prebuilt : builtin.prebuilt ;
generators.override qcc.searched-lib-generator : searched-lib-generator ;
# Declare flags for linking
# First, the common flags
flags qcc.link OPTIONS <debug-symbols>on : -g ;
flags qcc.link OPTIONS <profiling>on : -pg ;
flags qcc.link OPTIONS <linkflags> ;
flags qcc.link LINKPATH <library-path> ;
flags qcc.link FINDLIBS-ST <find-static-library> ;
flags qcc.link FINDLIBS-SA <find-shared-library> ;
flags qcc.link LIBRARIES <library-file> ;
# For <runtime-link>static we made sure there are no dynamic libraries
# in the link
flags qcc.link OPTIONS <runtime-link>static : -static ;
# Now, the vendor specific flags
# The parameter linker can be either gnu or sun
rule init-link-flags ( toolset linker condition )
{
switch $(linker)
{
case gnu :
{
# Strip the binary when no debugging is needed.
# We use --strip-all flag as opposed to -s since icc
# (intel's compiler) is generally option-compatible with
# and inherits from qcc toolset, but does not support -s
flags $(toolset).link OPTIONS $(condition)/<debug-symbols>off : -Wl,--strip-all
: unchecked ;
flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ;
flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> : unchecked ;
}
case darwin :
{
# we can't pass -s to ld unless we also pass -static
# so we removed -s completly from OPTIONS and add it
# to ST_OPTIONS
flags $(toolset).link ST_OPTIONS $(condition)/<debug-symbols>off : -s
: unchecked ;
flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ;
flags $(toolset).link RPATH_LINK $(condition) : <xdll-path> : unchecked ;
}
case sun :
{
flags $(toolset).link OPTIONS $(condition)/<debug-symbols>off : -Wl,-s
: unchecked ;
flags $(toolset).link RPATH $(condition) : <dll-path> : unchecked ;
# Solaris linker does not have a separate -rpath-link, but
# allows to use -L for the same purpose.
flags $(toolset).link LINKPATH $(condition) : <xdll-path> : unchecked ;
# This permits shared libraries with non-PIC code on Solaris
# VP, 2004/09/07: Now that we have -fPIC hardcode in link.dll,
# the following is not needed. Whether -fPIC should be hardcoded,
# is a separate question.
# AH, 2004/10/16: it is still necessary because some tests link
# against static libraries that were compiled without PIC.
flags $(toolset).link OPTIONS $(condition)/<link>shared : -mimpure-text
: unchecked ;
}
case * :
{
errors.user-error
"$(toolset) initialization: invalid linker '$(linker)'" :
"The value '$(linker)' specified for <linker> is not recognized." :
"Possible values are 'sun', 'gnu'" ;
}
}
}
# Declare actions for linking
rule link ( targets * : sources * : properties * )
{
SPACE on $(targets) = " " ;
# Serialize execution of the 'link' action, since
# running N links in parallel is just slower.
# For now, serialize only qcc links, it might be a good
# idea to serialize all links.
JAM_SEMAPHORE on $(targets) = <s>qcc-link-semaphore ;
}
actions link bind LIBRARIES
{
"$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
}
# Always remove archive and start again. Here's rationale from
# Andre Hentz:
# I had a file, say a1.c, that was included into liba.a.
# I moved a1.c to a2.c, updated my Jamfiles and rebuilt.
# My program was crashing with absurd errors.
# After some debugging I traced it back to the fact that a1.o was *still*
# in liba.a
RM = [ common.rm-command ] ;
if [ os.name ] = NT
{
RM = "if exist \"$(<[1])\" DEL \"$(<[1])\"" ;
}
# Declare action for creating static libraries
# The 'r' letter means to add files to the archive with replacement
# Since we remove archive, we don't care about replacement, but
# there's no option "add without replacement".
# The 'c' letter means suppresses warning in case the archive
# does not exists yet. That warning is produced only on
# some platforms, for whatever reasons.
actions piecemeal archive
{
$(RM) "$(<)"
ar rc "$(<)" "$(>)"
}
rule link.dll ( targets * : sources * : properties * )
{
SPACE on $(targets) = " " ;
JAM_SEMAPHORE on $(targets) = <s>qcc-link-semaphore ;
}
# Differ from 'link' above only by -shared.
actions link.dll bind LIBRARIES
{
"$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" $(HAVE_SONAME)-Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS)
}
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