OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires | 5 # TODO(brettw) Use "gcc_toolchain.gni" like the Linux toolchains. This requires |
6 # some enhancements since the commands on Mac are slightly different than on | 6 # some enhancements since the commands on Mac are slightly different than on |
7 # Linux. | 7 # Linux. |
8 | 8 |
9 import("../goma.gni") | 9 import("../goma.gni") |
10 import("//build/config/ios/ios_sdk.gni") | 10 import("//build/config/ios/ios_sdk.gni") |
(...skipping 28 matching lines...) Expand all Loading... |
39 assert(defined(invoker.toolchain_os), | 39 assert(defined(invoker.toolchain_os), |
40 "mac_toolchain() must specify a \"toolchain_os\"") | 40 "mac_toolchain() must specify a \"toolchain_os\"") |
41 | 41 |
42 # We can't do string interpolation ($ in strings) on things with dots in | 42 # We can't do string interpolation ($ in strings) on things with dots in |
43 # them. To allow us to use $cc below, for example, we create copies of | 43 # them. To allow us to use $cc below, for example, we create copies of |
44 # these values in our scope. | 44 # these values in our scope. |
45 cc = invoker.cc | 45 cc = invoker.cc |
46 cxx = invoker.cxx | 46 cxx = invoker.cxx |
47 ld = invoker.ld | 47 ld = invoker.ld |
48 | 48 |
| 49 linker_driver = |
| 50 rebase_path("//build/toolchain/mac/linker_driver.py", root_build_dir) |
| 51 |
49 # Make these apply to all tools below. | 52 # Make these apply to all tools below. |
50 lib_switch = "-l" | 53 lib_switch = "-l" |
51 lib_dir_switch = "-L" | 54 lib_dir_switch = "-L" |
52 | 55 |
53 # Object files go in this directory. Use label_name instead of | 56 # Object files go in this directory. Use label_name instead of |
54 # target_output_name since labels will generally have no spaces and will be | 57 # target_output_name since labels will generally have no spaces and will be |
55 # unique in the directory. | 58 # unique in the directory. |
56 object_subdir = "{{target_out_dir}}/{{label_name}}" | 59 object_subdir = "{{target_out_dir}}/{{label_name}}" |
57 | 60 |
58 tool("cc") { | 61 tool("cc") { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 # the existing .TOC file, overwrite it, otherwise, don't change it. | 134 # the existing .TOC file, overwrite it, otherwise, don't change it. |
132 # | 135 # |
133 # As a special case, if the library reexports symbols from other dynamic | 136 # As a special case, if the library reexports symbols from other dynamic |
134 # libraries, we always update the .TOC and skip the temporary file and | 137 # libraries, we always update the .TOC and skip the temporary file and |
135 # diffing steps, since that library always needs to be re-linked. | 138 # diffing steps, since that library always needs to be re-linked. |
136 tocname = dylib + ".TOC" | 139 tocname = dylib + ".TOC" |
137 temporary_tocname = dylib + ".tmp" | 140 temporary_tocname = dylib + ".tmp" |
138 | 141 |
139 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool
-l \"$dylib\" | grep -q LC_REEXPORT_DYLIB" | 142 does_reexport_command = "[ ! -e \"$dylib\" -o ! -e \"$tocname\" ] || otool
-l \"$dylib\" | grep -q LC_REEXPORT_DYLIB" |
140 | 143 |
141 link_command = "$ld -shared " | 144 link_command = "$linker_driver $ld -shared " |
142 if (is_component_build) { | 145 if (is_component_build) { |
143 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out
put_extension}}\" " | 146 link_command += " -Wl,-install_name,@rpath/\"{{target_output_name}}{{out
put_extension}}\" " |
144 } | 147 } |
145 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li
bs}} {{solibs}}" | 148 link_command += "{{ldflags}} -o \"$dylib\" -Wl,-filelist,\"$rspfile\" {{li
bs}} {{solibs}}" |
146 | 149 |
147 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m
v \"$temporary_tocname\" \"$tocname\"" | 150 replace_command = "if ! cmp -s \"$temporary_tocname\" \"$tocname\"; then m
v \"$temporary_tocname\" \"$tocname\"" |
148 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm -
gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" | 151 extract_toc_command = "{ otool -l \"$dylib\" | grep LC_ID_DYLIB -A 5; nm -
gP \"$dylib\" | cut -f1-2 -d' ' | grep -v U\$\$; true; }" |
149 | 152 |
150 command = "if $does_reexport_command ; then $link_command && $extract_toc_
command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporar
y_tocname\" && $replace_command ; fi; fi" | 153 command = "if $does_reexport_command ; then $link_command && $extract_toc_
command > \"$tocname\"; else $link_command && $extract_toc_command > \"$temporar
y_tocname\" && $replace_command ; fi; fi" |
151 | 154 |
(...skipping 21 matching lines...) Expand all Loading... |
173 tocname, | 176 tocname, |
174 ] | 177 ] |
175 link_output = dylib | 178 link_output = dylib |
176 depend_output = tocname | 179 depend_output = tocname |
177 } | 180 } |
178 | 181 |
179 tool("solink_module") { | 182 tool("solink_module") { |
180 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg
"./libfoo.so" | 183 sofile = "{{output_dir}}/{{target_output_name}}{{output_extension}}" # eg
"./libfoo.so" |
181 rspfile = sofile + ".rsp" | 184 rspfile = sofile + ".rsp" |
182 | 185 |
183 link_command = | 186 link_command = "$linker_driver $ld -bundle {{ldflags}} -o \"$sofile\" -Wl,
-filelist,\"$rspfile\"" |
184 "$ld -bundle {{ldflags}} -o \"$sofile\" -Wl,-filelist,\"$rspfile\"" | |
185 if (is_component_build) { | 187 if (is_component_build) { |
186 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu
t_extension}}" | 188 link_command += " -Wl,-install_name,@rpath/{{target_output_name}}{{outpu
t_extension}}" |
187 } | 189 } |
188 link_command += " {{solibs}} {{libs}}" | 190 link_command += " {{solibs}} {{libs}}" |
189 command = link_command | 191 command = link_command |
190 | 192 |
191 rspfile_content = "{{inputs_newline}}" | 193 rspfile_content = "{{inputs_newline}}" |
192 | 194 |
193 description = "SOLINK_MODULE {{output}}" | 195 description = "SOLINK_MODULE {{output}}" |
194 | 196 |
(...skipping 13 matching lines...) Expand all Loading... |
208 rspfile = "$outfile.rsp" | 210 rspfile = "$outfile.rsp" |
209 | 211 |
210 # Note about --filelist: Apple's linker reads the file list file and | 212 # Note about --filelist: Apple's linker reads the file list file and |
211 # interprets each newline-separated chunk of text as a file name. It | 213 # interprets each newline-separated chunk of text as a file name. It |
212 # doesn't do the things one would expect from the shell like unescaping | 214 # doesn't do the things one would expect from the shell like unescaping |
213 # or handling quotes. In contrast, when Ninja finds a file name with | 215 # or handling quotes. In contrast, when Ninja finds a file name with |
214 # spaces, it single-quotes them in $inputs_newline as it would normally | 216 # spaces, it single-quotes them in $inputs_newline as it would normally |
215 # do for command-line arguments. Thus any source names with spaces, or | 217 # do for command-line arguments. Thus any source names with spaces, or |
216 # label names with spaces (which GN bases the output paths on) will be | 218 # label names with spaces (which GN bases the output paths on) will be |
217 # corrupted by this process. Don't use spaces for source files or labels. | 219 # corrupted by this process. Don't use spaces for source files or labels. |
218 command = "$ld {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"$rspfile\" {{so
libs}} {{libs}}" | 220 command = "$linker_driver $ld {{ldflags}} -o \"$outfile\" -Wl,-filelist,\"
$rspfile\" {{solibs}} {{libs}}" |
219 description = "LINK $outfile" | 221 description = "LINK $outfile" |
220 rspfile_content = "{{inputs_newline}}" | 222 rspfile_content = "{{inputs_newline}}" |
221 outputs = [ | 223 outputs = [ |
222 outfile, | 224 outfile, |
223 ] | 225 ] |
224 | 226 |
225 default_output_dir = "{{root_out_dir}}" | 227 default_output_dir = "{{root_out_dir}}" |
226 } | 228 } |
227 | 229 |
228 # These two are really entirely generic, but have to be repeated in | 230 # These two are really entirely generic, but have to be repeated in |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 358 } |
357 | 359 |
358 mac_toolchain("x64") { | 360 mac_toolchain("x64") { |
359 toolchain_cpu = "x64" | 361 toolchain_cpu = "x64" |
360 toolchain_os = "mac" | 362 toolchain_os = "mac" |
361 cc = "${goma_prefix}/gcc" | 363 cc = "${goma_prefix}/gcc" |
362 cxx = "${goma_prefix}/g++" | 364 cxx = "${goma_prefix}/g++" |
363 ld = cxx | 365 ld = cxx |
364 is_clang = false | 366 is_clang = false |
365 } | 367 } |
OLD | NEW |