Blame tools/build/src/tools/gcc.jam

Packit 58578d
# Copyright 2001 David Abrahams
Packit 58578d
# Copyright 2002-2017 Rene Rivera
Packit 58578d
# Copyright 2002-2003 Vladimir Prus
Packit 58578d
# Copyright 2005 Reece H. Dunn
Packit 58578d
# Copyright 2006 Ilya Sokolov
Packit 58578d
# Copyright 2007 Roland Schwarz
Packit 58578d
# Copyright 2007 Boris Gubenko
Packit 58578d
#
Packit 58578d
# Distributed under the Boost Software License, Version 1.0.
Packit 58578d
#    (See accompanying file LICENSE_1_0.txt or copy at
Packit 58578d
#          http://www.boost.org/LICENSE_1_0.txt)
Packit 58578d
Packit 58578d
import "class" : new ;
Packit 58578d
import common ;
Packit 58578d
import cygwin ;
Packit 58578d
import feature ;
Packit 58578d
import fortran ;
Packit 58578d
import generators ;
Packit 58578d
import os ;
Packit 58578d
import pch ;
Packit 58578d
import property ;
Packit 58578d
import property-set ;
Packit 58578d
import rc ;
Packit 58578d
import regex ;
Packit 58578d
import set ;
Packit 58578d
import toolset ;
Packit 58578d
import type ;
Packit 58578d
import unix ;
Packit 58578d
import virtual-target ;
Packit 58578d
import errors ;
Packit 58578d
Packit 58578d
Packit 58578d
if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
Packit 58578d
{
Packit 58578d
    .debug-configuration = true ;
Packit 58578d
}
Packit 58578d
Packit 58578d
Packit 58578d
feature.extend toolset : gcc ;
Packit 58578d
# feature.subfeature toolset gcc : flavor : : optional ;
Packit 58578d
Packit 58578d
toolset.inherit-generators gcc : unix : unix.link unix.link.dll ;
Packit 58578d
toolset.inherit-flags gcc : unix ;
Packit 58578d
toolset.inherit-rules gcc : unix ;
Packit 58578d
Packit 58578d
generators.override gcc.prebuilt : builtin.prebuilt ;
Packit 58578d
generators.override gcc.searched-lib-generator : searched-lib-generator ;
Packit 58578d
Packit 58578d
# Make gcc toolset object files use the "o" suffix on all platforms.
Packit 58578d
type.set-generated-target-suffix OBJ : <toolset>gcc : o ;
Packit 58578d
type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>windows : o ;
Packit 58578d
type.set-generated-target-suffix OBJ : <toolset>gcc <target-os>cygwin : o ;
Packit 58578d
Packit 58578d
Packit 58578d
# Initializes the gcc toolset for the given version. If necessary, command may
Packit 58578d
# be used to specify where the compiler is located. The parameter 'options' is a
Packit 58578d
# space-delimited list of options, each one specified as
Packit 58578d
# <option-name>option-value. Valid option names are: cxxflags, linkflags and
Packit 58578d
# linker-type. Accepted linker-type values are aix, darwin, gnu, hpux, osf or
Packit 58578d
# sun and the default value will be selected based on the current OS.
Packit 58578d
# Example:
Packit 58578d
#   using gcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ;
Packit 58578d
#
Packit 58578d
# The compiler command to use is detected in three steps:
Packit 58578d
# 1) If an explicit command is specified by the user, it will be used and must
Packit 58578d
#    be available.
Packit 58578d
# 2) If only a certain version is specified, it is enforced:
Packit 58578d
#    - either the 'g++-VERSION' command must be available
Packit 58578d
#    - or the default command 'g++' must be available and match the exact
Packit 58578d
#      version.
Packit 58578d
# 3) Without user-provided restrictions use default 'g++'.
Packit 58578d
#
Packit 58578d
rule init ( version ? : command * : options * : requirement * )
Packit 58578d
{
Packit 58578d
    #1): use user-provided command
Packit 58578d
    local tool-command = ;
Packit 58578d
    if $(command)
Packit 58578d
    {
Packit 58578d
        tool-command = [ common.get-invocation-command-nodefault gcc : g++ :
Packit 58578d
            $(command) ] ;
Packit 58578d
        if ! $(tool-command)
Packit 58578d
        {
Packit 58578d
            import errors ;
Packit 58578d
            errors.error toolset gcc initialization:
Packit 58578d
                : provided command '$(command)' not found
Packit 58578d
                : initialized from [ errors.nearest-user-location ] ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
    #2): enforce user-provided version
Packit 58578d
    else if $(version)
Packit 58578d
    {
Packit 58578d
        tool-command = [ common.get-invocation-command-nodefault gcc :
Packit 58578d
            "g++-$(version[1])" ] ;
Packit 58578d
Packit 58578d
        #2.1) fallback: check whether "g++" reports the requested version
Packit 58578d
        if ! $(tool-command)
Packit 58578d
        {
Packit 58578d
            tool-command = [ common.get-invocation-command-nodefault gcc : g++ ]
Packit 58578d
                ;
Packit 58578d
            if $(tool-command)
Packit 58578d
            {
Packit 58578d
                local tool-command-string = \"$(tool-command)\" ;
Packit 58578d
                tool-command-string = $(tool-command-string:J=" ") ;
Packit 58578d
                local tool-version = [ MATCH "^([0-9.]+)" :
Packit 58578d
                    [ SHELL "$(tool-command-string) -dumpversion" ] ] ;
Packit 58578d
                if $(tool-version) != $(version)
Packit 58578d
                {
Packit 58578d
                    # Permit a match betwen a two-digit version specified by the
Packit 58578d
                    # user (e.g. 4.4) and a 3-digit version reported by gcc.
Packit 58578d
                    # Since only two digits are present in the binary name
Packit 58578d
                    # anyway, insisting that user specify the 3-digit version
Packit 58578d
                    # when configuring Boost.Build, while it is not required on
Packit 58578d
                    # the command line, would be strange.
Packit 58578d
                    local stripped = [ MATCH "^([0-9]+\.[0-9]+).*" :
Packit 58578d
                        $(tool-version) ] ;
Packit 58578d
                    if $(stripped) != $(version)
Packit 58578d
                    {
Packit 58578d
                        import errors ;
Packit 58578d
                        errors.error toolset gcc initialization:
Packit 58578d
                            : version '$(version)' requested but
Packit 58578d
                                'g++-$(version)' not found and version
Packit 58578d
                                '$(tool-version)' of default '$(tool-command)'
Packit 58578d
                                does not match
Packit 58578d
                            : initialized from [ errors.nearest-user-location ]
Packit 58578d
                            ;
Packit 58578d
                        tool-command = ;
Packit 58578d
                    }
Packit 58578d
                    # Use full 3-digit version to be compatible with the
Packit 58578d
                    # 'using gcc ;' case
Packit 58578d
                    version = $(tool-version) ;
Packit 58578d
                }
Packit 58578d
            }
Packit 58578d
            else
Packit 58578d
            {
Packit 58578d
                import errors ;
Packit 58578d
                errors.error toolset gcc initialization:
Packit 58578d
                    : version '$(version)' requested but neither
Packit 58578d
                        'g++-$(version)' nor default 'g++' found
Packit 58578d
                    : initialized from [ errors.nearest-user-location ] ;
Packit 58578d
            }
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
    #3) default: no command and no version specified, try using "g++"
Packit 58578d
    else
Packit 58578d
    {
Packit 58578d
        tool-command = [ common.get-invocation-command-nodefault gcc : g++ ] ;
Packit 58578d
        if ! $(tool-command)
Packit 58578d
        {
Packit 58578d
            import errors ;
Packit 58578d
            errors.error toolset gcc initialization:
Packit 58578d
                : no command provided, default command 'g++' not found
Packit 58578d
                : initialized from [ errors.nearest-user-location ] ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
Packit 58578d
Packit 58578d
    # Information about the gcc command...
Packit 58578d
    #   The command.
Packit 58578d
    local command = $(tool-command) ;
Packit 58578d
    #   The 'command' variable can have multiple elements but when calling the    
Packit 58578d
    # SHELL builtin we need a single string, and we need to quote elements
Packit 58578d
    # with spaces.
Packit 58578d
    local command-string = \"$(command)\" ;
Packit 58578d
    command-string = $(command-string:J=" ") ;
Packit 58578d
    #   The root directory of the tool install.
Packit 58578d
    local root = [ feature.get-values <root> : $(options) ] ;
Packit 58578d
    #   The bin directory where to find the command to execute.
Packit 58578d
    local bin ;
Packit 58578d
    #   The compiler flavor.
Packit 58578d
    local flavor = [ feature.get-values <flavor> : $(options) ] ;
Packit 58578d
    #   vxworks build on windows uses csh that is neither mingw or cygwin
Packit 58578d
    if [ feature.get-values <target-os> : $(options) ] = vxworks
Packit 58578d
    {
Packit 58578d
        flavor ?= vxworks ;
Packit 58578d
    }
Packit 58578d
    #   Autodetect the root and bin dir if not given.
Packit 58578d
    if $(command)
Packit 58578d
    {
Packit 58578d
        bin ?= [ common.get-absolute-tool-path $(command[-1]) ] ;
Packit 58578d
        root ?= $(bin:D) ;
Packit 58578d
    }
Packit 58578d
    #   Autodetect the version and flavor if not given.
Packit 58578d
    if $(command)
Packit 58578d
    {
Packit 58578d
        local machine = [ MATCH "^([^ ]+)" :
Packit 58578d
            [ SHELL "$(command-string) -dumpmachine" ] ] ;
Packit 58578d
        version ?= [ MATCH "^([0-9.]+)" :
Packit 58578d
            [ SHELL "$(command-string) -dumpversion" ] ] ;
Packit 58578d
        switch $(machine:L)
Packit 58578d
        {
Packit 58578d
            case *mingw* : flavor ?= mingw ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
Packit 58578d
    local condition ;
Packit 58578d
    if $(flavor)
Packit 58578d
    {
Packit 58578d
        condition = flavor $(flavor) ;
Packit 58578d
    }
Packit 58578d
    condition = [ common.check-init-parameters gcc $(requirement) : version $(version)
Packit 58578d
        : $(condition) ] ;
Packit 58578d
Packit 58578d
    common.handle-options gcc : $(condition) : $(command) : $(options) ;
Packit 58578d
Packit 58578d
    init-link-flags gcc "" $(condition) ;
Packit 58578d
Packit 58578d
    # If gcc is installed in a non-standard location, we would need to add
Packit 58578d
    # LD_LIBRARY_PATH when running programs created with it (for unit-test/run
Packit 58578d
    # rules).
Packit 58578d
    if $(command)
Packit 58578d
    {
Packit 58578d
        # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries
Packit 58578d
        # and all must be added to LD_LIBRARY_PATH. The linker will pick the
Packit 58578d
        # right onces. Note that we do not provide a clean way to build a 32-bit
Packit 58578d
        # binary using a 64-bit compiler, but user can always pass -m32
Packit 58578d
        # manually.
Packit 58578d
        local lib_path = $(root)/bin $(root)/lib $(root)/lib32 $(root)/lib64 ;
Packit 58578d
        if $(.debug-configuration)
Packit 58578d
        {
Packit 58578d
            ECHO notice: using gcc libraries :: $(condition) :: $(lib_path) ;
Packit 58578d
        }
Packit 58578d
        toolset.flags gcc.link RUN_PATH $(condition) : $(lib_path) ;
Packit 58578d
    }
Packit 58578d
Packit 58578d
    # If we are not using a system gcc installation we should adjust the various
Packit 58578d
    # programs as needed to prefer using their installation specific versions.
Packit 58578d
    # This is essential for correct use of MinGW and for cross-compiling.
Packit 58578d
Packit 58578d
    # - Archive builder.
Packit 58578d
    local archiver = [ common.get-invocation-command gcc
Packit 58578d
        : [ .get-prog-name $(command-string) : ar : $(flavor) ]
Packit 58578d
        : [ feature.get-values <archiver> : $(options) ]
Packit 58578d
        : $(bin)
Packit 58578d
        : search-path ] ;
Packit 58578d
    toolset.flags gcc.archive .AR $(condition) : $(archiver[1]) ;
Packit 58578d
    if $(.debug-configuration)
Packit 58578d
    {
Packit 58578d
        ECHO notice: using gcc archiver :: $(condition) :: $(archiver[1]) ;
Packit 58578d
    }
Packit 58578d
Packit 58578d
    # - Ranlib.
Packit 58578d
    local ranlib = [ common.get-invocation-command gcc
Packit 58578d
        : [ .get-prog-name $(command-string) : ranlib : $(flavor) ]
Packit 58578d
        : [ feature.get-values <ranlib> : $(options) ]
Packit 58578d
        : $(bin)
Packit 58578d
        : search-path ] ;
Packit 58578d
    toolset.flags gcc.archive .RANLIB $(condition) : $(ranlib[1]) ;
Packit 58578d
    if $(.debug-configuration)
Packit 58578d
    {
Packit 58578d
        ECHO notice: using gcc ranlib :: $(condition) :: $(ranlib[1]) ;
Packit 58578d
    }
Packit 58578d
Packit 58578d
    # - Resource compiler.
Packit 58578d
    local rc = [ common.get-invocation-command-nodefault gcc : windres :
Packit 58578d
        [ feature.get-values <rc> : $(options) ] : $(bin) : search-path ] ;
Packit 58578d
    local rc-type = [ feature.get-values <rc-type> : $(options) ] ;
Packit 58578d
    rc-type ?= windres ;
Packit 58578d
    if ! $(rc)
Packit 58578d
    {
Packit 58578d
        # If we can not find an RC compiler we fallback to a null one that
Packit 58578d
        # creates empty object files. This allows the same Jamfiles to work
Packit 58578d
        # across the board. The null RC uses assembler to create the empty
Packit 58578d
        # objects, so configure that.
Packit 58578d
        rc = [ common.get-invocation-command gcc : as : : $(bin) : search-path ]
Packit 58578d
            ;
Packit 58578d
        rc-type = null ;
Packit 58578d
    }
Packit 58578d
    rc.configure $(rc) : $(condition) : <rc-type>$(rc-type) ;
Packit 58578d
    
Packit 58578d
    toolset.flags gcc VERSION $(condition) : [ regex.split $(version) "[.]" ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
if [ os.name ] = NT
Packit 58578d
{
Packit 58578d
    # This causes single-line command invocation to not go through .bat files,
Packit 58578d
    # thus avoiding command-line length limitations.
Packit 58578d
    # TODO: Set JAMSHELL on specific targets instead of globally.
Packit 58578d
    JAMSHELL = % ;
Packit 58578d
}
Packit 58578d
Packit 58578d
# Uses -print-prog-name to get the name of the tool.
Packit 58578d
# Converts the path to native form if using cygwin.
Packit 58578d
rule .get-prog-name ( command-string : tool : flavor ? )
Packit 58578d
{
Packit 58578d
    local prog-name = [ NORMALIZE_PATH [ MATCH "(.*)[\n]+" :
Packit 58578d
        [ SHELL "$(command-string) -print-prog-name=$(tool)" ] ] ] ;
Packit 58578d
Packit 58578d
    if $(flavor) != vxworks && $(flavor) != mingw && [ os.name ] = NT
Packit 58578d
    {
Packit 58578d
        prog-name = [ cygwin.cygwin-to-windows-path $(prog-name) ] ;
Packit 58578d
    }
Packit 58578d
    return $(prog-name) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### Functions that set options on the targets.
Packit 58578d
###
Packit 58578d
Packit 58578d
rule set-fpic-options ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    local link = [ feature.get-values link : $(properties) ] ;
Packit 58578d
    if $(link) = shared
Packit 58578d
    {
Packit 58578d
        local target-os = [ feature.get-values target-os : $(properties) ] ;
Packit 58578d
Packit 58578d
        # This logic will add -fPIC for all compilations:
Packit 58578d
        #
Packit 58578d
        # lib a : a.cpp b ;
Packit 58578d
        # obj b : b.cpp ;
Packit 58578d
        # exe c : c.cpp a d ;
Packit 58578d
        # obj d : d.cpp ;
Packit 58578d
        #
Packit 58578d
        # This all is fine, except that 'd' will be compiled with -fPIC even
Packit 58578d
        # though it is not needed, as 'd' is used only in exe. However, it is
Packit 58578d
        # hard to detect where a target is going to be used. Alternatively, we
Packit 58578d
        # can set -fPIC only when main target type is LIB but than 'b' would be
Packit 58578d
        # compiled without -fPIC which would lead to link errors on x86-64. So,
Packit 58578d
        # compile everything with -fPIC.
Packit 58578d
        #
Packit 58578d
        # Yet another alternative would be to create a propagated <sharedable>
Packit 58578d
        # feature and set it when building shared libraries, but that would be
Packit 58578d
        # hard to implement and would increase the target path length even more.
Packit 58578d
Packit 58578d
        # On Windows, fPIC is the default, and specifying -fPIC explicitly leads
Packit 58578d
        # to a warning.
Packit 58578d
        if ! $(target-os) in cygwin windows
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -fPIC ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
rule set-address-model-options ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    local model = [ feature.get-values address-model : $(properties) ] ;
Packit 58578d
    if $(model)
Packit 58578d
    {
Packit 58578d
        local option ;
Packit 58578d
        local target-os = [ feature.get-values target-os : $(properties) ] ;
Packit 58578d
        if $(target-os) = aix
Packit 58578d
        {
Packit 58578d
            if $(model) = 32
Packit 58578d
            {
Packit 58578d
                option = -maix32 ;
Packit 58578d
            }
Packit 58578d
            else
Packit 58578d
            {
Packit 58578d
                option = -maix64 ;
Packit 58578d
            }
Packit 58578d
        }
Packit 58578d
        else if $(target-os) = hpux
Packit 58578d
        {
Packit 58578d
            if $(model) = 32
Packit 58578d
            {
Packit 58578d
                option = -milp32 ;
Packit 58578d
            }
Packit 58578d
            else
Packit 58578d
            {
Packit 58578d
                option = -mlp64 ;
Packit 58578d
            }
Packit 58578d
        }
Packit 58578d
        else
Packit 58578d
        {
Packit 58578d
            local arch = [ feature.get-values architecture : $(properties) ] ;
Packit 58578d
            if $(arch) = power || $(arch) = sparc || $(arch) = x86
Packit 58578d
            {
Packit 58578d
                if $(model) = 32
Packit 58578d
                {
Packit 58578d
                    option = -m32 ;
Packit 58578d
                }
Packit 58578d
                else if $(model) = 64
Packit 58578d
                {
Packit 58578d
                    option = -m64 ;
Packit 58578d
                }
Packit 58578d
            }
Packit 58578d
            # For darwin, the model can be 32_64. darwin.jam will handle that
Packit 58578d
            # on its own.
Packit 58578d
        }
Packit 58578d
        OPTIONS on $(targets) += $(option) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
rule set-threading-options ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    local threading = [ feature.get-values threading : $(properties) ] ;
Packit 58578d
    if $(threading) = multi
Packit 58578d
    {
Packit 58578d
        local target-os = [ feature.get-values target-os : $(properties) ] ;
Packit 58578d
        local host-os = [ feature.get-values host-os : $(properties) ] ;
Packit 58578d
        local toolset = [ feature.get-values toolset : $(properties) ] ;
Packit 58578d
        local option ;
Packit 58578d
        local libs ;
Packit 58578d
        
Packit 58578d
        if $(toolset) = clang && $(target-os) = windows
Packit 58578d
        {
Packit 58578d
            option = -pthread ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        switch $(target-os)
Packit 58578d
        {
Packit 58578d
            case android : # No threading options, everything is in already.
Packit 58578d
            case windows : option ?= -mthreads ;
Packit 58578d
            case cygwin  : option ?= -mthreads ;
Packit 58578d
            case solaris : option ?= -pthreads ; libs = rt ;
Packit 58578d
            case beos    : # No threading options.
Packit 58578d
            case haiku   : # No threading options.
Packit 58578d
            case *bsd    : option ?= -pthread ;  # There is no -lrt on BSD.
Packit 58578d
            case sgi     : # gcc on IRIX does not support multi-threading.
Packit 58578d
            case darwin  : # No threading options.
Packit 58578d
            case vxworks : # No threading options.  
Packit 58578d
            case *       : option ?= -pthread ; libs = rt ;
Packit 58578d
        }
Packit 58578d
        if $(option)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += $(option) ;
Packit 58578d
        }
Packit 58578d
        if $(libs)
Packit 58578d
        {
Packit 58578d
            FINDLIBS-SA on $(targets) += $(libs) ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
local rule zero-pad ( numbers * )
Packit 58578d
{
Packit 58578d
    local result ;
Packit 58578d
    for local n in $(numbers)
Packit 58578d
    {
Packit 58578d
        switch $(n)
Packit 58578d
        {
Packit 58578d
            case ???? : result += $(n) ;
Packit 58578d
            case ??? : result += 0$(n) ;
Packit 58578d
            case ?? : result += 00$(n) ;
Packit 58578d
            case ? : result += 000$(n) ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
    return $(result) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule set-cxxstd-options ( targets * : sources * : properties * : action )
Packit 58578d
{
Packit 58578d
    local *targets = [ $(action).targets ] ;
Packit 58578d
    local *sources = [ $(action).sources ] ;
Packit 58578d
    local target-type = [ $(*targets[1]).type ] ;
Packit 58578d
    local source-type = [ $(*sources[1]).type ] ;
Packit 58578d
    local toolset = [ feature.get-values toolset : $(properties) ] ;
Packit 58578d
    local version = [ zero-pad [ on $(targets[1]) return $(VERSION) ] ] ;
Packit 58578d
    version = $(version[1]).$(version[2]) ;
Packit 58578d
    local cxxstd = [ feature.get-values cxxstd : $(properties) ] ;
Packit 58578d
    local cxxstd-dialect = [ feature.get-values cxxstd-dialect : $(properties) ] ;
Packit 58578d
    cxxstd-dialect ?= iso ;
Packit 58578d
    switch $(cxxstd-dialect)
Packit 58578d
    {
Packit 58578d
        case gnu : cxxstd-dialect = gnu++ ;
Packit 58578d
        case iso : cxxstd-dialect = c++ ;
Packit 58578d
        case * :
Packit 58578d
        errors.warning Unknown cxxstd-dialect $(cxxstd-dialect:E=?) .. using
Packit 58578d
            ISO dialect instead. ;
Packit 58578d
        cxxstd-dialect = c++ ;
Packit 58578d
    }
Packit 58578d
    local option ;
Packit 58578d
    if $(cxxstd) = latest
Packit 58578d
    {
Packit 58578d
        if $(toolset) = gcc
Packit 58578d
        {
Packit 58578d
            if $(version) >= 0008.0000 { option = 2a ; }
Packit 58578d
            else if $(version) >= 0005.0001 { option = 1z ; }
Packit 58578d
            else if $(version) >= 0004.0008 { option = 1y ; }
Packit 58578d
            else if $(version) >= 0004.0007 { option = 11 ; }
Packit 58578d
            else if $(version) >= 0003.0003 { option = 98 ; }
Packit 58578d
        }
Packit 58578d
        if $(toolset) = clang
Packit 58578d
        {
Packit 58578d
            if $(version) >= 0003.0005 { option = 1z ; }
Packit 58578d
            if $(version) >= 0003.0004 { option = 14 ; }
Packit 58578d
            if $(version) >= 0003.0003 { option = 11 ; }
Packit 58578d
            option ?= 03 ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
    else
Packit 58578d
    {
Packit 58578d
        option = $(cxxstd) ;
Packit 58578d
    }
Packit 58578d
    if $(source-type) in CPP || $(target-type) in CPP_PCH EXE SHARED_LIB
Packit 58578d
    {
Packit 58578d
        OPTIONS on $(targets) += -std=$(cxxstd-dialect)$(option) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### Compiling generators and actions.
Packit 58578d
###
Packit 58578d
Packit 58578d
class gcc-c-compiling-generator : C-compiling-generator
Packit 58578d
{
Packit 58578d
    rule action-class ( )
Packit 58578d
    {
Packit 58578d
        return gcc-c-compile-action ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
class gcc-c-compile-action : compile-action
Packit 58578d
{
Packit 58578d
    import gcc ;
Packit 58578d
    
Packit 58578d
    rule execute ( action-name targets + : sources * : properties * )
Packit 58578d
    {
Packit 58578d
        gcc.set-threading-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-fpic-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-address-model-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-cxxstd-options $(targets) : $(sources) : $(properties) : $(__name__) ;
Packit 58578d
        compile-action.execute $(action-name) $(targets) : $(sources) : $(properties) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
local rule register-gcc-c-compiler ( id : source-types + : target-types + : requirements *
Packit 58578d
    : optional-properties * )
Packit 58578d
{
Packit 58578d
    generators.register [ new gcc-c-compiling-generator $(id) : $(source-types) :
Packit 58578d
        $(target-types) : $(requirements) : $(optional-properties) ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
register-gcc-c-compiler gcc.compile.c++.preprocess : CPP : PREPROCESSED_CPP : <toolset>gcc ;
Packit 58578d
register-gcc-c-compiler gcc.compile.c.preprocess   : C   : PREPROCESSED_C   : <toolset>gcc ;
Packit 58578d
register-gcc-c-compiler gcc.compile.c++ : CPP : OBJ : <toolset>gcc ;
Packit 58578d
register-gcc-c-compiler gcc.compile.c   : C   : OBJ : <toolset>gcc ;
Packit 58578d
register-gcc-c-compiler gcc.compile.asm : ASM : OBJ : <toolset>gcc ;
Packit 58578d
Packit 58578d
class gcc-fortran-compiling-generator : fortran-compiling-generator
Packit 58578d
{
Packit 58578d
    rule action-class ( )
Packit 58578d
    {
Packit 58578d
        return gcc-fortran-compile-action ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
class gcc-fortran-compile-action : compile-action
Packit 58578d
{
Packit 58578d
    import gcc ;
Packit 58578d
    
Packit 58578d
    rule execute ( action-name targets + : sources * : properties * )
Packit 58578d
    {
Packit 58578d
        gcc.set-threading-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-fpic-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-address-model-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-cxxstd-options $(targets) : $(sources) : $(properties) : $(__name__) ;
Packit 58578d
        compile-action.execute $(action-name) $(targets) : $(sources) : $(properties) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
generators.register [ new gcc-fortran-compiling-generator
Packit 58578d
    gcc.compile.fortran : FORTRAN FORTRAN90 : OBJ : <toolset>gcc ] ;
Packit 58578d
Packit 58578d
rule compile.c++.preprocess ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    # Some extensions are compiled as C++ by default. For others, we need to
Packit 58578d
    # pass -x c++. We could always pass -x c++ but distcc does not work with it.
Packit 58578d
    if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C
Packit 58578d
    {
Packit 58578d
        LANG on $(<) = "-x c++" ;
Packit 58578d
    }
Packit 58578d
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.c.preprocess ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    # If we use the name g++ then default file suffix -> language mapping does
Packit 58578d
    # not work. So have to pass -x option. Maybe, we can work around this by
Packit 58578d
    # allowing the user to specify both C and C++ compiler names.
Packit 58578d
    #if $(>:S) != .c
Packit 58578d
    #{
Packit 58578d
        LANG on $(<) = "-x c" ;
Packit 58578d
    #}
Packit 58578d
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.c++ ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    # Some extensions are compiled as C++ by default. For others, we need to
Packit 58578d
    # pass -x c++. We could always pass -x c++ but distcc does not work with it.
Packit 58578d
    if ! $(>:S) in .cc .cp .cxx .cpp .c++ .C
Packit 58578d
    {
Packit 58578d
        LANG on $(<) = "-x c++" ;
Packit 58578d
    }
Packit 58578d
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.c ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    # If we use the name g++ then default file suffix -> language mapping does
Packit 58578d
    # not work. So have to pass -x option. Maybe, we can work around this by
Packit 58578d
    # allowing the user to specify both C and C++ compiler names.
Packit 58578d
    #if $(>:S) != .c
Packit 58578d
    #{
Packit 58578d
        LANG on $(<) = "-x c" ;
Packit 58578d
    #}
Packit 58578d
    DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.fortran ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c++ bind PCH_FILE
Packit 58578d
{
Packit 0fd731
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)"
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c bind PCH_FILE
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c++.preprocess bind PCH_FILE
Packit 58578d
{
Packit 0fd731
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>:W)" -E >"$(<:W)"
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c.preprocess bind PCH_FILE
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>)" -E >$(<)
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.fortran
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.asm ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    LANG on $(<) = "-x assembler-with-cpp" ;
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.asm
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### Preconpiled header use and generation.
Packit 58578d
###
Packit 58578d
Packit 58578d
# The compiler looks for a precompiled header in each directory just before it
Packit 58578d
# looks for the include file in that directory. The name searched for is the
Packit 58578d
# name specified in the #include directive with ".gch" suffix appended. The
Packit 58578d
# logic in gcc-pch-generator will make sure that the BASE_PCH suffix is appended
Packit 58578d
# to the full header name.
Packit 58578d
Packit 58578d
type.set-generated-target-suffix PCH : <toolset>gcc : gch ;
Packit 58578d
Packit 58578d
# GCC-specific pch generator.
Packit 58578d
class gcc-pch-generator : pch-generator
Packit 58578d
{
Packit 58578d
    import project ;
Packit 58578d
    import property-set ;
Packit 58578d
    import type ;
Packit 58578d
Packit 58578d
    rule run-pch ( project name ? : property-set : sources + )
Packit 58578d
    {
Packit 58578d
        # Find the header in sources. Ignore any CPP sources.
Packit 58578d
        local header ;
Packit 58578d
        for local s in $(sources)
Packit 58578d
        {
Packit 58578d
            if [ type.is-derived [ $(s).type ] H ]
Packit 58578d
            {
Packit 58578d
                header = $(s) ;
Packit 58578d
            }
Packit 58578d
        }
Packit 58578d
Packit 58578d
        # Error handling: base header file name should be the same as the base
Packit 58578d
        # precompiled header name.
Packit 58578d
        local header-name = [ $(header).name ] ;
Packit 58578d
        local header-basename = $(header-name:B) ;
Packit 58578d
        if $(header-basename) != $(name)
Packit 58578d
        {
Packit 58578d
            local location = [ $(project).project-module ] ;
Packit 58578d
            import errors : user-error : errors.user-error ;
Packit 58578d
            errors.user-error "in" $(location): pch target name '$(name)' should
Packit 58578d
                be the same as the base name of header file '$(header-name)' ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        local pch-file = [ generator.run $(project) $(name) : $(property-set)
Packit 58578d
            : $(header) ] ;
Packit 58578d
Packit 58578d
        # Return result of base class and pch-file property as
Packit 58578d
        # usage-requirements.
Packit 58578d
        return
Packit 58578d
            [ property-set.create <pch-file>$(pch-file) <cflags>-Winvalid-pch ]
Packit 58578d
            $(pch-file)
Packit 58578d
          ;
Packit 58578d
    }
Packit 58578d
Packit 58578d
    # Calls the base version specifying source's name as the name of the created
Packit 58578d
    # target. As a result, the PCH will be named whatever.hpp.gch, and not
Packit 58578d
    # whatever.gch.
Packit 58578d
    rule generated-targets ( sources + : property-set : project name ? )
Packit 58578d
    {
Packit 58578d
        name = [ $(sources[1]).name ] ;
Packit 58578d
        return [ generator.generated-targets $(sources)
Packit 58578d
          : $(property-set) : $(project) $(name) ] ;
Packit 58578d
    }
Packit 58578d
    
Packit 58578d
    rule action-class ( )
Packit 58578d
    {
Packit 58578d
        return gcc-pch-compile-action ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
class gcc-pch-compile-action : compile-action
Packit 58578d
{
Packit 58578d
    import gcc ;
Packit 58578d
    
Packit 58578d
    rule execute ( action-name targets + : sources * : properties * )
Packit 58578d
    {
Packit 58578d
        gcc.set-threading-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-fpic-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-address-model-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-cxxstd-options $(targets) : $(sources) : $(properties) : $(__name__) ;
Packit 58578d
        compile-action.execute $(action-name) $(targets) : $(sources) : $(properties) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
# Note: the 'H' source type will catch both '.h' header and '.hpp' header. The
Packit 58578d
# latter have HPP type, but HPP type is derived from H. The type of compilation
Packit 58578d
# is determined entirely by the destination type.
Packit 58578d
generators.register [ new gcc-pch-generator gcc.compile.c.pch   : H :   C_PCH : <pch>on <toolset>gcc ] ;
Packit 58578d
generators.register [ new gcc-pch-generator gcc.compile.c++.pch : H : CPP_PCH : <pch>on <toolset>gcc ] ;
Packit 58578d
Packit 58578d
# Override default do-nothing generators.
Packit 58578d
generators.override gcc.compile.c.pch   : pch.default-c-pch-generator   ;
Packit 58578d
generators.override gcc.compile.c++.pch : pch.default-cpp-pch-generator ;
Packit 58578d
Packit 58578d
toolset.flags gcc.compile PCH_FILE <pch>on : <pch-file> ;
Packit 58578d
Packit 58578d
rule compile.c++.pch ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c++.pch
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
Packit 58578d
}
Packit 58578d
Packit 58578d
rule compile.c.pch ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
}
Packit 58578d
Packit 58578d
actions compile.c.pch
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### General options, like optimization.
Packit 58578d
###
Packit 58578d
Packit 58578d
# Declare flags and action for compilation.
Packit 0fd731
toolset.flags gcc.compile OPTIONS <optimization>off   :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <optimization>speed :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <optimization>space :  ;
Packit 58578d
Packit 0fd731
toolset.flags gcc.compile OPTIONS <inlining>off  :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <inlining>on   :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <inlining>full :  ;
Packit 58578d
Packit 0fd731
toolset.flags gcc.compile OPTIONS <warnings>off :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <warnings>on  :  ;
Packit 0fd731
toolset.flags gcc.compile OPTIONS <warnings>all :  ;
Packit 58578d
toolset.flags gcc.compile OPTIONS <warnings-as-errors>on : -Werror ;
Packit 58578d
Packit 58578d
toolset.flags gcc.compile OPTIONS <debug-symbols>on : -g ;
Packit 58578d
toolset.flags gcc.compile OPTIONS <profiling>on : -pg ;
Packit 58578d
Packit 58578d
toolset.flags gcc.compile.c++ OPTIONS <rtti>off : -fno-rtti ;
Packit 58578d
toolset.flags gcc.compile.c++ OPTIONS <exception-handling>off : -fno-exceptions ;
Packit 58578d
Packit 58578d
###
Packit 58578d
### User free feature options.
Packit 58578d
###
Packit 58578d
Packit 58578d
toolset.flags gcc.compile USER_OPTIONS <cflags> ;
Packit 58578d
toolset.flags gcc.compile.c++ USER_OPTIONS <cxxflags> ;
Packit 58578d
toolset.flags gcc.compile.asm USER_OPTIONS <asmflags> ;
Packit 58578d
toolset.flags gcc.compile DEFINES <define> ;
Packit 58578d
toolset.flags gcc.compile INCLUDES <include> ;
Packit 58578d
toolset.flags gcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ;
Packit 58578d
toolset.flags gcc.compile.fortran USER_OPTIONS <fflags> ;
Packit 58578d
Packit 58578d
###
Packit 58578d
### Linking generators and actions.
Packit 58578d
###
Packit 58578d
Packit 58578d
# Class checking that we do not try to use the <runtime-link>static property
Packit 58578d
# while creating or using a shared library, since it is not supported by
Packit 58578d
# gcc/libc.
Packit 58578d
class gcc-linking-generator : unix-linking-generator
Packit 58578d
{
Packit 58578d
    rule run ( project name ? : property-set : sources + )
Packit 58578d
    {
Packit 58578d
        local target-os = [ $(property-set).get <target-os> ] ;
Packit 58578d
        local no-static-link = true ;
Packit 58578d
        switch $(target-os)
Packit 58578d
        {
Packit 58578d
            case vms : no-static-link = ;
Packit 58578d
            case windows : no-static-link = ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        local properties = [ $(property-set).raw ] ;
Packit 58578d
        local reason ;
Packit 58578d
        if $(no-static-link) && <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            if <link>shared in $(properties)
Packit 58578d
            {
Packit 58578d
                reason = On gcc, DLLs can not be built with
Packit 58578d
                    '<runtime-link>static'. ;
Packit 58578d
            }
Packit 58578d
            else if [ type.is-derived $(self.target-types[1]) EXE ]
Packit 58578d
            {
Packit 58578d
                for local s in $(sources)
Packit 58578d
                {
Packit 58578d
                    local type = [ $(s).type ] ;
Packit 58578d
                    if $(type) && [ type.is-derived $(type) SHARED_LIB ]
Packit 58578d
                    {
Packit 58578d
                        reason = On gcc, using DLLs together with the
Packit 58578d
                            '<runtime-link>static' option is not possible. ;
Packit 58578d
                    }
Packit 58578d
                }
Packit 58578d
            }
Packit 58578d
        }
Packit 58578d
        if $(reason)
Packit 58578d
        {
Packit 58578d
            ECHO warning: $(reason) ;
Packit 58578d
            ECHO warning: It is suggested to use '<runtime-link>static' together
Packit 58578d
                with '<link>static'. ;
Packit 58578d
        }
Packit 58578d
        else
Packit 58578d
        {
Packit 58578d
            return [ unix-linking-generator.run $(project) $(name) :
Packit 58578d
                $(property-set) : $(sources) ] ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
    
Packit 58578d
    rule action-class ( )
Packit 58578d
    {
Packit 58578d
        return gcc-link-action ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
class gcc-link-action : action
Packit 58578d
{
Packit 58578d
    import gcc ;
Packit 58578d
    
Packit 58578d
    rule execute ( action-name targets + : sources * : properties * )
Packit 58578d
    {
Packit 58578d
        gcc.set-threading-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-fpic-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-address-model-options $(targets) : $(sources) : $(properties) ;
Packit 58578d
        gcc.set-cxxstd-options $(targets) : $(sources) : $(properties) : $(__name__) ;
Packit 58578d
        gcc.set-link-options $(action-name) $(targets) : $(sources) : $(properties) ;
Packit 58578d
        action.execute $(action-name) $(targets) : $(sources) : $(properties) ;
Packit 58578d
    }
Packit 58578d
}
Packit 58578d
Packit 58578d
# The set of permissible input types is different on mingw. So, define two sets
Packit 58578d
# of generators, with mingw generators selected when target-os=windows.
Packit 58578d
Packit 58578d
local g ;
Packit 58578d
g = [ new gcc-linking-generator gcc.mingw.link
Packit 58578d
      : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
Packit 58578d
      : EXE
Packit 58578d
      : <toolset>gcc <target-os>windows ] ;
Packit 58578d
$(g).set-rule-name gcc.link ;
Packit 58578d
generators.register $(g) ;
Packit 58578d
Packit 58578d
g = [ new gcc-linking-generator gcc.mingw.link.dll
Packit 58578d
      : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
Packit 58578d
      : IMPORT_LIB SHARED_LIB
Packit 58578d
      : <toolset>gcc <target-os>windows ] ;
Packit 58578d
$(g).set-rule-name gcc.link.dll ;
Packit 58578d
generators.register $(g) ;
Packit 58578d
Packit 58578d
generators.register
Packit 58578d
  [ new gcc-linking-generator gcc.link
Packit 58578d
      : LIB OBJ
Packit 58578d
      : EXE
Packit 58578d
      : <toolset>gcc ] ;
Packit 58578d
generators.register
Packit 58578d
  [ new gcc-linking-generator gcc.link.dll
Packit 58578d
      : LIB OBJ
Packit 58578d
      : SHARED_LIB
Packit 58578d
      : <toolset>gcc ] ;
Packit 58578d
Packit 58578d
generators.override gcc.mingw.link : gcc.link ;
Packit 58578d
generators.override gcc.mingw.link.dll : gcc.link.dll ;
Packit 58578d
Packit 58578d
# Cygwin is similar to msvc and mingw in that it uses import libraries. While in
Packit 58578d
# simple cases, it can directly link to a shared library, it is believed to be
Packit 58578d
# slower, and not always possible. Define cygwin-specific generators here.
Packit 58578d
Packit 58578d
g = [ new gcc-linking-generator gcc.cygwin.link
Packit 58578d
      : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
Packit 58578d
      : EXE
Packit 58578d
      : <toolset>gcc <target-os>cygwin ] ;
Packit 58578d
$(g).set-rule-name gcc.link ;
Packit 58578d
generators.register $(g) ;
Packit 58578d
Packit 58578d
g = [ new gcc-linking-generator gcc.cygwin.link.dll
Packit 58578d
      : OBJ SEARCHED_LIB STATIC_LIB IMPORT_LIB
Packit 58578d
      : IMPORT_LIB SHARED_LIB
Packit 58578d
      : <toolset>gcc <target-os>cygwin ] ;
Packit 58578d
$(g).set-rule-name gcc.link.dll ;
Packit 58578d
generators.register $(g) ;
Packit 58578d
Packit 58578d
generators.override gcc.cygwin.link : gcc.link ;
Packit 58578d
generators.override gcc.cygwin.link.dll : gcc.link.dll ;
Packit 58578d
Packit 58578d
# Declare flags for linking.
Packit 58578d
# First, the common flags.
Packit 58578d
toolset.flags gcc.link OPTIONS <debug-symbols>on : -g ;
Packit 58578d
toolset.flags gcc.link OPTIONS <profiling>on : -pg ;
Packit 58578d
toolset.flags gcc.link USER_OPTIONS <linkflags> ;
Packit 58578d
toolset.flags gcc.link LINKPATH <library-path> ;
Packit 58578d
toolset.flags gcc.link FINDLIBS-ST <find-static-library> ;
Packit 58578d
toolset.flags gcc.link FINDLIBS-SA <find-shared-library> ;
Packit 58578d
toolset.flags gcc.link LIBRARIES <library-file> ;
Packit 58578d
Packit 58578d
toolset.flags gcc.link.dll .IMPLIB-COMMAND <target-os>windows : "-Wl,--out-implib," ;
Packit 58578d
toolset.flags gcc.link.dll .IMPLIB-COMMAND <target-os>cygwin : "-Wl,--out-implib," ;
Packit 58578d
Packit 58578d
# Now, the vendor specific flags.
Packit 58578d
# The parameter linker can be either aix, darwin, gnu, hpux, osf or sun.
Packit 58578d
rule init-link-flags ( toolset subtool condition )
Packit 58578d
{
Packit 58578d
    ## Need to define the linker-type feature once for each toolset module.
Packit 58578d
    if ! [ feature.valid <toolset-$(toolset):linker-type> ]
Packit 58578d
    {
Packit 58578d
        feature.subfeature toolset $(toolset) : linker-type :
Packit 58578d
            gnu aix darwin hpux osf sun : propagated link-incompatible ;
Packit 58578d
    }
Packit 58578d
    ## The specification to add the linker-type is per toolset "instance".
Packit 58578d
    toolset.add-requirements
Packit 58578d
        $(condition),<target-os>aix:<toolset-$(toolset):linker-type>aix
Packit 58578d
        $(condition),<target-os>darwin:<toolset-$(toolset):linker-type>darwin
Packit 58578d
        $(condition),<target-os>hpux:<toolset-$(toolset):linker-type>hpux
Packit 58578d
        $(condition),<target-os>osf:<toolset-$(toolset):linker-type>osf
Packit 58578d
        $(condition),<target-os>solaris:<toolset-$(toolset):linker-type>sun
Packit 58578d
        ;
Packit 58578d
}
Packit 58578d
Packit 58578d
rule set-link-options ( action-name targets + : sources * : properties * )
Packit 58578d
{
Packit 58578d
    local toolset = [ feature.get-values <toolset> : $(properties) ] ;
Packit 58578d
    local linker-type = [ feature.get-values <toolset-$(toolset):linker-type> : $(properties) ] ;
Packit 58578d
    local target-os = [ feature.get-values <target-os> : $(properties) ] ;
Packit 58578d
Packit 58578d
    switch $(linker-type:G=)
Packit 58578d
    {
Packit 58578d
        case aix :
Packit 58578d
Packit 58578d
        # On AIX we *have* to use the native linker.
Packit 58578d
        #
Packit 58578d
        # Using -brtl, the AIX linker will look for libraries with both the .a
Packit 58578d
        # and .so extensions, such as libfoo.a and libfoo.so. Without -brtl, the
Packit 58578d
        # AIX linker looks only for libfoo.a. Note that libfoo.a is an archived
Packit 58578d
        # file that may contain shared objects and is different from static libs
Packit 58578d
        # as on Linux.
Packit 58578d
        #
Packit 58578d
        # The -bnoipath strips the prepending (relative) path of libraries from
Packit 58578d
        # the loader section in the target library or executable. Hence, during
Packit 58578d
        # load-time LIBPATH (identical to LD_LIBRARY_PATH) or a hard-coded
Packit 58578d
        # -blibpath (*similar* to -lrpath/-lrpath-link) is searched. Without
Packit 58578d
        # this option, the prepending (relative) path + library name is
Packit 58578d
        # hard-coded in the loader section, causing *only* this path to be
Packit 58578d
        # searched during load-time. Note that the AIX linker does not have an
Packit 58578d
        # -soname equivalent, this is as close as it gets.
Packit 58578d
        #
Packit 58578d
        # The -bbigtoc option instrcuts the linker to create a TOC bigger than 64k.
Packit 58578d
        # This is neccesary for some submodules such as math, but it does make running
Packit 58578d
        # the tests a tad slower.
Packit 58578d
        #
Packit 58578d
        # The above options are definately for AIX 5.x, and most likely also for
Packit 58578d
        # AIX 4.x and AIX 6.x. For details about the AIX linker see:
Packit 58578d
        # http://download.boulder.ibm.com/ibmdl/pub/software/dw/aix/es-aix_ll.pdf
Packit 58578d
        #
Packit 58578d
Packit 58578d
        OPTIONS on $(targets) += -Wl,-brtl -Wl,-bnoipath -Wl,-bbigtoc ;
Packit 58578d
Packit 58578d
        # See note [1]
Packit 58578d
        if <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -static ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        case darwin :
Packit 58578d
Packit 58578d
        # On Darwin, the -s option to ld does not work unless we pass -static,
Packit 58578d
        # and passing -static unconditionally is a bad idea. So, do not pass -s
Packit 58578d
        # at all and darwin.jam will use a separate 'strip' invocation.
Packit 58578d
        RPATH on $(targets) +=
Packit 58578d
            [ feature.get-values <dll-path> : $(properties) ] ;
Packit 58578d
        # This does not support -R.
Packit 58578d
        RPATH_OPTION on $(targets) += -rpath ;
Packit 58578d
        # -rpath-link is not supported at all.
Packit 58578d
Packit 58578d
        # See note [1]
Packit 58578d
        if <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -static ;
Packit 58578d
        }
Packit 58578d
        
Packit 58578d
        case vxworks :
Packit 58578d
        # On VxWorks we want to reflect what ever special flags have been set in the
Packit 58578d
        # environment for the CPU we are targeting in the cross build
Packit 58578d
        toolset.flags $(toolset).link     OPTIONS     $(condition)/<strip>on    : -Wl,--strip-all                : unchecked ;
Packit 58578d
        toolset.flags $(toolset).link     OPTIONS     $(condition)/<link>static : [ os.environ LDFLAGS_STATIC ]  : unchecked ;
Packit 58578d
        toolset.flags $(toolset).link.dll OPTIONS     $(condition)              : [ os.environ LDFLAGS_SO ]      : unchecked ;
Packit 58578d
        toolset.flags $(toolset).link     OPTIONS     $(condition)/<link>shared : [ os.environ LDFLAGS_DYNAMIC ] : unchecked ;
Packit 58578d
  
Packit 58578d
        case gnu :
Packit 58578d
Packit 58578d
        # Strip the binary when no debugging is needed. We use --strip-all flag
Packit 58578d
        # as opposed to -s since icc (intel's compiler) is generally
Packit 58578d
        # option-compatible with and inherits from the gcc toolset, but does not
Packit 58578d
        # support -s.
Packit 58578d
        if <strip>on in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -Wl,--strip-all ;
Packit 58578d
        }
Packit 58578d
        RPATH on $(targets) +=
Packit 58578d
            [ feature.get-values <dll-path> : $(properties) ] ;
Packit 58578d
        RPATH_OPTION on $(targets) += -rpath ;
Packit 58578d
        RPATH_LINK on $(targets) +=
Packit 58578d
            [ feature.get-values <xdll-path> : $(properties) ] ;
Packit 58578d
        START-GROUP on $(targets) += -Wl,--start-group ;
Packit 58578d
        END-GROUP on $(targets) += -Wl,--end-group ;
Packit 58578d
Packit 58578d
        # gnu ld has the ability to change the search behaviour for libraries
Packit 58578d
        # referenced by the -l switch. These modifiers are -Bstatic and
Packit 58578d
        # -Bdynamic and change search for -l switches that follow them. The
Packit 58578d
        # following list shows the tried variants. Search stops at the first
Packit 58578d
        # variant that has a match.
Packit 58578d
        #
Packit 58578d
        # *nix: -Bstatic -lxxx
Packit 58578d
        #    libxxx.a
Packit 58578d
        #
Packit 58578d
        # *nix: -Bdynamic -lxxx
Packit 58578d
        #    libxxx.so
Packit 58578d
        #    libxxx.a
Packit 58578d
        #
Packit 58578d
        # windows (mingw, cygwin) -Bstatic -lxxx
Packit 58578d
        #    libxxx.a
Packit 58578d
        #    xxx.lib
Packit 58578d
        #
Packit 58578d
        # windows (mingw, cygwin) -Bdynamic -lxxx
Packit 58578d
        #    libxxx.dll.a
Packit 58578d
        #    xxx.dll.a
Packit 58578d
        #    libxxx.a
Packit 58578d
        #    xxx.lib
Packit 58578d
        #    cygxxx.dll (*)
Packit 58578d
        #    libxxx.dll
Packit 58578d
        #    xxx.dll
Packit 58578d
        #    libxxx.a
Packit 58578d
        #
Packit 58578d
        # (*) This is for cygwin
Packit 58578d
        # Please note that -Bstatic and -Bdynamic are not a guarantee that a
Packit 58578d
        # static or dynamic lib indeed gets linked in. The switches only change
Packit 58578d
        # search patterns!
Packit 58578d
Packit 58578d
        # On *nix mixing shared libs with static runtime is not a good idea.
Packit 58578d
        if <runtime-link>shared in $(properties)
Packit 58578d
        {
Packit 58578d
            FINDLIBS-ST-PFX on $(targets) += -Wl,-Bstatic ;
Packit 58578d
            FINDLIBS-SA-PFX on $(targets) += -Wl,-Bdynamic ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        # On windows allow mixing of static and dynamic libs with static
Packit 58578d
        # runtime is not a good idea.
Packit 58578d
        if <runtime-link>static in $(properties) && <target-os>windows in $(properties)
Packit 58578d
        {
Packit 58578d
            FINDLIBS-ST-PFX on $(targets) += -Wl,-Bstatic ;
Packit 58578d
            FINDLIBS-SA-PFX on $(targets) += -Wl,-Bdynamic ;
Packit 58578d
            OPTIONS on $(targets) += -Wl,-Bstatic ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        HAVE_SONAME on $(targets) += "" ;
Packit 58578d
        SONAME_OPTION on $(targets) += -h ;
Packit 58578d
Packit 58578d
        # See note [1]
Packit 58578d
        if <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -static ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        case hpux :
Packit 58578d
Packit 58578d
        if <strip>on in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -Wl,-s ;
Packit 58578d
        }
Packit 58578d
        if <link>shared in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -fPIC ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        HAVE_SONAME on $(targets) += "" ; 
Packit 58578d
        SONAME_OPTION on $(targets) += +h ;
Packit 58578d
Packit 58578d
        case osf :
Packit 58578d
Packit 58578d
        # No --strip-all, just -s.
Packit 58578d
        OPTIONS
Packit 58578d
            <toolset-$(toolset):linker-type>osf/$(condition)/<strip>on
Packit 58578d
            : -Wl,-s
Packit 58578d
            : unchecked ;
Packit 58578d
        RPATH on $(targets) += [ feature.get-values <dll-path> ] ;
Packit 58578d
        # This does not support -R.
Packit 58578d
        RPATH_OPTION on $(targets) += -rpath ;
Packit 58578d
        # -rpath-link is not supported at all.
Packit 58578d
Packit 58578d
        # See note [1]
Packit 58578d
        if <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -static ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        case sun :
Packit 58578d
Packit 58578d
        if <strip>on in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -Wl,-s ;
Packit 58578d
        }
Packit 58578d
        RPATH on $(targets) += [ feature.get-values <dll-path> ] ;
Packit 58578d
        # Solaris linker does not have a separate -rpath-link, but allows using
Packit 58578d
        # -L for the same purpose.
Packit 58578d
        LINKPATH on $(targets) += [ feature.get-values <xdll-path> ] ;
Packit 58578d
Packit 58578d
        # This permits shared libraries with non-PIC code on Solaris.
Packit 58578d
        # VP, 2004/09/07: Now that we have -fPIC hardcode in link.dll, the
Packit 58578d
        # following is not needed. Whether -fPIC should be hardcoded, is a
Packit 58578d
        # separate question.
Packit 58578d
        # AH, 2004/10/16: it is still necessary because some tests link against
Packit 58578d
        # static libraries that were compiled without PIC.
Packit 58578d
        if <link>shared in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -mimpure-text ;
Packit 58578d
        }
Packit 58578d
Packit 58578d
        # See note [1]
Packit 58578d
        if <runtime-link>static in $(properties)
Packit 58578d
        {
Packit 58578d
            OPTIONS on $(targets) += -static ;
Packit 58578d
        }
Packit 58578d
    }
Packit 58578d
Packit 58578d
    # [1]
Packit 58578d
    # For <runtime-link>static we made sure there are no dynamic libraries in the
Packit 58578d
    # link. On HP-UX not all system libraries exist as archived libraries (for
Packit 58578d
    # example, there is no libunwind.a), so, on this platform, the -static option
Packit 58578d
    # cannot be specified.
Packit 58578d
}
Packit 58578d
Packit 58578d
Packit 58578d
# Enclose the RPATH variable on 'targets' in double quotes, unless it is already
Packit 58578d
# enclosed in single quotes. This special casing is done because it is common to
Packit 58578d
# pass '$ORIGIN' to linker -- and it has to have single quotes to prevent shell
Packit 58578d
# expansion -- and if we add double quotes then the preventing properties of
Packit 58578d
# single quotes disappear.
Packit 58578d
#
Packit 58578d
rule quote-rpath ( targets * )
Packit 58578d
{
Packit 58578d
    local r = [ on $(targets[1]) return $(RPATH) ] ;
Packit 58578d
    if ! [ MATCH ('.*') : $(r) ]
Packit 58578d
    {
Packit 58578d
        r = \"$(r)\" ;
Packit 58578d
    }
Packit 58578d
    RPATH on $(targets) = $(r) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
# Declare actions for linking.
Packit 58578d
rule link ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    SPACE on $(targets) = " " ;
Packit 58578d
    # Serialize execution of the 'link' action, since running N links in
Packit 58578d
    # parallel is just slower. For now, serialize only gcc links, it might be a
Packit 58578d
    # good idea to serialize all links.
Packit 58578d
    JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
Packit 58578d
    quote-rpath $(targets) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
actions link bind LIBRARIES
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
Packit 58578d
}
Packit 58578d
Packit 58578d
rule link.dll ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    SPACE on $(targets) = " " ;
Packit 58578d
    JAM_SEMAPHORE on $(targets) = <s>gcc-link-semaphore ;
Packit 58578d
    quote-rpath $(targets) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
# Differs from 'link' above only by -shared.
Packit 58578d
actions link.dll bind LIBRARIES
Packit 58578d
{
Packit 58578d
    "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,$(RPATH) "$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" $(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) -shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) $(USER_OPTIONS)
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### Archive library generation.
Packit 58578d
###
Packit 58578d
Packit 58578d
# Default value. Mostly for the sake of intel-linux that inherits from gcc, but
Packit 58578d
# does not have the same logic to set the .AR variable. We can put the same
Packit 58578d
# logic in intel-linux, but that is hardly worth the trouble as on Linux, 'ar'
Packit 58578d
# is always available.
Packit 58578d
.AR = ar ;
Packit 58578d
.RANLIB = ranlib ;
Packit 58578d
Packit 58578d
toolset.flags gcc.archive AROPTIONS <archiveflags> ;
Packit 58578d
Packit 58578d
rule archive ( targets * : sources * : properties * )
Packit 58578d
{
Packit 58578d
    # Always remove archive and start again. Here is the rationale from
Packit 58578d
    #
Packit 58578d
    # Andre Hentz:
Packit 58578d
    #
Packit 58578d
    # I had a file, say a1.c, that was included into liba.a. I moved a1.c to
Packit 58578d
    # a2.c, updated my Jamfiles and rebuilt. My program was crashing with absurd
Packit 58578d
    # errors. After some debugging I traced it back to the fact that a1.o was
Packit 58578d
    # *still* in liba.a
Packit 58578d
    #
Packit 58578d
    # Rene Rivera:
Packit 58578d
    #
Packit 58578d
    # Originally removing the archive was done by splicing an RM onto the
Packit 58578d
    # archive action. That makes archives fail to build on NT when they have
Packit 58578d
    # many files because it will no longer execute the action directly and blow
Packit 58578d
    # the line length limit. Instead we remove the file in a different action,
Packit 58578d
    # just before building the archive.
Packit 58578d
    #
Packit 58578d
    local clean.a = $(targets[1])(clean) ;
Packit 58578d
    TEMPORARY $(clean.a) ;
Packit 58578d
    NOCARE $(clean.a) ;
Packit 58578d
    LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ;
Packit 58578d
    DEPENDS $(clean.a) : $(sources) ;
Packit 58578d
    DEPENDS $(targets) : $(clean.a) ;
Packit 58578d
    common.RmTemps $(clean.a) : $(targets) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
# Declare action for creating static libraries.
Packit 58578d
# The letter 'r' means to add files to the archive with replacement. Since we
Packit 58578d
# remove archive, we do not care about replacement, but there is no option "add
Packit 58578d
# without replacement".
Packit 58578d
# The letter 'c' suppresses the warning in case the archive does not exists yet.
Packit 58578d
# That warning is produced only on some platforms, for whatever reasons.
Packit 58578d
#
Packit 58578d
actions piecemeal archive
Packit 58578d
{
Packit 58578d
    "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
Packit 58578d
    "$(.RANLIB)" "$(<)"
Packit 58578d
}
Packit 58578d
Packit 58578d
###
Packit 58578d
### CPU architecture and instruction set options.
Packit 58578d
###
Packit 58578d
Packit 58578d
local rule cpu-flags ( toolset variable : architecture : instruction-set + :
Packit 58578d
    values + : default ? )
Packit 58578d
{
Packit 58578d
    if $(default)
Packit 58578d
    {
Packit 58578d
        toolset.flags $(toolset) $(variable)
Packit 58578d
            <architecture>$(architecture)/<instruction-set> : $(values) ;
Packit 58578d
    }
Packit 58578d
    toolset.flags $(toolset) $(variable)
Packit 58578d
        <architecture>/<instruction-set>$(instruction-set)
Packit 58578d
        <architecture>$(architecture)/<instruction-set>$(instruction-set)
Packit 58578d
        : $(values) ;
Packit 58578d
}
Packit 58578d
Packit 58578d
Packit 58578d
# Set architecture/instruction-set options.
Packit 58578d
#
Packit 58578d
# x86 and compatible
Packit 58578d
# The 'native' option appeared in gcc 4.2 so we cannot safely use it as default.
Packit 58578d
# Use i686 instead for 32-bit.
Packit 58578d
toolset.flags gcc OPTIONS <architecture>x86/<address-model>32/<instruction-set> : -march=i686 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : native : -march=native ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : i486 : -march=i486 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : i586 : -march=i586 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : i686 : -march=i686 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium : -march=pentium ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium-mmx : -march=pentium-mmx ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentiumpro : -march=pentiumpro ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium2 : -march=pentium2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium3 : -march=pentium3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium3m : -march=pentium3m ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium-m : -march=pentium-m ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium4 : -march=pentium4 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : pentium4m : -march=pentium4m ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : prescott : -march=prescott ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : nocona : -march=nocona ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : core2 : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : conroe : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : conroe-xe : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : conroe-l : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : allendale : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : wolfdale : -march=core2 -msse4.1 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : merom : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : merom-xe : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : kentsfield : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : kentsfield-xe : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : yorksfield : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : penryn : -march=core2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : corei7 : -march=corei7 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : nehalem : -march=corei7 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : corei7-avx : -march=corei7-avx ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : sandy-bridge : -march=corei7-avx ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : core-avx-i : -march=core-avx-i ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : ivy-bridge : -march=core-avx-i ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : haswell : -march=core-avx-i -mavx2 -mfma -mbmi -mbmi2 -mlzcnt ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : broadwell : -march=broadwell ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : skylake : -march=skylake ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : skylake-avx512 : -march=skylake-avx512 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : cannonlake : -march=skylake-avx512 -mavx512vbmi -mavx512ifma -msha ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : k6 : -march=k6 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : k6-2 : -march=k6-2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : k6-3 : -march=k6-3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon : -march=athlon ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon-tbird : -march=athlon-tbird ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon-4 : -march=athlon-4 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon-xp : -march=athlon-xp ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon-mp : -march=athlon-mp ;
Packit 58578d
##
Packit 58578d
cpu-flags gcc OPTIONS : x86 : k8 : -march=k8 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : opteron : -march=opteron ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon64 : -march=athlon64 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon-fx : -march=athlon-fx ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : k8-sse3 : -march=k8-sse3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : opteron-sse3 : -march=opteron-sse3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : athlon64-sse3 : -march=athlon64-sse3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : amdfam10 : -march=amdfam10 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : barcelona : -march=barcelona ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : bdver1 : -march=bdver1 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : bdver2 : -march=bdver2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : bdver3 : -march=bdver3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : bdver4 : -march=bdver4 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : btver1 : -march=btver1 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : btver2 : -march=btver2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : znver1 : -march=znver1 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : winchip-c6 : -march=winchip-c6 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : winchip2 : -march=winchip2 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : c3 : -march=c3 ;
Packit 58578d
cpu-flags gcc OPTIONS : x86 : c3-2 : -march=c3-2 ;
Packit 58578d
##
Packit 58578d
cpu-flags gcc OPTIONS : x86 : atom : -march=atom ;
Packit 58578d
# Sparc
Packit 58578d
cpu-flags gcc OPTIONS : sparc : v7 : -mcpu=v7 : default ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : cypress : -mcpu=cypress ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : v8 : -mcpu=v8 ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : supersparc : -mcpu=supersparc ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : sparclite : -mcpu=sparclite ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : hypersparc : -mcpu=hypersparc ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : sparclite86x : -mcpu=sparclite86x ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : f930 : -mcpu=f930 ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : f934 : -mcpu=f934 ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : sparclet : -mcpu=sparclet ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : tsc701 : -mcpu=tsc701 ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : v9 : -mcpu=v9 ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : ultrasparc : -mcpu=ultrasparc ;
Packit 58578d
cpu-flags gcc OPTIONS : sparc : ultrasparc3 : -mcpu=ultrasparc3 ;
Packit 58578d
# RS/6000 & PowerPC
Packit 58578d
cpu-flags gcc OPTIONS : power : 403 : -mcpu=403 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 505 : -mcpu=505 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 601 : -mcpu=601 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 602 : -mcpu=602 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 603 : -mcpu=603 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 603e : -mcpu=603e ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 604 : -mcpu=604 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 604e : -mcpu=604e ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 620 : -mcpu=620 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 630 : -mcpu=630 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 740 : -mcpu=740 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 7400 : -mcpu=7400 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 7450 : -mcpu=7450 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 750 : -mcpu=750 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 801 : -mcpu=801 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 821 : -mcpu=821 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 823 : -mcpu=823 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 860 : -mcpu=860 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 970 : -mcpu=970 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : 8540 : -mcpu=8540 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : power : -mcpu=power ;
Packit 58578d
cpu-flags gcc OPTIONS : power : power2 : -mcpu=power2 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : power3 : -mcpu=power3 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : power4 : -mcpu=power4 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : power5 : -mcpu=power5 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : powerpc : -mcpu=powerpc ;
Packit 58578d
cpu-flags gcc OPTIONS : power : powerpc64 : -mcpu=powerpc64 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : rios : -mcpu=rios ;
Packit 58578d
cpu-flags gcc OPTIONS : power : rios1 : -mcpu=rios1 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : rios2 : -mcpu=rios2 ;
Packit 58578d
cpu-flags gcc OPTIONS : power : rsc : -mcpu=rsc ;
Packit 58578d
cpu-flags gcc OPTIONS : power : rs64a : -mcpu=rs64 ;
Packit 58578d
# AIX variant of RS/6000 & PowerPC
Packit 58578d
toolset.flags gcc AROPTIONS <address-model>64/<target-os>aix : "-X64" ;