Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 1322523008: Modify the gcc_toolchain definitions in GN for NaCl compatibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@linux_cleanup
Patch Set: add comments for link_outputs, post_link, and is_component_build Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/config/BUILDCONFIG.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import("//build/toolchain/toolchain.gni") 5 import("//build/toolchain/toolchain.gni")
6 6
7 # This value will be inherited in the toolchain below. 7 # This value will be inherited in the toolchain below.
8 concurrent_links = exec_script("get_concurrent_links.py", [], "value") 8 concurrent_links = exec_script("get_concurrent_links.py", [], "value")
9 9
10 # This template defines a toolchain for something that works like gcc 10 # This template defines a toolchain for something that works like gcc
(...skipping 12 matching lines...) Expand all
23 # 23 #
24 # Optional parameters: 24 # Optional parameters:
25 # - libs_section_prefix 25 # - libs_section_prefix
26 # - libs_section_postfix 26 # - libs_section_postfix
27 # The contents of these strings, if specified, will be placed around 27 # The contents of these strings, if specified, will be placed around
28 # the libs section of the linker line. It allows one to inject libraries 28 # the libs section of the linker line. It allows one to inject libraries
29 # at the beginning and end for all targets in a toolchain. 29 # at the beginning and end for all targets in a toolchain.
30 # - solink_libs_section_prefix 30 # - solink_libs_section_prefix
31 # - solink_libs_section_postfix 31 # - solink_libs_section_postfix
32 # Same as libs_section_{pre,post}fix except used for solink instead of link . 32 # Same as libs_section_{pre,post}fix except used for solink instead of link .
33 # - link_outputs
34 # The content of this array, if specified, will be added to the list of
35 # outputs from the link command. This can be useful in conjunction with
36 # the post_link parameter.
37 # - post_link
38 # The content of this string, if specified, will be appended to the link
39 # command.
Roland McGrath 2015/08/28 19:59:37 This sounds like it's for arguments to be added to
Dirk Pranke 2015/08/28 20:05:33 That makes sense. I will fix it.
33 # - post_solink 40 # - post_solink
34 # The content of this string, if specified, will be appended to the solink 41 # The content of this string, if specified, will be appended to the solink
35 # command. 42 # command.
Dirk Pranke 2015/08/28 20:45:30 turns out post_solink isn't actually implemented o
36 # - deps 43 # - deps
37 # Just forwarded to the toolchain definition. 44 # Just forwarded to the toolchain definition.
45 # - executable_extension
46 # If this string is specified it will be used for the file extension
47 # for an executable, rather than using no extension; targets will
48 # still be able to override the extension using the output_extension
49 # variable.
38 # - is_clang 50 # - is_clang
39 # Whether to use clang instead of gcc. 51 # Whether to use clang instead of gcc.
52 # - is_component_build
53 # Whether to forceably enable or disable component builds for this
Roland McGrath 2015/08/28 19:59:37 "forcibly"
Dirk Pranke 2015/08/28 20:05:33 Acknowledged.
54 # toolchain; if not specified, the toolchain will inherit the
55 # default setting.
56 # - rebuild_define
57 # The contents of this string, if specified, will be passed as a #define
58 # to the toolchain. It can be used to force recompiles whenever a
59 # toolchain is updated.
60 # - shlib_extension
61 # If this string is specified it will be used for the file extension
62 # for a shared library, rather than default value specified in
63 # toolchain.gni
40 # - strip 64 # - strip
41 # Location of the strip executable. When specified, strip will be run on 65 # Location of the strip executable. When specified, strip will be run on
42 # all shared libraries and executables as they are built. The pre-stripped 66 # all shared libraries and executables as they are built. The pre-stripped
43 # artifacts will be put in lib.stripped/ and exe.stripped/. 67 # artifacts will be put in lib.stripped/ and exe.stripped/.
44 template("gcc_toolchain") { 68 template("gcc_toolchain") {
45 toolchain(target_name) { 69 toolchain(target_name) {
46 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") 70 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
47 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") 71 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
48 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") 72 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
49 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") 73 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
50 assert(defined(invoker.toolchain_cpu), 74 assert(defined(invoker.toolchain_cpu),
51 "gcc_toolchain() must specify a \"toolchain_cpu\"") 75 "gcc_toolchain() must specify a \"toolchain_cpu\"")
52 assert(defined(invoker.toolchain_os), 76 assert(defined(invoker.toolchain_os),
53 "gcc_toolchain() must specify a \"toolchain_os\"") 77 "gcc_toolchain() must specify a \"toolchain_os\"")
54 78
79 # This define changes when the toolchain changes, forcing a rebuild.
80 # Nothing should ever use this define.
81 if (defined(invoker.rebuild_define)) {
82 rebuild_string = "-D" + invoker.rebuild_define + " "
83 } else {
84 rebuild_string = ""
85 }
86
55 # We can't do string interpolation ($ in strings) on things with dots in 87 # We can't do string interpolation ($ in strings) on things with dots in
56 # them. To allow us to use $cc below, for example, we create copies of 88 # them. To allow us to use $cc below, for example, we create copies of
57 # these values in our scope. 89 # these values in our scope.
58 cc = invoker.cc 90 cc = invoker.cc
59 cxx = invoker.cxx 91 cxx = invoker.cxx
60 ar = invoker.ar 92 ar = invoker.ar
61 ld = invoker.ld 93 ld = invoker.ld
62 if (defined(invoker.readelf)) { 94 if (defined(invoker.readelf)) {
63 readelf = invoker.readelf 95 readelf = invoker.readelf
64 } else { 96 } else {
65 readelf = "readelf" 97 readelf = "readelf"
66 } 98 }
67 if (defined(invoker.nm)) { 99 if (defined(invoker.nm)) {
68 nm = invoker.nm 100 nm = invoker.nm
69 } else { 101 } else {
70 nm = "nm" 102 nm = "nm"
71 } 103 }
72 104
105 if (defined(invoker.shlib_extension)) {
106 default_shlib_extension = invoker.shlib_extension
107 } else {
108 default_shlib_extension = shlib_extension
109 }
110
111 if (defined(invoker.executable_extension)) {
112 default_executable_extension = invoker.executable_extension
113 } else {
114 default_executable_extension = ""
115 }
116
73 # Bring these into our scope for string interpolation with default values. 117 # Bring these into our scope for string interpolation with default values.
74 if (defined(invoker.libs_section_prefix)) { 118 if (defined(invoker.libs_section_prefix)) {
75 libs_section_prefix = invoker.libs_section_prefix 119 libs_section_prefix = invoker.libs_section_prefix
76 } else { 120 } else {
77 libs_section_prefix = "" 121 libs_section_prefix = ""
78 } 122 }
79 123
80 if (defined(invoker.libs_section_postfix)) { 124 if (defined(invoker.libs_section_postfix)) {
81 libs_section_postfix = invoker.libs_section_postfix 125 libs_section_postfix = invoker.libs_section_postfix
82 } else { 126 } else {
(...skipping 11 matching lines...) Expand all
94 } else { 138 } else {
95 solink_libs_section_postfix = "" 139 solink_libs_section_postfix = ""
96 } 140 }
97 141
98 # These library switches can apply to all tools below. 142 # These library switches can apply to all tools below.
99 lib_switch = "-l" 143 lib_switch = "-l"
100 lib_dir_switch = "-L" 144 lib_dir_switch = "-L"
101 145
102 tool("cc") { 146 tool("cc") {
103 depfile = "{{output}}.d" 147 depfile = "{{output}}.d"
104 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" 148 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
105 depsformat = "gcc" 149 depsformat = "gcc"
106 description = "CC {{output}}" 150 description = "CC {{output}}"
107 outputs = [ 151 outputs = [
108 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", 152 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
109 ] 153 ]
110 } 154 }
111 155
112 tool("cxx") { 156 tool("cxx") {
113 depfile = "{{output}}.d" 157 depfile = "{{output}}.d"
114 command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}" 158 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
115 depsformat = "gcc" 159 depsformat = "gcc"
116 description = "CXX {{output}}" 160 description = "CXX {{output}}"
117 outputs = [ 161 outputs = [
118 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", 162 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
119 ] 163 ]
120 } 164 }
121 165
122 tool("asm") { 166 tool("asm") {
123 # For GCC we can just use the C compiler to compile assembly. 167 # For GCC we can just use the C compiler to compile assembly.
124 depfile = "{{output}}.d" 168 depfile = "{{output}}.d"
125 command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} { {cflags_c}} -c {{source}} -o {{output}}" 169 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
126 depsformat = "gcc" 170 depsformat = "gcc"
127 description = "ASM {{output}}" 171 description = "ASM {{output}}"
128 outputs = [ 172 outputs = [
129 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o", 173 "{{target_out_dir}}/{{target_output_name}}/{{source_name_part}}.o",
130 ] 174 ]
131 } 175 }
132 176
133 tool("alink") { 177 tool("alink") {
134 rspfile = "{{output}}.rsp" 178 rspfile = "{{output}}.rsp"
135 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile" 179 command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 "${invoker.strip} --strip-unneeded -o $sofile $unstripped_sofile" 218 "${invoker.strip} --strip-unneeded -o $sofile $unstripped_sofile"
175 command += " && " + strip_command 219 command += " && " + strip_command
176 } 220 }
177 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" 221 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
178 222
179 description = "SOLINK $sofile" 223 description = "SOLINK $sofile"
180 224
181 # Use this for {{output_extension}} expansions unless a target manually 225 # Use this for {{output_extension}} expansions unless a target manually
182 # overrides it (in which case {{output_extension}} will be what the target 226 # overrides it (in which case {{output_extension}} will be what the target
183 # specifies). 227 # specifies).
184 default_output_extension = shlib_extension 228 default_output_extension = default_shlib_extension
185 if (defined(invoker.default_output_extension)) {
186 default_output_extension = invoker.default_output_extension
187 }
188 229
189 output_prefix = "lib" 230 output_prefix = "lib"
190 231
191 # Since the above commands only updates the .TOC file when it changes, ask 232 # Since the above commands only updates the .TOC file when it changes, ask
192 # Ninja to check if the timestamp actually changed to know if downstream 233 # Ninja to check if the timestamp actually changed to know if downstream
193 # dependencies should be recompiled. 234 # dependencies should be recompiled.
194 restat = true 235 restat = true
195 236
196 # Tell GN about the output files. It will link to the sofile but use the 237 # Tell GN about the output files. It will link to the sofile but use the
197 # tocfile for dependency management. 238 # tocfile for dependency management.
198 outputs = [ 239 outputs = [
199 sofile, 240 sofile,
200 tocfile, 241 tocfile,
201 ] 242 ]
202 if (sofile != unstripped_sofile) { 243 if (sofile != unstripped_sofile) {
203 outputs += [ unstripped_sofile ] 244 outputs += [ unstripped_sofile ]
204 } 245 }
205 link_output = sofile 246 link_output = sofile
206 depend_output = tocfile 247 depend_output = tocfile
207 } 248 }
208 249
209 tool("link") { 250 tool("link") {
210 exename = "{{target_output_name}}{{output_extension}}" 251 exename = "{{target_output_name}}{{output_extension}}"
211 outfile = "{{root_out_dir}}/$exename" 252 outfile = "{{root_out_dir}}/$exename"
212 rspfile = "$outfile.rsp" 253 rspfile = "$outfile.rsp"
213 unstripped_outfile = outfile 254 unstripped_outfile = outfile
255
256 # Use this for {{output_extension}} expansions unless a target manually
257 # overrides it (in which case {{output_extension}} will be what the target
258 # specifies).
259 default_output_extension = default_executable_extension
260
214 if (defined(invoker.strip)) { 261 if (defined(invoker.strip)) {
215 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename" 262 unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
216 } 263 }
217 264
218 command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspf ile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postf ix" 265 command = "$ld {{ldflags}} -o $unstripped_outfile -Wl,--start-group @$rspf ile {{solibs}} -Wl,--end-group $libs_section_prefix {{libs}} $libs_section_postf ix"
219 if (defined(invoker.strip)) { 266 if (defined(invoker.strip)) {
220 strip_command = 267 strip_command =
221 "${invoker.strip} --strip-unneeded -o $outfile $unstripped_outfile" 268 "${invoker.strip} --strip-unneeded -o $outfile $unstripped_outfile"
222 command += " && " + strip_command 269 command += " && " + strip_command
223 } 270 }
271 if (defined(invoker.postlink)) {
272 command += " && " + invoker.postlink
273 }
224 description = "LINK $outfile" 274 description = "LINK $outfile"
225 rspfile_content = "{{inputs}}" 275 rspfile_content = "{{inputs}}"
226 outputs = [ 276 outputs = [
227 outfile, 277 outfile,
228 ] 278 ]
229 if (outfile != unstripped_outfile) { 279 if (outfile != unstripped_outfile) {
230 outputs += [ unstripped_outfile ] 280 outputs += [ unstripped_outfile ]
231 } 281 }
282 if (defined(invoker.link_outputs)) {
283 outputs += invoker.link_outputs
284 }
232 } 285 }
233 286
234 tool("stamp") { 287 tool("stamp") {
235 command = "touch {{output}}" 288 command = "touch {{output}}"
236 description = "STAMP {{output}}" 289 description = "STAMP {{output}}"
237 } 290 }
238 291
239 tool("copy") { 292 tool("copy") {
240 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} & & cp -af {{source}} {{output}})" 293 command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} & & cp -af {{source}} {{output}})"
241 description = "COPY {{source}} {{output}}" 294 description = "COPY {{source}} {{output}}"
242 } 295 }
243 296
244 # When invoking this toolchain not as the default one, these args will be 297 # When invoking this toolchain not as the default one, these args will be
245 # passed to the build. They are ignored when this is the default toolchain. 298 # passed to the build. They are ignored when this is the default toolchain.
246 toolchain_args() { 299 toolchain_args() {
247 current_cpu = invoker.toolchain_cpu 300 current_cpu = invoker.toolchain_cpu
248 current_os = invoker.toolchain_os 301 current_os = invoker.toolchain_os
249 302
250 # These values need to be passed through unchanged. 303 # These values need to be passed through unchanged.
251 target_os = target_os 304 target_os = target_os
252 target_cpu = target_cpu 305 target_cpu = target_cpu
253 306
254 if (defined(invoker.is_clang)) { 307 if (defined(invoker.is_clang)) {
255 is_clang = invoker.is_clang 308 is_clang = invoker.is_clang
256 } 309 }
310 if (defined(invoker.is_component_build)) {
311 is_component_build = invoker.is_component_build
312 }
257 } 313 }
258 314
259 if (defined(invoker.deps)) { 315 if (defined(invoker.deps)) {
260 deps = invoker.deps 316 deps = invoker.deps
261 } 317 }
262 } 318 }
263 } 319 }
OLDNEW
« no previous file with comments | « build/config/BUILDCONFIG.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698