]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright (c) 2001 David Abrahams. |
2 | # Copyright (c) 2002-2003 Rene Rivera. | |
3 | # Copyright (c) 2002-2003 Vladimir Prus. | |
20effc67 | 4 | # Copyright (c) 2020 Alexander Karzhenkov. |
7c673cae FG |
5 | # |
6 | # Use, modification and distribution is subject to the Boost Software | |
1e59de90 TL |
7 | # License Version 1.0. (See accompanying file LICENSE.txt or |
8 | # https://www.bfgroup.xyz/b2/LICENSE.txt) | |
7c673cae FG |
9 | |
10 | import "class" : new ; | |
11 | import common ; | |
12 | import errors ; | |
13 | import feature ; | |
14 | import generators ; | |
15 | import os ; | |
16 | import property ; | |
17 | import set ; | |
18 | import toolset ; | |
19 | import type ; | |
20 | import unix ; | |
21 | ||
22 | feature.extend toolset : qcc ; | |
23 | ||
24 | toolset.inherit-generators qcc : unix : unix.link unix.link.dll ; | |
7c673cae FG |
25 | toolset.inherit-flags qcc : unix ; |
26 | toolset.inherit-rules qcc : unix ; | |
27 | ||
28 | # Initializes the qcc toolset for the given version. If necessary, command may | |
29 | # be used to specify where the compiler is located. The parameter 'options' is a | |
30 | # space-delimited list of options, each one being specified as | |
31 | # <option-name>option-value. Valid option names are: cxxflags, linkflags and | |
32 | # linker-type. Accepted values for linker-type are gnu and sun, gnu being the | |
33 | # default. | |
34 | # | |
35 | # Example: | |
36 | # using qcc : 3.4 : : <cxxflags>foo <linkflags>bar <linker-type>sun ; | |
37 | # | |
38 | rule init ( version ? : command * : options * ) | |
39 | { | |
40 | local condition = [ common.check-init-parameters qcc : version $(version) ] ; | |
41 | local command = [ common.get-invocation-command qcc : QCC : $(command) ] ; | |
42 | common.handle-options qcc : $(condition) : $(command) : $(options) ; | |
43 | } | |
44 | ||
45 | ||
46 | generators.register-c-compiler qcc.compile.c++ : CPP : OBJ : <toolset>qcc ; | |
47 | generators.register-c-compiler qcc.compile.c : C : OBJ : <toolset>qcc ; | |
48 | generators.register-c-compiler qcc.compile.asm : ASM : OBJ : <toolset>qcc ; | |
49 | ||
50 | ||
20effc67 TL |
51 | # Select QCC target platform |
52 | ||
53 | # Configuration checks don't use explicit value of QCC-TARGET-PLATFORM | |
54 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>/<address-model> : NA ; | |
55 | ||
56 | # Combinations supported by both QNX 6.5.0 and QNX 7.0.0 | |
57 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>x86/<address-model>32 : -Vgcc_ntox86 ; | |
58 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>arm/<address-model>32 : -Vgcc_ntoarmv7le ; | |
59 | ||
60 | # Combinations supported by QNX 7.0.0 | |
61 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>x86/<address-model>64 : -Vgcc_ntox86_64 ; | |
62 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>arm/<address-model>64 : -Vgcc_ntoaarch64le ; | |
63 | ||
64 | # Combinations supported by QNX 6.5.0 | |
65 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>power/<address-model>32 : -Vgcc_ntoppcbe ; | |
1e59de90 | 66 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>mips/<address-model>32 : -Vgcc_ntomipsle ; |
20effc67 TL |
67 | toolset.flags qcc QCC-TARGET-PLATFORM <architecture>mips1/<address-model>32 : -Vgcc_ntomipsle ; |
68 | ||
69 | # There are also excluded alternatives (supported by QNX 6.5.0) | |
70 | # toolset.flags qcc QCC-TARGET-PLATFORM <architecture>arm/<address-model>32 : -Vgcc_ntoarmle ; | |
71 | # toolset.flags qcc QCC-TARGET-PLATFORM <architecture>power/<address-model>32 : -Vgcc_ntoppcbespe ; | |
1e59de90 | 72 | # toolset.flags qcc QCC-TARGET-PLATFORM <architecture>mips/<address-model>32 : -Vgcc_ntomipsbe ; |
20effc67 TL |
73 | # toolset.flags qcc QCC-TARGET-PLATFORM <architecture>mips1/<address-model>32 : -Vgcc_ntomipsbe ; |
74 | ||
75 | local rule check-target-platform | |
76 | { | |
77 | local opt = [ on $(1) return $(QCC-TARGET-PLATFORM) ] ; | |
78 | ||
79 | if $(opt) = NA | |
80 | { | |
81 | # Configuration checks are performed | |
82 | QCC-TARGET-PLATFORM on $(1) = ; | |
83 | } | |
84 | else if ! $(opt) | |
85 | { | |
86 | errors.user-error "Unsupported achitecture / address model" ; | |
87 | } | |
88 | } | |
89 | ||
7c673cae FG |
90 | # Declare flags for compilation. |
91 | toolset.flags qcc.compile OPTIONS <debug-symbols>on : -gstabs+ ; | |
92 | ||
93 | # Declare flags and action for compilation. | |
94 | toolset.flags qcc.compile OPTIONS <optimization>off : -O0 ; | |
95 | toolset.flags qcc.compile OPTIONS <optimization>speed : -O3 ; | |
96 | toolset.flags qcc.compile OPTIONS <optimization>space : -Os ; | |
97 | ||
98 | toolset.flags qcc.compile OPTIONS <inlining>off : -Wc,-fno-inline ; | |
99 | toolset.flags qcc.compile OPTIONS <inlining>on : -Wc,-Wno-inline ; | |
100 | toolset.flags qcc.compile OPTIONS <inlining>full : -Wc,-finline-functions -Wc,-Wno-inline ; | |
101 | ||
102 | toolset.flags qcc.compile OPTIONS <warnings>off : -w ; | |
103 | toolset.flags qcc.compile OPTIONS <warnings>all : -Wc,-Wall ; | |
20effc67 TL |
104 | toolset.flags qcc.compile OPTIONS <warnings>extra : -Wc,-Wall -Wc,-Wextra ; |
105 | toolset.flags qcc.compile OPTIONS <warnings>pedantic : -Wc,-Wall -Wc,-Wextra -Wc,-pedantic ; | |
7c673cae FG |
106 | toolset.flags qcc.compile OPTIONS <warnings-as-errors>on : -Wc,-Werror ; |
107 | ||
108 | toolset.flags qcc.compile OPTIONS <profiling>on : -p ; | |
109 | ||
92f5a8d4 TL |
110 | toolset.flags qcc.compile OPTIONS <local-visibility>hidden : -fvisibility=hidden ; |
111 | toolset.flags qcc.compile.c++ OPTIONS <local-visibility>hidden : -fvisibility-inlines-hidden ; | |
112 | toolset.flags qcc.compile OPTIONS <local-visibility>protected : -fvisibility=protected ; | |
113 | toolset.flags qcc.compile OPTIONS <local-visibility>global : -fvisibility=default ; | |
114 | ||
7c673cae FG |
115 | toolset.flags qcc.compile OPTIONS <cflags> ; |
116 | toolset.flags qcc.compile.c++ OPTIONS <cxxflags> ; | |
117 | toolset.flags qcc.compile DEFINES <define> ; | |
118 | toolset.flags qcc.compile INCLUDES <include> ; | |
119 | ||
120 | toolset.flags qcc.compile OPTIONS <link>shared : -shared ; | |
121 | ||
122 | toolset.flags qcc.compile.c++ TEMPLATE_DEPTH <c++-template-depth> ; | |
123 | ||
124 | ||
125 | rule compile.c++ | |
126 | { | |
127 | # Here we want to raise the template-depth parameter value to something | |
128 | # higher than the default value of 17. Note that we could do this using the | |
129 | # feature.set-default rule but we do not want to set the default value for | |
130 | # all toolsets as well. | |
131 | # | |
132 | # TODO: This 'modified default' has been inherited from some 'older Boost | |
133 | # Build implementation' and has most likely been added to make some Boost | |
134 | # library parts compile correctly. We should see what exactly prompted this | |
135 | # and whether we can get around the problem more locally. | |
136 | local template-depth = [ on $(1) return $(TEMPLATE_DEPTH) ] ; | |
137 | if ! $(template-depth) | |
138 | { | |
139 | TEMPLATE_DEPTH on $(1) = 128 ; | |
140 | } | |
20effc67 TL |
141 | |
142 | check-target-platform $(1) ; | |
7c673cae FG |
143 | } |
144 | ||
145 | actions compile.c++ | |
146 | { | |
20effc67 TL |
147 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) -Wc,-ftemplate-depth-$(TEMPLATE_DEPTH) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
148 | } | |
149 | ||
150 | rule compile.c | |
151 | { | |
152 | check-target-platform $(1) ; | |
7c673cae FG |
153 | } |
154 | ||
155 | actions compile.c | |
156 | { | |
20effc67 TL |
157 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) -lang-c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
158 | } | |
159 | ||
160 | rule compile.asm | |
161 | { | |
162 | check-target-platform $(1) ; | |
7c673cae FG |
163 | } |
164 | ||
165 | actions compile.asm | |
166 | { | |
20effc67 | 167 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
7c673cae FG |
168 | } |
169 | ||
170 | ||
171 | # The class checking that we do not try to use the <runtime-link>static property | |
172 | # while creating or using a shared library, since it is not supported by qcc/ | |
173 | # /libc. | |
174 | # | |
175 | class qcc-linking-generator : unix-linking-generator | |
176 | { | |
177 | rule generated-targets ( sources + : property-set : project name ? ) | |
178 | { | |
179 | if <runtime-link>static in [ $(property-set).raw ] | |
180 | { | |
181 | local m ; | |
182 | if [ id ] = "qcc.link.dll" | |
183 | { | |
184 | m = "on qcc, DLL can't be build with <runtime-link>static" ; | |
185 | } | |
186 | if ! $(m) | |
187 | { | |
188 | for local s in $(sources) | |
189 | { | |
190 | local type = [ $(s).type ] ; | |
191 | if $(type) && [ type.is-derived $(type) SHARED_LIB ] | |
192 | { | |
193 | m = "on qcc, using DLLS together with the <runtime-link>static options is not possible " ; | |
194 | } | |
195 | } | |
196 | } | |
197 | if $(m) | |
198 | { | |
199 | errors.user-error $(m) : "It is suggested to use" | |
200 | "<runtime-link>static together with <link>static." ; | |
201 | } | |
202 | } | |
203 | ||
204 | return [ unix-linking-generator.generated-targets | |
205 | $(sources) : $(property-set) : $(project) $(name) ] ; | |
206 | } | |
207 | } | |
208 | ||
209 | generators.register [ new qcc-linking-generator qcc.link : LIB OBJ : EXE | |
210 | : <toolset>qcc ] ; | |
211 | ||
212 | generators.register [ new qcc-linking-generator qcc.link.dll : LIB OBJ | |
213 | : SHARED_LIB : <toolset>qcc ] ; | |
214 | ||
215 | generators.override qcc.prebuilt : builtin.prebuilt ; | |
216 | generators.override qcc.searched-lib-generator : searched-lib-generator ; | |
217 | ||
218 | ||
219 | # Declare flags for linking. | |
220 | # First, the common flags. | |
221 | toolset.flags qcc.link OPTIONS <debug-symbols>on : -gstabs+ ; | |
222 | toolset.flags qcc.link OPTIONS <profiling>on : -p ; | |
223 | toolset.flags qcc.link OPTIONS <linkflags> ; | |
224 | toolset.flags qcc.link LINKPATH <library-path> ; | |
225 | toolset.flags qcc.link FINDLIBS-ST <find-static-library> ; | |
226 | toolset.flags qcc.link FINDLIBS-SA <find-shared-library> ; | |
227 | toolset.flags qcc.link LIBRARIES <library-file> ; | |
228 | ||
229 | toolset.flags qcc.link FINDLIBS-SA : m ; | |
230 | ||
231 | # For <runtime-link>static we made sure there are no dynamic libraries in the | |
232 | # link. | |
233 | toolset.flags qcc.link OPTIONS <runtime-link>static : -static ; | |
234 | ||
235 | # Assuming this is just like with gcc. | |
236 | toolset.flags qcc.link RPATH : <dll-path> : unchecked ; | |
237 | toolset.flags qcc.link RPATH_LINK : <xdll-path> : unchecked ; | |
238 | ||
239 | ||
240 | # Declare actions for linking. | |
241 | # | |
242 | rule link ( targets * : sources * : properties * ) | |
243 | { | |
244 | SPACE on $(targets) = " " ; | |
20effc67 | 245 | check-target-platform $(1) ; |
7c673cae FG |
246 | } |
247 | ||
248 | actions link bind LIBRARIES | |
249 | { | |
20effc67 | 250 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -Wl,-rpath-link$(SPACE)-Wl,"$(RPATH_LINK)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) |
7c673cae FG |
251 | } |
252 | ||
253 | ||
254 | # Always remove archive and start again. Here is the rationale from Andre Hentz: | |
255 | # I had a file, say a1.c, that was included into liba.a. I moved a1.c to a2.c, | |
256 | # updated my Jamfiles and rebuilt. My program was crashing with absurd errors. | |
257 | # After some debugging I traced it back to the fact that a1.o was *still* in | |
258 | # liba.a | |
259 | RM = [ common.rm-command ] ; | |
260 | if [ os.name ] = NT | |
261 | { | |
262 | RM = "if exist \"$(<[1])\" DEL \"$(<[1])\"" ; | |
263 | } | |
264 | ||
265 | ||
266 | # Declare action for creating static libraries. The 'r' letter means to add | |
267 | # files to the archive with replacement. Since we remove the archive, we do not | |
268 | # care about replacement, but there is no option to "add without replacement". | |
269 | # The 'c' letter suppresses warnings in case the archive does not exists yet. | |
270 | # That warning is produced only on some platforms, for whatever reasons. | |
271 | # | |
272 | # Use qcc driver to create archive, see | |
273 | # http://www.qnx.com/developers/docs/6.3.2/neutrino/utilities/q/qcc.html | |
20effc67 TL |
274 | |
275 | rule archive | |
276 | { | |
277 | check-target-platform $(1) ; | |
278 | } | |
279 | ||
7c673cae FG |
280 | actions piecemeal archive |
281 | { | |
282 | $(RM) "$(<)" | |
20effc67 | 283 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) -A "$(<)" "$(>)" |
7c673cae FG |
284 | } |
285 | ||
286 | ||
287 | rule link.dll ( targets * : sources * : properties * ) | |
288 | { | |
289 | SPACE on $(targets) = " " ; | |
20effc67 | 290 | check-target-platform $(1) ; |
7c673cae FG |
291 | } |
292 | ||
293 | ||
294 | # Differ from 'link' above only by -shared. | |
295 | # | |
296 | actions link.dll bind LIBRARIES | |
297 | { | |
20effc67 | 298 | "$(CONFIG_COMMAND)" $(QCC-TARGET-PLATFORM) -L"$(LINKPATH)" -Wl,-R$(SPACE)-Wl,"$(RPATH)" -o "$(<)" -Wl,-h$(SPACE)-Wl,$(<[1]:D=) -shared "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-ST) -l$(FINDLIBS-SA) $(OPTIONS) |
7c673cae | 299 | } |