]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/src/tools/clang-linux.jam
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / boost / tools / build / src / tools / clang-linux.jam
1 # Copyright 2021 Nikita Kniazev
2 # Copyright 2020 Rene Rivera
3 # Copyright (c) 2003 Michael Stevens
4 # Copyright (c) 2010-2011 Bryce Lelbach (blelbach@cct.lsu.edu, maintainer)
5 #
6 # Use, modification and distribution is subject to the Boost Software
7 # License Version 1.0. (See accompanying file LICENSE.txt or
8 # https://www.bfgroup.xyz/b2/LICENSE.txt)
9
10 import common ;
11 import toolset ;
12 import feature ;
13 import toolset : flags ;
14
15 import clang ;
16 import gcc ;
17 import common ;
18 import errors ;
19 import generators ;
20 import type ;
21 import numbers ;
22 import os ;
23 import property ;
24 import set ;
25
26 feature.extend-subfeature toolset clang : platform : linux ;
27
28 toolset.inherit-generators clang-linux
29 <toolset>clang <toolset-clang:platform>linux : gcc
30 : gcc.mingw.link gcc.mingw.link.dll gcc.cygwin.link gcc.cygwin.link.dll ;
31 generators.override clang-linux.prebuilt : builtin.lib-generator ;
32 generators.override clang-linux.prebuilt : builtin.prebuilt ;
33 generators.override clang-linux.searched-lib-generator : searched-lib-generator ;
34
35 # Override default do-nothing generators.
36 generators.override clang-linux.compile.c.pch : pch.default-c-pch-generator ;
37 generators.override clang-linux.compile.c++.pch : pch.default-cpp-pch-generator ;
38
39 toolset.inherit-rules clang-linux : gcc ;
40 toolset.inherit-flags clang-linux : gcc
41 : <inlining>full
42 <threading>multi/<target-os>windows
43 <lto>on/<lto-mode>full
44 <lto>on/<lto-mode>fat
45 ;
46
47 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] {
48 .debug-configuration = true ;
49 }
50
51 rule init ( version ? : command * : options * ) {
52 command = [ common.find-compiler clang-linux : clang++ : $(version) : $(command) ] ;
53 local command-string = [ common.make-command-string $(command) ] ;
54 if ! $(version) { # ?= operator does not short-circuit
55 version ?= [ get-short-version $(command-string) ] ;
56 }
57
58 local condition = [ common.check-init-parameters clang-linux
59 : version $(version) ] ;
60
61 common.handle-options clang-linux : $(condition) : $(command) : $(options) ;
62 clang.init-cxxstd-flags clang-linux : $(condition) : $(version) ;
63
64 # Support for gcc root as the backend, this is mainly useful for clang/gcc on Windows
65 # since on Linux gcc will be the default compiler already located on the PATH.
66 # On Windows it is possible to have multiple versions of mingw(-64)/gcc installed
67 # in different directories. The <root>option can be given so that the gcc backend
68 # can be found at runtime, while the $(command) can be a script that sets the
69 # PATH for both the clang directory and the backende gcc directory
70 # before calling clang++ when compiling/linking.
71
72 local root = [ feature.get-values <root> : $(options) ] ;
73
74 if $(root)
75 {
76 # On multilib 64-bit boxes, there are both 32-bit and 64-bit libraries
77 # and all must be added to LD_LIBRARY_PATH. The linker will pick the
78 # right onces. Note that we do not provide a clean way to build a 32-bit
79 # binary using a 64-bit compiler, but user can always pass -m32
80 # manually.
81 local lib_path = $(root)/bin $(root)/lib $(root)/lib32 $(root)/lib64 ;
82 if $(.debug-configuration)
83 {
84 ECHO "notice:" using gcc libraries with clang"::" $(condition) "::" $(lib_path) ;
85 }
86 toolset.flags clang-linux.link RUN_PATH $(condition) : $(lib_path) ;
87 }
88
89 # - Archive builder.
90 local archiver = [ feature.get-values <archiver> : $(options) ] ;
91 if ( ! $(archiver) ) && $(root)
92 {
93 archiver = $(root)/bin/ar ;
94 }
95 toolset.flags clang-linux.archive .AR $(condition) : $(archiver[1]) ;
96 }
97
98 rule get-full-version ( command-string )
99 {
100 return [ common.match-command-output version : "version ([0-9.]+)"
101 : "$(command-string) --version" ] ;
102 }
103
104 rule get-short-version ( command-string : single-digit-since ? )
105 {
106 local version = [ get-full-version $(command-string) ] ;
107 version = [ SPLIT_BY_CHARACTERS $(version) : . ] ;
108
109 import version ;
110 if [ version.version-less $(version) : $(single-digit-since:E=4) ]
111 {
112 return $(version[1-2]:J=.) ;
113 }
114
115 return $(version[1]) ;
116 }
117
118 ###############################################################################
119 # Flags
120
121 local all-os = [ feature.values <target-os> ] ;
122
123 # note: clang silently ignores some of these inlining options
124 # For clang, 'on' and 'full' are identical.
125 toolset.flags clang-linux.compile OPTIONS <inlining>full : -Wno-inline ;
126
127 toolset.flags clang-linux.compile OPTIONS <threading>multi/<target-os>windows : -pthread ;
128 toolset.flags clang-linux.link OPTIONS <threading>multi/<target-os>windows : -pthread ;
129
130 # LTO
131 toolset.flags clang-linux.compile OPTIONS <lto>on/<lto-mode>thin : -flto=thin ;
132 toolset.flags clang-linux.link OPTIONS <lto>on/<lto-mode>thin : -flto=thin ;
133
134 toolset.flags clang-linux.compile OPTIONS <lto>on/<lto-mode>full : -flto=full ;
135 toolset.flags clang-linux.link OPTIONS <lto>on/<lto-mode>full : -flto=full ;
136
137 # stdlib selection
138 toolset.flags clang-linux.compile OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ;
139 toolset.flags clang-linux.link OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ;
140
141 toolset.flags clang-linux.compile OPTIONS <stdlib>libc++ : -stdlib=libc++ ;
142 toolset.flags clang-linux.link OPTIONS <stdlib>libc++ : -stdlib=libc++ ;
143
144 # Enable response file control
145 toolset.flags clang-linux RESPONSE_FILE_SUB <response-file>auto : a ;
146 toolset.flags clang-linux RESPONSE_FILE_SUB <response-file>file : f ;
147 toolset.flags clang-linux RESPONSE_FILE_SUB <response-file>contents : c ;
148
149 # Used in actions for multi argument options
150 _ = " " ;
151 ###############################################################################
152 # C and C++ compilation
153
154 rule compile.c++ ( targets * : sources * : properties * ) {
155 DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
156 }
157
158 actions compile.c++ bind PCH_FILE
159 {
160 "$(CONFIG_COMMAND)" -c -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang$(_)-include-pch$(_)-Xclang$(_)"$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -o "$(<)" "$(>)"
161 }
162
163 rule compile.c ( targets * : sources * : properties * )
164 {
165 DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ;
166 }
167
168 actions compile.c bind PCH_FILE
169 {
170 "$(CONFIG_COMMAND)" -c -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -Xclang$(_)-include-pch$(_)-Xclang$(_)"$(PCH_FILE)" -include"$(FORCE_INCLUDES)" -c -o "$(<)" "$(>)"
171 }
172
173 ###############################################################################
174 # Linking
175
176 local soname-os = [ set.difference $(all-os) : windows ] ;
177 toolset.flags clang-linux.link SONAME_OPT <target-os>$(soname-os) : "-Wl,-soname -Wl," ;
178
179 actions link bind LIBRARIES {
180 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" @($(<[1]:T).rsp:O=FC:<=@":>=":E=-Wl,-R$(_)-Wl,$(RPATH) -Wl,-rpath-link$(_)-Wl,"$(RPATH_LINK)" $(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP)) $(OPTIONS) $(USER_OPTIONS)
181 }
182
183 actions link.dll bind LIBRARIES {
184 "$(CONFIG_COMMAND)" -L"$(LINKPATH)" -o "$(<)" @($(<[1]:T).rsp:O=FC:<=@":>=":E=-Wl,-R$(_)-Wl,$(RPATH) $(SONAME_OPT)$(<[1]:D=) -shared $(START-GROUP) "$(>:T)" "$(LIBRARIES:T)" $(FINDLIBS-ST-PFX:T) -l$(FINDLIBS-ST:T) $(FINDLIBS-SA-PFX:T) -l$(FINDLIBS-SA:T) $(END-GROUP)) $(OPTIONS) $(USER_OPTIONS)
185 }