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