|
Packit |
58578d |
# Status: being ported by Steven Watanabe
|
|
Packit |
58578d |
# Base revision: 47077
|
|
Packit |
58578d |
# TODO: common.jam needs to be ported
|
|
Packit |
58578d |
# TODO: generators.jam needs to have register_c_compiler.
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# Copyright 2001 David Abrahams.
|
|
Packit |
58578d |
# Copyright 2002-2006 Rene Rivera.
|
|
Packit |
58578d |
# Copyright 2002-2003 Vladimir Prus.
|
|
Packit |
58578d |
# Copyright (c) 2005 Reece H. Dunn.
|
|
Packit |
58578d |
# Copyright 2006 Ilya Sokolov.
|
|
Packit |
58578d |
# Copyright 2007 Roland Schwarz
|
|
Packit |
58578d |
# Copyright 2007 Boris Gubenko.
|
|
Packit |
58578d |
# Copyright 2008 Steven Watanabe
|
|
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 os
|
|
Packit |
58578d |
import subprocess
|
|
Packit |
58578d |
import re
|
|
Packit |
58578d |
|
|
Packit |
58578d |
import bjam
|
|
Packit |
58578d |
|
|
Packit |
58578d |
from b2.tools import unix, common, rc, pch, builtin
|
|
Packit |
58578d |
from b2.build import feature, type, toolset, generators, property_set
|
|
Packit |
58578d |
from b2.build.property import Property
|
|
Packit |
58578d |
from b2.util.utility import os_name, on_windows
|
|
Packit |
58578d |
from b2.manager import get_manager
|
|
Packit |
58578d |
from b2.build.generators import Generator
|
|
Packit |
58578d |
from b2.build.toolset import flags
|
|
Packit |
58578d |
from b2.util.utility import to_seq
|
|
Packit |
58578d |
|
|
Packit |
58578d |
|
|
Packit |
58578d |
|
|
Packit |
58578d |
__debug = None
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def debug():
|
|
Packit |
58578d |
global __debug
|
|
Packit |
58578d |
if __debug is None:
|
|
Packit |
58578d |
__debug = "--debug-configuration" in bjam.variable("ARGV")
|
|
Packit |
58578d |
return __debug
|
|
Packit |
58578d |
|
|
Packit |
58578d |
feature.extend('toolset', ['gcc'])
|
|
Packit |
58578d |
|
|
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 |
# Target naming is determined by types/lib.jam and the settings below this
|
|
Packit |
58578d |
# comment.
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# On *nix:
|
|
Packit |
58578d |
# libxxx.a static library
|
|
Packit |
58578d |
# libxxx.so shared library
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# On windows (mingw):
|
|
Packit |
58578d |
# libxxx.lib static library
|
|
Packit |
58578d |
# xxx.dll DLL
|
|
Packit |
58578d |
# xxx.lib import library
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# On windows (cygwin) i.e. <target-os>cygwin
|
|
Packit |
58578d |
# libxxx.a static library
|
|
Packit |
58578d |
# xxx.dll DLL
|
|
Packit |
58578d |
# libxxx.dll.a import library
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# Note: user can always override by using the <tag>@rule
|
|
Packit |
58578d |
# This settings have been choosen, so that mingw
|
|
Packit |
58578d |
# is in line with msvc naming conventions. For
|
|
Packit |
58578d |
# cygwin the cygwin naming convention has been choosen.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Make the "o" suffix used for gcc toolset on all
|
|
Packit |
58578d |
# platforms
|
|
Packit |
58578d |
type.set_generated_target_suffix('OBJ', ['<toolset>gcc'], 'o')
|
|
Packit |
58578d |
type.set_generated_target_suffix('STATIC_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'a')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
type.set_generated_target_suffix('IMPORT_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'dll.a')
|
|
Packit |
58578d |
type.set_generated_target_prefix('IMPORT_LIB', ['<toolset>gcc', '<target-os>cygwin'], 'lib')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
__machine_match = re.compile('^([^ ]+)')
|
|
Packit |
58578d |
__version_match = re.compile('^([0-9.]+)')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def init(version = None, command = None, options = None):
|
|
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 gnu, darwin, osf, hpux or sun
|
|
Packit |
58578d |
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 |
|
|
Packit |
58578d |
options = to_seq(options)
|
|
Packit |
58578d |
command = to_seq(command)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Information about the gcc command...
|
|
Packit |
58578d |
# The command.
|
|
Packit |
58578d |
command = to_seq(common.get_invocation_command('gcc', 'g++', command))
|
|
Packit |
58578d |
# The root directory of the tool install.
|
|
Packit |
58578d |
root = feature.get_values('<root>', options)
|
|
Packit |
58578d |
root = root[0] if root else ''
|
|
Packit |
58578d |
# The bin directory where to find the command to execute.
|
|
Packit |
58578d |
bin = None
|
|
Packit |
58578d |
# The flavor of compiler.
|
|
Packit |
58578d |
flavor = feature.get_values('<flavor>', options)
|
|
Packit |
58578d |
flavor = flavor[0] if flavor else ''
|
|
Packit |
58578d |
# Autodetect the root and bin dir if not given.
|
|
Packit |
58578d |
if command:
|
|
Packit |
58578d |
if not bin:
|
|
Packit |
58578d |
bin = common.get_absolute_tool_path(command[-1])
|
|
Packit |
58578d |
if not root:
|
|
Packit |
58578d |
root = os.path.dirname(bin)
|
|
Packit |
58578d |
# Autodetect the version and flavor if not given.
|
|
Packit |
58578d |
if command:
|
|
Packit |
58578d |
machine_info = subprocess.Popen(command + ['-dumpmachine'], stdout=subprocess.PIPE).communicate()[0]
|
|
Packit |
58578d |
machine = __machine_match.search(machine_info).group(1)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
version_info = subprocess.Popen(command + ['-dumpversion'], stdout=subprocess.PIPE).communicate()[0]
|
|
Packit |
58578d |
version = __version_match.search(version_info).group(1)
|
|
Packit |
58578d |
if not flavor and machine.find('mingw') != -1:
|
|
Packit |
58578d |
flavor = 'mingw'
|
|
Packit |
58578d |
|
|
Packit |
58578d |
condition = None
|
|
Packit |
58578d |
if flavor:
|
|
Packit |
58578d |
condition = common.check_init_parameters('gcc', None,
|
|
Packit |
58578d |
('version', version),
|
|
Packit |
58578d |
('flavor', flavor))
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
condition = common.check_init_parameters('gcc', None,
|
|
Packit |
58578d |
('version', version))
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if command:
|
|
Packit |
58578d |
command = command[0]
|
|
Packit |
58578d |
|
|
Packit |
58578d |
common.handle_options('gcc', condition, command, options)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
linker = feature.get_values('<linker-type>', options)
|
|
Packit |
58578d |
if not linker:
|
|
Packit |
58578d |
if os_name() == 'OSF':
|
|
Packit |
58578d |
linker = 'osf'
|
|
Packit |
58578d |
elif os_name() == 'HPUX':
|
|
Packit |
58578d |
linker = 'hpux' ;
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
linker = 'gnu'
|
|
Packit |
58578d |
|
|
Packit |
58578d |
init_link_flags('gcc', linker, condition)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# If gcc is installed in non-standard location, we'd 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 |
# 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 don't provide a clean way to build 32-bit
|
|
Packit |
58578d |
# binary with 64-bit compiler, but user can always pass -m32 manually.
|
|
Packit |
58578d |
lib_path = [os.path.join(root, 'bin'),
|
|
Packit |
58578d |
os.path.join(root, 'lib'),
|
|
Packit |
58578d |
os.path.join(root, 'lib32'),
|
|
Packit |
58578d |
os.path.join(root, 'lib64')]
|
|
Packit |
58578d |
if debug():
|
|
Packit |
58578d |
print 'notice: using gcc libraries ::', condition, '::', lib_path
|
|
Packit |
58578d |
toolset.flags('gcc.link', 'RUN_PATH', condition, lib_path)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# If it's not a system gcc install we should adjust the various programs as
|
|
Packit |
58578d |
# needed to prefer using the install specific versions. This is essential
|
|
Packit |
58578d |
# for correct use of MinGW and for cross-compiling.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# - The archive builder.
|
|
Packit |
58578d |
archiver = common.get_invocation_command('gcc',
|
|
Packit |
58578d |
'ar', feature.get_values('<archiver>', options), [bin], path_last=True)
|
|
Packit |
58578d |
toolset.flags('gcc.archive', '.AR', condition, [archiver])
|
|
Packit |
58578d |
if debug():
|
|
Packit |
58578d |
print 'notice: using gcc archiver ::', condition, '::', archiver
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# - Ranlib
|
|
Packit |
58578d |
ranlib = common.get_invocation_command('gcc',
|
|
Packit |
58578d |
'ranlib', feature.get_values('<ranlib>', options), [bin], path_last=True)
|
|
Packit |
58578d |
toolset.flags('gcc.archive', '.RANLIB', condition, [ranlib])
|
|
Packit |
58578d |
if debug():
|
|
Packit |
58578d |
print 'notice: using gcc archiver ::', condition, '::', ranlib
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# - The resource compiler.
|
|
Packit |
58578d |
rc_command = common.get_invocation_command_nodefault('gcc',
|
|
Packit |
58578d |
'windres', feature.get_values('<rc>', options), [bin], path_last=True)
|
|
Packit |
58578d |
rc_type = feature.get_values('<rc-type>', options)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if not rc_type:
|
|
Packit |
58578d |
rc_type = 'windres'
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if not rc_command:
|
|
Packit |
58578d |
# If we can't find an RC compiler we fallback to a null RC compiler that
|
|
Packit |
58578d |
# creates empty object files. This allows the same Jamfiles to work
|
|
Packit |
58578d |
# across the board. The null RC uses the assembler to create the empty
|
|
Packit |
58578d |
# objects, so configure that.
|
|
Packit |
58578d |
rc_command = common.get_invocation_command('gcc', 'as', [], [bin], path_last=True)
|
|
Packit |
58578d |
rc_type = 'null'
|
|
Packit |
58578d |
rc.configure([rc_command], condition, ['<rc-type>' + rc_type])
|
|
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 |
### JAMSHELL = % ;
|
|
Packit |
58578d |
###}
|
|
Packit |
58578d |
|
|
Packit |
58578d |
#FIXME: when register_c_compiler is moved to
|
|
Packit |
58578d |
# generators, these should be updated
|
|
Packit |
58578d |
builtin.register_c_compiler('gcc.compile.c++.preprocess', ['CPP'], ['PREPROCESSED_CPP'], ['<toolset>gcc'])
|
|
Packit |
58578d |
builtin.register_c_compiler('gcc.compile.c.preprocess', ['C'], ['PREPROCESSED_C'], ['<toolset>gcc'])
|
|
Packit |
58578d |
builtin.register_c_compiler('gcc.compile.c++', ['CPP'], ['OBJ'], ['<toolset>gcc'])
|
|
Packit |
58578d |
builtin.register_c_compiler('gcc.compile.c', ['C'], ['OBJ'], ['<toolset>gcc'])
|
|
Packit |
58578d |
builtin.register_c_compiler('gcc.compile.asm', ['ASM'], ['OBJ'], ['<toolset>gcc'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# pch support
|
|
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 BASE_PCH suffix is appended to
|
|
Packit |
58578d |
# full name of the header.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
type.set_generated_target_suffix('PCH', ['<toolset>gcc'], 'gch')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# GCC-specific pch generator.
|
|
Packit |
58578d |
class GccPchGenerator(pch.PchGenerator):
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Inherit the __init__ method
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def run_pch(self, project, name, prop_set, sources):
|
|
Packit |
58578d |
# Find the header in sources. Ignore any CPP sources.
|
|
Packit |
58578d |
header = None
|
|
Packit |
58578d |
for s in sources:
|
|
Packit |
58578d |
if type.is_derived(s.type(), 'H'):
|
|
Packit |
58578d |
header = s
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Error handling: Base header file name should be the same as the base
|
|
Packit |
58578d |
# precompiled header name.
|
|
Packit |
58578d |
header_name = header.name()
|
|
Packit |
58578d |
header_basename = os.path.basename(header_name).rsplit('.', 1)[0]
|
|
Packit |
58578d |
if header_basename != name:
|
|
Packit |
58578d |
location = project.project_module
|
|
Packit |
58578d |
###FIXME:
|
|
Packit |
58578d |
raise Exception()
|
|
Packit |
58578d |
### errors.user-error "in" $(location)": pch target name `"$(name)"' should be the same as the base name of header file `"$(header-name)"'" ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
pch_file = Generator.run(self, project, name, prop_set, [header])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# return result of base class and pch-file property as usage-requirements
|
|
Packit |
58578d |
# FIXME: what about multiple results from generator.run?
|
|
Packit |
58578d |
return (property_set.create([Property('pch-file', pch_file[0]),
|
|
Packit |
58578d |
Property('cflags', '-Winvalid-pch')]),
|
|
Packit |
58578d |
pch_file)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Calls the base version specifying source's name as the name of the created
|
|
Packit |
58578d |
# target. As result, the PCH will be named whatever.hpp.gch, and not
|
|
Packit |
58578d |
# whatever.gch.
|
|
Packit |
58578d |
def generated_targets(self, sources, prop_set, project, name = None):
|
|
Packit |
58578d |
name = sources[0].name()
|
|
Packit |
58578d |
return Generator.generated_targets(self, sources,
|
|
Packit |
58578d |
prop_set, project, name)
|
|
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(GccPchGenerator('gcc.compile.c.pch', False, ['H'], ['C_PCH'], ['<pch>on', '<toolset>gcc' ]))
|
|
Packit |
58578d |
generators.register(GccPchGenerator('gcc.compile.c++.pch', False, ['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 |
flags('gcc.compile', 'PCH_FILE', ['<pch>on'], ['<pch-file>'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Declare flags and action for compilation
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<optimization>off'], ['-O0'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<optimization>speed'], ['-O3'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<optimization>space'], ['-Os'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<inlining>off'], ['-fno-inline'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<inlining>on'], ['-Wno-inline'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<inlining>full'], ['-finline-functions', '-Wno-inline'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<warnings>off'], ['-w'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<warnings>on'], ['-Wall'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<warnings>all'], ['-Wall', '-pedantic'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<warnings-as-errors>on'], ['-Werror'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<debug-symbols>on'], ['-g'])
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<profiling>on'], ['-pg'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.compile.c++', 'OPTIONS', ['<rtti>off'], ['-fno-rtti'])
|
|
Packit |
58578d |
flags('gcc.compile.c++', 'OPTIONS', ['<exception-handling>off'], ['-fno-exceptions'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# On cygwin and mingw, gcc generates position independent code by default, and
|
|
Packit |
58578d |
# warns if -fPIC is specified. This might not be the right way of checking if
|
|
Packit |
58578d |
# we're using cygwin. For example, it's possible to run cygwin gcc from NT
|
|
Packit |
58578d |
# shell, or using crosscompiling. But we'll solve that problem when it's time.
|
|
Packit |
58578d |
# In that case we'll just add another parameter to 'init' and move this login
|
|
Packit |
58578d |
# inside 'init'.
|
|
Packit |
58578d |
if not os_name () in ['CYGWIN', 'NT']:
|
|
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 though
|
|
Packit |
58578d |
# it's not needed, as 'd' is used only in exe. However, it's hard to detect
|
|
Packit |
58578d |
# where a target is going to be used. Alternative, we can set -fPIC only
|
|
Packit |
58578d |
# when main target type is LIB but than 'b' will be compiled without -fPIC.
|
|
Packit |
58578d |
# In x86-64 that will lead to link errors. So, compile everything with
|
|
Packit |
58578d |
# -fPIC.
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# Yet another alternative would be to create propagated <sharedable>
|
|
Packit |
58578d |
# feature, and set it when building shared libraries, but that's hard to
|
|
Packit |
58578d |
# implement and will increase target path length even more.
|
|
Packit |
58578d |
flags('gcc.compile', 'OPTIONS', ['<link>shared'], ['-fPIC'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if os_name() != 'NT' and os_name() != 'OSF' and os_name() != 'HPUX':
|
|
Packit |
58578d |
# OSF does have an option called -soname but it doesn't seem to work as
|
|
Packit |
58578d |
# expected, therefore it has been disabled.
|
|
Packit |
58578d |
HAVE_SONAME = ''
|
|
Packit |
58578d |
SONAME_OPTION = '-h'
|
|
Packit |
58578d |
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.compile', 'USER_OPTIONS', [], ['<cflags>'])
|
|
Packit |
58578d |
flags('gcc.compile.c++', 'USER_OPTIONS',[], ['<cxxflags>'])
|
|
Packit |
58578d |
flags('gcc.compile', 'DEFINES', [], ['<define>'])
|
|
Packit |
58578d |
flags('gcc.compile', 'INCLUDES', [], ['<include>'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine = get_manager().engine()
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action('gcc.compile.c++.pch',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action('gcc.compile.c.pch',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" -x c-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def gcc_compile_cpp(targets, sources, properties):
|
|
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 |
extension = os.path.splitext (sources [0]) [1]
|
|
Packit |
58578d |
lang = ''
|
|
Packit |
58578d |
if not extension in ['.cc', '.cp', '.cxx', '.cpp', '.c++', '.C']:
|
|
Packit |
58578d |
lang = '-x c++'
|
|
Packit |
58578d |
get_manager().engine().set_target_variable (targets, 'LANG', lang)
|
|
Packit |
58578d |
engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE'))
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def gcc_compile_c(targets, sources, properties):
|
|
Packit |
58578d |
engine = get_manager().engine()
|
|
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 |
engine.set_target_variable (targets, 'LANG', '-x c')
|
|
Packit |
58578d |
#}
|
|
Packit |
58578d |
engine.add_dependency(targets, bjam.call('get-target-variable', targets, 'PCH_FILE'))
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.compile.c++',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-128 $(OPTIONS) ' +
|
|
Packit |
58578d |
'$(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" ' +
|
|
Packit |
58578d |
'-c -o "$(<:W)" "$(>:W)"',
|
|
Packit |
58578d |
function=gcc_compile_cpp,
|
|
Packit |
58578d |
bound_list=['PCH_FILE'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.compile.c',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) ' +
|
|
Packit |
58578d |
'-I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)"',
|
|
Packit |
58578d |
function=gcc_compile_c,
|
|
Packit |
58578d |
bound_list=['PCH_FILE'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.compile.c++.preprocess',
|
|
Packit |
58578d |
function=gcc_compile_cpp,
|
|
Packit |
58578d |
bound_list=['PCH_FILE'],
|
|
Packit |
58578d |
command="""
|
|
Packit |
58578d |
$(CONFIG_COMMAND) $(LANG) -ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>:W)" -E >"$(<:W)"
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.compile.c.preprocess',
|
|
Packit |
58578d |
function=gcc_compile_c,
|
|
Packit |
58578d |
bound_list=['PCH_FILE'],
|
|
Packit |
58578d |
command="""
|
|
Packit |
58578d |
$(CONFIG_COMMAND) $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" "$(>)" -E >$(<)
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def gcc_compile_asm(targets, sources, properties):
|
|
Packit |
58578d |
get_manager().engine().set_target_variable(targets, 'LANG', '-x assembler-with-cpp')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.compile.asm',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"',
|
|
Packit |
58578d |
function=gcc_compile_asm)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
|
|
Packit |
58578d |
class GccLinkingGenerator(unix.UnixLinkingGenerator):
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
The class which check that we don't try to use the <runtime-link>static
|
|
Packit |
58578d |
property while creating or using shared library, since it's not supported by
|
|
Packit |
58578d |
gcc/libc.
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
def run(self, project, name, ps, sources):
|
|
Packit |
58578d |
# TODO: Replace this with the use of a target-os property.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
no_static_link = False
|
|
Packit |
58578d |
if bjam.variable('UNIX'):
|
|
Packit |
58578d |
no_static_link = True;
|
|
Packit |
58578d |
##FIXME: what does this mean?
|
|
Packit |
58578d |
## {
|
|
Packit |
58578d |
## switch [ modules.peek : JAMUNAME ]
|
|
Packit |
58578d |
## {
|
|
Packit |
58578d |
## case * : no-static-link = true ;
|
|
Packit |
58578d |
## }
|
|
Packit |
58578d |
## }
|
|
Packit |
58578d |
|
|
Packit |
58578d |
reason = None
|
|
Packit |
58578d |
if no_static_link and ps.get('runtime-link') == 'static':
|
|
Packit |
58578d |
if ps.get('link') == 'shared':
|
|
Packit |
58578d |
reason = "On gcc, DLL can't be build with '<runtime-link>static'."
|
|
Packit |
58578d |
elif type.is_derived(self.target_types[0], 'EXE'):
|
|
Packit |
58578d |
for s in sources:
|
|
Packit |
58578d |
source_type = s.type()
|
|
Packit |
58578d |
if source_type and type.is_derived(source_type, 'SHARED_LIB'):
|
|
Packit |
58578d |
reason = "On gcc, using DLLS together with the " +\
|
|
Packit |
58578d |
"<runtime-link>static options is not possible "
|
|
Packit |
58578d |
if reason:
|
|
Packit |
58578d |
print 'warning:', reason
|
|
Packit |
58578d |
print 'warning:',\
|
|
Packit |
58578d |
"It is suggested to use '<runtime-link>static' together",\
|
|
Packit |
58578d |
"with '<link>static'." ;
|
|
Packit |
58578d |
return
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
generated_targets = unix.UnixLinkingGenerator.run(self, project,
|
|
Packit |
58578d |
name, ps, sources)
|
|
Packit |
58578d |
return generated_targets
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if on_windows():
|
|
Packit |
58578d |
flags('gcc.link.dll', '.IMPLIB-COMMAND', [], ['-Wl,--out-implib,'])
|
|
Packit |
58578d |
generators.register(
|
|
Packit |
58578d |
GccLinkingGenerator('gcc.link', True,
|
|
Packit |
58578d |
['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'],
|
|
Packit |
58578d |
[ 'EXE' ],
|
|
Packit |
58578d |
[ '<toolset>gcc' ]))
|
|
Packit |
58578d |
generators.register(
|
|
Packit |
58578d |
GccLinkingGenerator('gcc.link.dll', True,
|
|
Packit |
58578d |
['OBJ', 'SEARCHED_LIB', 'STATIC_LIB', 'IMPORT_LIB'],
|
|
Packit |
58578d |
['IMPORT_LIB', 'SHARED_LIB'],
|
|
Packit |
58578d |
['<toolset>gcc']))
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
generators.register(
|
|
Packit |
58578d |
GccLinkingGenerator('gcc.link', True,
|
|
Packit |
58578d |
['LIB', 'OBJ'],
|
|
Packit |
58578d |
['EXE'],
|
|
Packit |
58578d |
['<toolset>gcc']))
|
|
Packit |
58578d |
generators.register(
|
|
Packit |
58578d |
GccLinkingGenerator('gcc.link.dll', True,
|
|
Packit |
58578d |
['LIB', 'OBJ'],
|
|
Packit |
58578d |
['SHARED_LIB'],
|
|
Packit |
58578d |
['<toolset>gcc']))
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Declare flags for linking.
|
|
Packit |
58578d |
# First, the common flags.
|
|
Packit |
58578d |
flags('gcc.link', 'OPTIONS', ['<debug-symbols>on'], ['-g'])
|
|
Packit |
58578d |
flags('gcc.link', 'OPTIONS', ['<profiling>on'], ['-pg'])
|
|
Packit |
58578d |
flags('gcc.link', 'USER_OPTIONS', [], ['<linkflags>'])
|
|
Packit |
58578d |
flags('gcc.link', 'LINKPATH', [], ['<library-path>'])
|
|
Packit |
58578d |
flags('gcc.link', 'FINDLIBS-ST', [], ['<find-static-library>'])
|
|
Packit |
58578d |
flags('gcc.link', 'FINDLIBS-SA', [], ['<find-shared-library>'])
|
|
Packit |
58578d |
flags('gcc.link', 'LIBRARIES', [], ['<library-file>'])
|
|
Packit |
58578d |
|
|
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 |
if os_name() != 'HPUX':
|
|
Packit |
58578d |
flags('gcc.link', 'OPTIONS', ['<runtime-link>static'], ['-static'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Now, the vendor specific flags.
|
|
Packit |
58578d |
# The parameter linker can be either gnu, darwin, osf, hpux or sun.
|
|
Packit |
58578d |
def init_link_flags(toolset, linker, condition):
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
Now, the vendor specific flags.
|
|
Packit |
58578d |
The parameter linker can be either gnu, darwin, osf, hpux or sun.
|
|
Packit |
58578d |
"""
|
|
Packit |
58578d |
toolset_link = toolset + '.link'
|
|
Packit |
58578d |
if linker == 'gnu':
|
|
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 |
|
|
Packit |
58578d |
# FIXME: what does unchecked translate to?
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,--strip-all']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH_LINK', condition, ['<xdll-path>']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'START-GROUP', condition, ['-Wl,--start-group'])# : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'END-GROUP', condition, ['-Wl,--end-group']) # : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# gnu ld has the ability to change the search behaviour for libraries
|
|
Packit |
58578d |
# referenced by -l switch. These modifiers are -Bstatic and -Bdynamic
|
|
Packit |
58578d |
# and change search for -l switches that follow them. The following list
|
|
Packit |
58578d |
# shows the tried variants.
|
|
Packit |
58578d |
# The search stops at the first variant that has a match.
|
|
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 |
flags(toolset_link, 'FINDLIBS-ST-PFX',
|
|
Packit |
58578d |
map(lambda x: x + '/<runtime-link>shared', condition),
|
|
Packit |
58578d |
['-Wl,-Bstatic']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'FINDLIBS-SA-PFX',
|
|
Packit |
58578d |
map(lambda x: x + '/<runtime-link>shared', condition),
|
|
Packit |
58578d |
['-Wl,-Bdynamic']) # : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# On windows allow mixing of static and dynamic libs with static
|
|
Packit |
58578d |
# runtime.
|
|
Packit |
58578d |
flags(toolset_link, 'FINDLIBS-ST-PFX',
|
|
Packit |
58578d |
map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition),
|
|
Packit |
58578d |
['-Wl,-Bstatic']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'FINDLIBS-SA-PFX',
|
|
Packit |
58578d |
map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition),
|
|
Packit |
58578d |
['-Wl,-Bdynamic']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS',
|
|
Packit |
58578d |
map(lambda x: x + '/<runtime-link>static/<target-os>windows', condition),
|
|
Packit |
58578d |
['-Wl,-Bstatic']) # : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
elif linker == 'darwin':
|
|
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, don't pass -s.
|
|
Packit |
58578d |
# at all, darwin.jam will use separate 'strip' invocation.
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH_LINK', condition, ['<xdll-path>']) # : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
elif linker == 'osf':
|
|
Packit |
58578d |
# No --strip-all, just -s.
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,-s'])
|
|
Packit |
58578d |
# : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ;
|
|
Packit |
58578d |
# This does not supports -R.
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH_OPTION', condition, ['-rpath']) # : unchecked ;
|
|
Packit |
58578d |
# -rpath-link is not supported at all.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
elif linker == 'sun':
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition), ['-Wl,-s'])
|
|
Packit |
58578d |
# : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'RPATH', condition, ['<dll-path>']) # : unchecked ;
|
|
Packit |
58578d |
# Solaris linker does not have a separate -rpath-link, but allows to use
|
|
Packit |
58578d |
# -L for the same purpose.
|
|
Packit |
58578d |
flags(toolset_link, 'LINKPATH', condition, ['<xdll-path>']) # : unchecked ;
|
|
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 |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<link>shared', condition), ['-mimpure-text'])
|
|
Packit |
58578d |
# : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
elif linker == 'hpux':
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<debug-symbols>off', condition),
|
|
Packit |
58578d |
['-Wl,-s']) # : unchecked ;
|
|
Packit |
58578d |
flags(toolset_link, 'OPTIONS', map(lambda x: x + '/<link>shared', condition),
|
|
Packit |
58578d |
['-fPIC']) # : unchecked ;
|
|
Packit |
58578d |
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
# FIXME:
|
|
Packit |
58578d |
errors.user_error(
|
|
Packit |
58578d |
"$(toolset) initialization: invalid linker '$(linker)' " +
|
|
Packit |
58578d |
"The value '$(linker)' specified for <linker> is not recognized. " +
|
|
Packit |
58578d |
"Possible values are 'gnu', 'darwin', 'osf', 'hpux' or 'sun'")
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Declare actions for linking.
|
|
Packit |
58578d |
def gcc_link(targets, sources, properties):
|
|
Packit |
58578d |
engine = get_manager().engine()
|
|
Packit |
58578d |
engine.set_target_variable(targets, 'SPACE', ' ')
|
|
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 |
engine.set_target_variable(targets, 'JAM_SEMAPHORE', '<s>gcc-link-semaphore')
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.link',
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' +
|
|
Packit |
58578d |
'-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' +
|
|
Packit |
58578d |
'-Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" ' +
|
|
Packit |
58578d |
'$(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' +
|
|
Packit |
58578d |
'-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' +
|
|
Packit |
58578d |
'$(OPTIONS) $(USER_OPTIONS)',
|
|
Packit |
58578d |
function=gcc_link,
|
|
Packit |
58578d |
bound_list=['LIBRARIES'])
|
|
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's hardly worth the trouble as on Linux, 'ar' is
|
|
Packit |
58578d |
# always available.
|
|
Packit |
58578d |
__AR = 'ar'
|
|
Packit |
58578d |
|
|
Packit |
58578d |
flags('gcc.archive', 'AROPTIONS', [], ['<archiveflags>'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def gcc_archive(targets, sources, properties):
|
|
Packit |
58578d |
# Always remove archive and start again. Here's 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 |
clean = targets[0] + '(clean)'
|
|
Packit |
58578d |
bjam.call('TEMPORARY', clean)
|
|
Packit |
58578d |
bjam.call('NOCARE', clean)
|
|
Packit |
58578d |
engine = get_manager().engine()
|
|
Packit |
58578d |
engine.set_target_variable('LOCATE', clean, bjam.call('get-target-variable', targets, 'LOCATE'))
|
|
Packit |
58578d |
engine.add_dependency(clean, sources)
|
|
Packit |
58578d |
engine.add_dependency(targets, clean)
|
|
Packit |
58578d |
engine.set_update_action('common.RmTemps', clean, targets)
|
|
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 don't care about replacement, but there's 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 |
engine.register_action('gcc.archive',
|
|
Packit |
58578d |
'''"$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)"
|
|
Packit |
58578d |
"$(.RANLIB)" "$(<)"
|
|
Packit |
58578d |
''',
|
|
Packit |
58578d |
function=gcc_archive,
|
|
Packit |
58578d |
flags=['piecemeal'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def gcc_link_dll(targets, sources, properties):
|
|
Packit |
58578d |
engine = get_manager().engine()
|
|
Packit |
58578d |
engine.set_target_variable(targets, 'SPACE', ' ')
|
|
Packit |
58578d |
engine.set_target_variable(targets, 'JAM_SEMAPHORE', '<s>gcc-link-semaphore')
|
|
Packit |
58578d |
engine.set_target_variable(targets, "HAVE_SONAME", HAVE_SONAME)
|
|
Packit |
58578d |
engine.set_target_variable(targets, "SONAME_OPTION", SONAME_OPTION)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
engine.register_action(
|
|
Packit |
58578d |
'gcc.link.dll',
|
|
Packit |
58578d |
# Differ from 'link' above only by -shared.
|
|
Packit |
58578d |
'"$(CONFIG_COMMAND)" -L"$(LINKPATH)" ' +
|
|
Packit |
58578d |
'-Wl,$(RPATH_OPTION:E=-R)$(SPACE)-Wl,"$(RPATH)" ' +
|
|
Packit |
58578d |
'"$(.IMPLIB-COMMAND)$(<[1])" -o "$(<[-1])" ' +
|
|
Packit |
58578d |
'$(HAVE_SONAME)-Wl,$(SONAME_OPTION)$(SPACE)-Wl,$(<[-1]:D=) ' +
|
|
Packit |
58578d |
'-shared $(START-GROUP) "$(>)" "$(LIBRARIES)" $(FINDLIBS-ST-PFX) ' +
|
|
Packit |
58578d |
'-l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) ' +
|
|
Packit |
58578d |
'$(OPTIONS) $(USER_OPTIONS)',
|
|
Packit |
58578d |
function = gcc_link_dll,
|
|
Packit |
58578d |
bound_list=['LIBRARIES'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Set up threading support. It's somewhat contrived, so perform it at the end,
|
|
Packit |
58578d |
# to avoid cluttering other code.
|
|
Packit |
58578d |
|
|
Packit |
58578d |
if on_windows():
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-mthreads'])
|
|
Packit |
58578d |
elif bjam.variable('UNIX'):
|
|
Packit |
58578d |
jamuname = bjam.variable('JAMUNAME')
|
|
Packit |
58578d |
host_os_name = jamuname[0]
|
|
Packit |
58578d |
if host_os_name.startswith('SunOS'):
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthreads'])
|
|
Packit |
58578d |
flags('gcc', 'FINDLIBS-SA', [], ['rt'])
|
|
Packit |
58578d |
elif host_os_name == 'BeOS':
|
|
Packit |
58578d |
# BeOS has no threading options, don't set anything here.
|
|
Packit |
58578d |
pass
|
|
Packit |
58578d |
elif host_os_name == 'Haiku':
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-lroot'])
|
|
Packit |
58578d |
# there is no -lrt on Haiku, and -pthread is implicit
|
|
Packit |
58578d |
elif host_os_name.endswith('BSD'):
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
|
|
Packit |
58578d |
# there is no -lrt on BSD
|
|
Packit |
58578d |
elif host_os_name == 'DragonFly':
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
|
|
Packit |
58578d |
# there is no -lrt on BSD - DragonFly is a FreeBSD variant,
|
|
Packit |
58578d |
# which anoyingly doesn't say it's a *BSD.
|
|
Packit |
58578d |
elif host_os_name == 'IRIX':
|
|
Packit |
58578d |
# gcc on IRIX does not support multi-threading, don't set anything here.
|
|
Packit |
58578d |
pass
|
|
Packit |
58578d |
elif host_os_name == 'Darwin':
|
|
Packit |
58578d |
# Darwin has no threading options, don't set anything here.
|
|
Packit |
58578d |
pass
|
|
Packit |
58578d |
else:
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<threading>multi'], ['-pthread'])
|
|
Packit |
58578d |
flags('gcc', 'FINDLIBS-SA', [], ['rt'])
|
|
Packit |
58578d |
|
|
Packit |
58578d |
def cpu_flags(toolset, variable, architecture, instruction_set, values, default=None):
|
|
Packit |
58578d |
#FIXME: for some reason this fails. Probably out of date feature code
|
|
Packit |
58578d |
## if default:
|
|
Packit |
58578d |
## flags(toolset, variable,
|
|
Packit |
58578d |
## ['<architecture>' + architecture + '/<instruction-set>'],
|
|
Packit |
58578d |
## values)
|
|
Packit |
58578d |
flags(toolset, variable,
|
|
Packit |
58578d |
#FIXME: same as above
|
|
Packit |
58578d |
[##'<architecture>/<instruction-set>' + instruction_set,
|
|
Packit |
58578d |
'<architecture>' + architecture + '/<instruction-set>' + instruction_set],
|
|
Packit |
58578d |
values)
|
|
Packit |
58578d |
|
|
Packit |
58578d |
# Set architecture/instruction-set options.
|
|
Packit |
58578d |
#
|
|
Packit |
58578d |
# x86 and compatible
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<architecture>x86/<address-model>32'], ['-m32'])
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<architecture>x86/<address-model>64'], ['-m64'])
|
|
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'], default=True)
|
|
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', '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', 'btver1', ['-march=btver1'])
|
|
Packit |
58578d |
cpu_flags('gcc', 'OPTIONS', 'x86', 'btver2', ['-march=btver2'])
|
|
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 |
flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>32'], ['-m32'])
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<architecture>sparc/<address-model>64'], ['-m64'])
|
|
Packit |
58578d |
cpu_flags('gcc', 'OPTIONS', 'sparc', 'v7', ['-mcpu=v7'], default=True)
|
|
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 |
flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>32'], ['-m32'])
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>64'], ['-m64'])
|
|
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 |
flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>32/<target-os>aix'], ['-maix32'])
|
|
Packit |
58578d |
flags('gcc', 'OPTIONS', ['<architecture>power/<address-model>64/<target-os>aix'], ['-maix64'])
|
|
Packit |
58578d |
flags('gcc', 'AROPTIONS', ['<architecture>power/<address-model>64/<target-os>aix'], ['-X64'])
|