]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright 2001 David Abrahams. |
2 | # Copyright 2004, 2005 Markus Schoepflin. | |
3 | # Distributed under the Boost Software License, Version 1.0. | |
1e59de90 | 4 | # (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt) |
7c673cae | 5 | |
92f5a8d4 TL |
6 | #| tag::doc[] |
7 | ||
8 | [[bbv2.reference.tools.compiler.hp_cxx]] | |
9 | = HP C++ Compiler for Tru64 Unix | |
10 | ||
11 | The `hp_cxx` modules supports the | |
12 | http://h30097.www3.hp.com/cplus/?jumpid=reg_R1002_USEN[HP C++ Compiler] | |
13 | for Tru64 Unix. | |
14 | ||
15 | The module is initialized using the following syntax: | |
16 | ||
17 | ---- | |
18 | using hp_cxx : [version] : [c++-compile-command] : [compiler options] ; | |
19 | ---- | |
20 | ||
21 | This statement may be repeated several times, if you want to configure | |
22 | several versions of the compiler. | |
23 | ||
f67539c2 | 24 | If the command is not specified, B2 will search for a binary |
92f5a8d4 TL |
25 | named `hp_cxx` in PATH. |
26 | ||
27 | The following options can be provided, using | |
28 | _`<option-name>option-value syntax`_: | |
29 | ||
30 | `cflags`:: | |
31 | Specifies additional compiler flags that will be used when compiling C | |
32 | sources. | |
33 | ||
34 | `cxxflags`:: | |
35 | Specifies additional compiler flags that will be used when compiling C++ | |
36 | sources. | |
37 | ||
38 | `compileflags`:: | |
39 | Specifies additional compiler flags that will be used when compiling both C | |
40 | and C++ sources. | |
41 | ||
42 | `linkflags`:: | |
43 | Specifies additional command line options that will be passed to the linker. | |
44 | ||
45 | |# # end::doc[] | |
46 | ||
7c673cae FG |
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 | ||
72 | import feature generators common ; | |
73 | import toolset : flags ; | |
74 | ||
75 | feature.extend toolset : hp_cxx ; | |
76 | feature.extend c++abi : cxxarm ; | |
77 | ||
78 | # Inherit from Unix toolset to get library ordering magic. | |
79 | toolset.inherit hp_cxx : unix ; | |
80 | ||
81 | generators.override hp_cxx.prebuilt : builtin.lib-generator ; | |
82 | generators.override hp_cxx.prebuilt : builtin.prebuilt ; | |
83 | generators.override hp_cxx.searched-lib-generator : searched-lib-generator ; | |
84 | ||
85 | ||
86 | rule init ( version ? : command * : options * ) | |
87 | { | |
88 | local condition = [ common.check-init-parameters hp_cxx : version $(version) ] ; | |
f67539c2 | 89 | |
7c673cae | 90 | local command = [ common.get-invocation-command hp_cxx : cxx : $(command) ] ; |
f67539c2 | 91 | |
7c673cae FG |
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)\"/" ; | |
f67539c2 TL |
99 | } |
100 | } | |
7c673cae FG |
101 | # If we can't find 'cxx' anyway, at least show 'cxx' in the commands |
102 | command ?= cxx ; | |
f67539c2 TL |
103 | |
104 | common.handle-options hp_cxx : $(condition) : $(command) : $(options) ; | |
7c673cae FG |
105 | } |
106 | ||
107 | generators.register-c-compiler hp_cxx.compile.c++ : CPP : OBJ : <toolset>hp_cxx ; | |
108 | generators.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 ; | |
114 | flags hp_cxx.compile OPTIONS <debug-symbols>on : -g3 ; | |
115 | flags hp_cxx.compile OPTIONS <optimization>off/<debug-symbols>on : -gall ; | |
116 | flags hp_cxx.link OPTIONS <debug-symbols>on : -g ; | |
117 | flags hp_cxx.link OPTIONS <debug-symbols>off : -s ; | |
118 | ||
119 | flags hp_cxx.compile OPTIONS <optimization>off : -O0 ; | |
120 | flags hp_cxx.compile OPTIONS <optimization>speed/<inlining>on : -O2 ; | |
121 | flags 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. | |
125 | flags hp_cxx.compile.c++ OPTIONS : -D__CNAME_OVERLOADS ; | |
126 | ||
127 | # Added for threading support | |
128 | flags hp_cxx.compile OPTIONS <threading>multi : -pthread ; | |
129 | flags hp_cxx.link OPTIONS <threading>multi : -pthread ; | |
130 | ||
131 | flags hp_cxx.compile OPTIONS <optimization>space/<inlining>on : <inlining>size ; | |
132 | flags hp_cxx.compile OPTIONS <optimization>space : -O1 ; | |
133 | flags 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 | ||
140 | flags hp_cxx.compile OPTIONS <profiling>on : -pg ; | |
141 | flags 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. | |
148 | flags hp_cxx.compile.c++ OPTIONS <c++abi> : -model ansi : : hack-hack ; | |
149 | flags hp_cxx.compile.c++ OPTIONS <c++abi>cxxarm : -model arm ; | |
150 | flags hp_cxx.link OPTIONS <c++abi> : -model ansi : : hack-hack ; | |
151 | flags hp_cxx.link OPTIONS <c++abi>cxxarm : -model arm ; | |
152 | ||
153 | # Display a descriptive tag together with each compiler message. This tag can | |
92f5a8d4 | 154 | # be used by the user to explicitly suppress the compiler message. |
7c673cae FG |
155 | flags hp_cxx.compile OPTIONS : -msg_display_tag ; |
156 | ||
157 | flags hp_cxx.compile OPTIONS <cflags> ; | |
158 | flags hp_cxx.compile.c++ OPTIONS <cxxflags> ; | |
159 | flags hp_cxx.compile DEFINES <define> ; | |
160 | flags hp_cxx.compile INCLUDES <include> ; | |
161 | flags hp_cxx.link OPTIONS <linkflags> ; | |
162 | ||
163 | flags hp_cxx.link LIBPATH <library-path> ; | |
164 | flags hp_cxx.link LIBRARIES <library-file> ; | |
165 | flags hp_cxx.link FINDLIBS-ST <find-static-library> ; | |
166 | flags hp_cxx.link FINDLIBS-SA <find-shared-library> ; | |
167 | ||
168 | flags hp_cxx.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ; | |
169 | ||
170 | actions 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 | ||
180 | actions 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. | |
189 | actions 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 | ||
200 | rule 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 | ||
211 | actions 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. | |
217 | RM = [ common.rm-command ] ; | |
218 | actions together piecemeal archive | |
219 | { | |
220 | $(RM) "$(<)" | |
221 | ar rc $(<) $(>) | |
222 | } |