1# Copyright 2001 David Abrahams. 2# Copyright 2004, 2005 Markus Schoepflin. 3# Distributed under the Boost Software License, Version 1.0. 4# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 5 6#| tag::doc[] 7 8[[bbv2.reference.tools.compiler.hp_cxx]] 9= HP C++ Compiler for Tru64 Unix 10 11The `hp_cxx` modules supports the 12http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN[HP C++ Compiler] 13for Tru64 Unix. 14 15The module is initialized using the following syntax: 16 17---- 18using hp_cxx : [version] : [c++-compile-command] : [compiler options] ; 19---- 20 21This statement may be repeated several times, if you want to configure 22several versions of the compiler. 23 24If the command is not specified, B2 will search for a binary 25named `hp_cxx` in PATH. 26 27The following options can be provided, using 28_`<option-name>option-value syntax`_: 29 30`cflags`:: 31Specifies additional compiler flags that will be used when compiling C 32sources. 33 34`cxxflags`:: 35Specifies additional compiler flags that will be used when compiling C++ 36sources. 37 38`compileflags`:: 39Specifies additional compiler flags that will be used when compiling both C 40and C++ sources. 41 42`linkflags`:: 43Specifies additional command line options that will be passed to the linker. 44 45|# # end::doc[] 46 47# 48# HP CXX compiler 49# See http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN 50# 51# 52# Notes on this toolset: 53# 54# - Because of very subtle issues with the default ansi mode, strict_ansi mode 55# is used for compilation. One example of things that don't work correctly in 56# the default ansi mode is overload resolution of function templates when 57# mixed with non-template functions. 58# 59# - For template instantiation "-timplicit_local" is used. Previously, 60# "-tlocal" has been tried to avoid the need for a template repository 61# but this doesn't work with manually instantiated templates. "-tweak" 62# has not been used to avoid the stream of warning messages issued by 63# ar or ld when creating a library or linking an application. 64# 65# - Debug symbols are generated with "-g3", as this works both in debug and 66# release mode. When compiling C++ code without optimization, we additionally 67# use "-gall", which generates full symbol table information for all classes, 68# structs, and unions. As this turns off optimization, it can't be used when 69# optimization is needed. 70# 71 72import feature generators common ; 73import toolset : flags ; 74 75feature.extend toolset : hp_cxx ; 76feature.extend c++abi : cxxarm ; 77 78# Inherit from Unix toolset to get library ordering magic. 79toolset.inherit hp_cxx : unix ; 80 81generators.override hp_cxx.prebuilt : builtin.lib-generator ; 82generators.override hp_cxx.prebuilt : builtin.prebuilt ; 83generators.override hp_cxx.searched-lib-generator : searched-lib-generator ; 84 85 86rule init ( version ? : command * : options * ) 87{ 88 local condition = [ common.check-init-parameters hp_cxx : version $(version) ] ; 89 90 local command = [ common.get-invocation-command hp_cxx : cxx : $(command) ] ; 91 92 if $(command) 93 { 94 local root = [ common.get-absolute-tool-path $(command[-1]) ] ; 95 96 if $(root) 97 { 98 flags hp_cxx .root $(condition) : "\"$(root)\"/" ; 99 } 100 } 101 # If we can't find 'cxx' anyway, at least show 'cxx' in the commands 102 command ?= cxx ; 103 104 common.handle-options hp_cxx : $(condition) : $(command) : $(options) ; 105} 106 107generators.register-c-compiler hp_cxx.compile.c++ : CPP : OBJ : <toolset>hp_cxx ; 108generators.register-c-compiler hp_cxx.compile.c : C : OBJ : <toolset>hp_cxx ; 109 110 111 112# No static linking as far as I can tell. 113# flags cxx LINKFLAGS <runtime-link>static : -bstatic ; 114flags hp_cxx.compile OPTIONS <debug-symbols>on : -g3 ; 115flags hp_cxx.compile OPTIONS <optimization>off/<debug-symbols>on : -gall ; 116flags hp_cxx.link OPTIONS <debug-symbols>on : -g ; 117flags hp_cxx.link OPTIONS <debug-symbols>off : -s ; 118 119flags hp_cxx.compile OPTIONS <optimization>off : -O0 ; 120flags hp_cxx.compile OPTIONS <optimization>speed/<inlining>on : -O2 ; 121flags hp_cxx.compile OPTIONS <optimization>speed : -O2 ; 122 123# This (undocumented) macro needs to be defined to get all C function 124# overloads required by the C++ standard. 125flags hp_cxx.compile.c++ OPTIONS : -D__CNAME_OVERLOADS ; 126 127# Added for threading support 128flags hp_cxx.compile OPTIONS <threading>multi : -pthread ; 129flags hp_cxx.link OPTIONS <threading>multi : -pthread ; 130 131flags hp_cxx.compile OPTIONS <optimization>space/<inlining>on : <inlining>size ; 132flags hp_cxx.compile OPTIONS <optimization>space : -O1 ; 133flags hp_cxx.compile OPTIONS <inlining>off : -inline none ; 134 135# The compiler versions tried (up to V6.5-040) hang when compiling Boost code 136# with full inlining enabled. So leave it at the default level for now. 137# 138# flags hp_cxx.compile OPTIONS <inlining>full : -inline all ; 139 140flags hp_cxx.compile OPTIONS <profiling>on : -pg ; 141flags hp_cxx.link OPTIONS <profiling>on : -pg ; 142 143# Selection of the object model. This flag is needed on both the C++ compiler 144# and linker command line. 145 146# Unspecified ABI translates to '-model ansi' as most 147# standard-conforming. 148flags hp_cxx.compile.c++ OPTIONS <c++abi> : -model ansi : : hack-hack ; 149flags hp_cxx.compile.c++ OPTIONS <c++abi>cxxarm : -model arm ; 150flags hp_cxx.link OPTIONS <c++abi> : -model ansi : : hack-hack ; 151flags hp_cxx.link OPTIONS <c++abi>cxxarm : -model arm ; 152 153# Display a descriptive tag together with each compiler message. This tag can 154# be used by the user to explicitly suppress the compiler message. 155flags hp_cxx.compile OPTIONS : -msg_display_tag ; 156 157flags hp_cxx.compile OPTIONS <cflags> ; 158flags hp_cxx.compile.c++ OPTIONS <cxxflags> ; 159flags hp_cxx.compile DEFINES <define> ; 160flags hp_cxx.compile INCLUDES <include> ; 161flags hp_cxx.link OPTIONS <linkflags> ; 162 163flags hp_cxx.link LIBPATH <library-path> ; 164flags hp_cxx.link LIBRARIES <library-file> ; 165flags hp_cxx.link FINDLIBS-ST <find-static-library> ; 166flags hp_cxx.link FINDLIBS-SA <find-shared-library> ; 167 168flags hp_cxx.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ; 169 170actions link bind LIBRARIES 171{ 172 $(CONFIG_COMMAND) -noimplicit_include $(OPTIONS) -o "$(<)" -L$(LIBPATH) "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) -lrt -lm 173} 174 175# When creating dynamic libraries, we don't want to be warned about unresolved 176# symbols, therefore all unresolved symbols are marked as expected by 177# '-expect_unresolved *'. This also mirrors the behaviour of the GNU tool 178# chain. 179 180actions link.dll bind LIBRARIES 181{ 182 $(CONFIG_COMMAND) -shared -expect_unresolved \* -noimplicit_include $(OPTIONS) -o "$(<[1])" -L$(LIBPATH) "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) -lm 183} 184 185 186# Note: Relaxed ANSI mode (-std) is used for compilation because in strict ANSI 187# C89 mode (-std1) the compiler doesn't accept C++ comments in C files. As -std 188# is the default, no special flag is needed. 189actions compile.c 190{ 191 $(.root:E=)cc -c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)" 192} 193 194# Note: The compiler is forced to compile the files as C++ (-x cxx) because 195# otherwise it will silently ignore files with no file extension. 196# 197# Note: We deliberately don't suppress any warnings on the compiler command 198# line, the user can always do this in a customized toolset later on. 199 200rule compile.c++ 201{ 202 # We preprocess the TEMPLATE_DEPTH command line option here because we found 203 # no way to do it correctly in the actual action code. There we either get 204 # the -pending_instantiations parameter when no c++-template-depth property 205 # has been specified or we get additional quotes around 206 # "-pending_instantiations ". 207 local template-depth = [ on $(1) return $(TEMPLATE_DEPTH) ] ; 208 TEMPLATE_DEPTH on $(1) = "-pending_instantiations "$(template-depth) ; 209} 210 211actions compile.c++ 212{ 213 $(CONFIG_COMMAND) -x cxx -c -std strict_ansi -nopure_cname -noimplicit_include -timplicit_local -ptr "$(<[1]:D)/cxx_repository" $(OPTIONS) $(TEMPLATE_DEPTH) -D$(DEFINES) -I"$(INCLUDES)" -o "$(<)" "$(>)" 214} 215 216# Always create archive from scratch. See the gcc toolet for rationale. 217RM = [ common.rm-command ] ; 218actions together piecemeal archive 219{ 220 $(RM) "$(<)" 221 ar rc $(<) $(>) 222} 223