]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | # Copyright Vladimir Prus 2004. |
2 | # Copyright Noel Belcourt 2007. | |
3 | # Distributed under the Boost Software License, Version 1.0. | |
4 | # (See accompanying file LICENSE_1_0.txt | |
5 | # or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ||
7 | import clang ; | |
8 | import feature : feature ; | |
9 | import os ; | |
10 | import toolset ; | |
11 | import toolset : flags ; | |
12 | import gcc ; | |
13 | import common ; | |
14 | import errors ; | |
15 | import generators ; | |
16 | ||
17 | feature.extend-subfeature toolset clang : platform : darwin ; | |
18 | ||
f67539c2 TL |
19 | toolset.inherit-generators clang-darwin |
20 | <toolset>clang <toolset-clang:platform>darwin | |
21 | : gcc | |
7c673cae FG |
22 | # Don't inherit PCH generators. They were not tested, and probably |
23 | # don't work for this compiler. | |
24 | : gcc.mingw.link gcc.mingw.link.dll gcc.compile.c.pch gcc.compile.c++.pch | |
25 | ; | |
26 | ||
27 | generators.override clang-darwin.prebuilt : builtin.lib-generator ; | |
28 | generators.override clang-darwin.prebuilt : builtin.prebuilt ; | |
29 | generators.override clang-darwin.searched-lib-generator : searched-lib-generator ; | |
30 | ||
31 | generators.register-c-compiler clang-darwin.compile.m : OBJECTIVE_C : OBJ : <toolset>clang <toolset-clang:platform>darwin ; | |
32 | generators.register-c-compiler clang-darwin.compile.mm : OBJECTIVE_CPP : OBJ : <toolset>clang <toolset-clang:platform>darwin ; | |
33 | ||
34 | toolset.inherit-rules clang-darwin : gcc ; | |
f67539c2 | 35 | toolset.inherit-flags clang-darwin : gcc |
11fdf7f2 | 36 | : <inlining>full |
7c673cae FG |
37 | <architecture>x86/<address-model>32 |
38 | <architecture>x86/<address-model>64 | |
f67539c2 TL |
39 | <lto>on/<lto-mode>full |
40 | <lto>on/<lto-mode>fat | |
7c673cae | 41 | ; |
f67539c2 | 42 | |
7c673cae FG |
43 | if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] |
44 | { | |
45 | .debug-configuration = true ; | |
46 | } | |
f67539c2 | 47 | |
7c673cae FG |
48 | # Initializes the clang-darwin toolset |
49 | # version in optional | |
92f5a8d4 | 50 | # name (default clang++) is used to invoke the specified clang compiler |
7c673cae FG |
51 | # compile and link options allow you to specify addition command line options for each version |
52 | rule init ( version ? : command * : options * ) | |
53 | { | |
f67539c2 | 54 | command = [ common.get-invocation-command clang-darwin : clang++ |
b32b8144 | 55 | : $(command) : /usr/bin /usr/local/bin ] ; |
7c673cae FG |
56 | |
57 | # Determine the version | |
58 | local command-string = $(command:J=" ") ; | |
59 | if $(command) | |
f67539c2 | 60 | { |
92f5a8d4 TL |
61 | version ?= [ MATCH "version ([0-9]+[.][0-9]+)" |
62 | : [ SHELL "$(command-string) --version" ] ] ; | |
7c673cae FG |
63 | } |
64 | ||
b32b8144 FG |
65 | local condition = [ common.check-init-parameters clang |
66 | : version $(version) ] ; | |
7c673cae FG |
67 | |
68 | common.handle-options clang-darwin : $(condition) : $(command) : $(options) ; | |
11fdf7f2 | 69 | clang.init-cxxstd-flags clang-darwin : $(condition) : $(version) ; |
b32b8144 FG |
70 | |
71 | # - Ranlib. | |
72 | local ranlib = [ feature.get-values <ranlib> : $(options) ] ; | |
73 | toolset.flags clang-darwin.archive .RANLIB $(condition) : $(ranlib[1]) ; | |
7c673cae | 74 | |
b32b8144 FG |
75 | # - Archive builder. |
76 | local archiver = [ feature.get-values <archiver> : $(options) ] ; | |
77 | toolset.flags clang-darwin.archive .AR $(condition) : $(archiver[1]) ; | |
7c673cae FG |
78 | } |
79 | ||
80 | SPACE = " " ; | |
81 | ||
7c673cae FG |
82 | toolset.flags clang-darwin.compile.m OPTIONS <mflags> ; |
83 | toolset.flags clang-darwin.compile.mm OPTIONS <mflags> ; | |
84 | toolset.flags clang-darwin.compile.mm OPTIONS <mmflags> ; | |
7c673cae FG |
85 | |
86 | # Declare flags and action for compilation. | |
7c673cae FG |
87 | |
88 | # For clang, 'on' and 'full' are identical | |
7c673cae FG |
89 | toolset.flags clang-darwin.compile OPTIONS <inlining>full : -Wno-inline ; |
90 | ||
92f5a8d4 | 91 | # SJW 12/2017: Support for <flags> is widely inconsistent. |
11fdf7f2 | 92 | # shouldn't this be handled by the common gcc? |
7c673cae FG |
93 | toolset.flags clang-darwin.compile OPTIONS <flags> ; |
94 | ||
f67539c2 TL |
95 | # LTO |
96 | toolset.flags clang-darwin.compile OPTIONS <lto>on/<lto-mode>thin : -flto=thin ; | |
97 | toolset.flags clang-darwin.link OPTIONS <lto>on/<lto-mode>thin : -flto=thin ; | |
98 | ||
99 | toolset.flags clang-darwin.compile OPTIONS <lto>on/<lto-mode>full : -flto=full ; | |
100 | toolset.flags clang-darwin.link OPTIONS <lto>on/<lto-mode>full : -flto=full ; | |
101 | ||
102 | # stdlib selection | |
103 | toolset.flags clang-darwin.compile OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ; | |
104 | toolset.flags clang-darwin.link OPTIONS <stdlib>gnu <stdlib>gnu11 : -stdlib=libstdc++ ; | |
105 | ||
106 | toolset.flags clang-darwin.compile OPTIONS <stdlib>libc++ : -stdlib=libc++ ; | |
107 | toolset.flags clang-darwin.link OPTIONS <stdlib>libc++ : -stdlib=libc++ ; | |
108 | ||
7c673cae FG |
109 | actions compile.c |
110 | { | |
11fdf7f2 | 111 | "$(CONFIG_COMMAND)" -x c $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
7c673cae FG |
112 | } |
113 | ||
114 | actions compile.c++ | |
115 | { | |
11fdf7f2 | 116 | "$(CONFIG_COMMAND)" -x c++ $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" |
7c673cae FG |
117 | } |
118 | ||
119 | actions compile.m | |
120 | { | |
121 | "$(CONFIG_COMMAND)" -x objective-c $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
122 | } | |
123 | ||
124 | actions compile.mm | |
125 | { | |
126 | "$(CONFIG_COMMAND)" -x objective-c++ $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" | |
127 | } | |
128 | ||
7c673cae FG |
129 | # Default value. Mostly for the sake of clang-linux |
130 | # that inherits from gcc, but does not has the same | |
131 | # logic to set the .AR variable. We can put the same | |
132 | # logic in clang-linux, but that's hardly worth the trouble | |
133 | # as on Linux, 'ar' is always available. | |
134 | .AR = ar ; | |
b32b8144 | 135 | .RANLIB = ranlib -cs ; |
7c673cae FG |
136 | |
137 | rule archive ( targets * : sources * : properties * ) | |
138 | { | |
139 | # Always remove archive and start again. Here's rationale from | |
140 | # Andre Hentz: | |
141 | # | |
f67539c2 TL |
142 | # I had a file, say a1.c, that was included into liba.a. |
143 | # I moved a1.c to a2.c, updated my Jamfiles and rebuilt. | |
144 | # My program was crashing with absurd errors. | |
145 | # After some debugging I traced it back to the fact that a1.o was *still* | |
146 | # in liba.a | |
7c673cae FG |
147 | # |
148 | # Rene Rivera: | |
149 | # | |
150 | # Originally removing the archive was done by splicing an RM | |
151 | # onto the archive action. That makes archives fail to build on NT | |
152 | # when they have many files because it will no longer execute the | |
153 | # action directly and blow the line length limit. Instead we | |
154 | # remove the file in a different action, just before the building | |
155 | # of the archive. | |
156 | # | |
157 | local clean.a = $(targets[1])(clean) ; | |
158 | TEMPORARY $(clean.a) ; | |
159 | NOCARE $(clean.a) ; | |
160 | LOCATE on $(clean.a) = [ on $(targets[1]) return $(LOCATE) ] ; | |
161 | DEPENDS $(clean.a) : $(sources) ; | |
162 | DEPENDS $(targets) : $(clean.a) ; | |
163 | common.RmTemps $(clean.a) : $(targets) ; | |
164 | } | |
165 | ||
166 | actions piecemeal archive | |
167 | { | |
168 | "$(.AR)" $(AROPTIONS) rc "$(<)" "$(>)" | |
b32b8144 | 169 | "$(.RANLIB)" "$(<)" |
7c673cae FG |
170 | } |
171 | ||
7c673cae FG |
172 | # Declare actions for linking |
173 | rule link ( targets * : sources * : properties * ) | |
174 | { | |
175 | SPACE on $(targets) = " " ; | |
176 | # Serialize execution of the 'link' action, since | |
177 | # running N links in parallel is just slower. | |
178 | JAM_SEMAPHORE on $(targets) = <s>clang-darwin-link-semaphore ; | |
179 | } | |
180 | ||
181 | actions link bind LIBRARIES | |
182 | { | |
183 | "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) | |
184 | } | |
185 | ||
186 | actions link.dll bind LIBRARIES | |
187 | { | |
188 | "$(CONFIG_COMMAND)" $(USER_OPTIONS) -L"$(LINKPATH)" -o "$(<)" -single_module -dynamiclib -install_name "@rpath/$(<[1]:D=)" "$(>)" "$(LIBRARIES)" $(START-GROUP) $(FINDLIBS-ST-PFX) -l$(FINDLIBS-ST) $(FINDLIBS-SA-PFX) -l$(FINDLIBS-SA) $(END-GROUP) $(OPTIONS) | |
189 | } |