OLD | NEW |
1 # Copyright (c) 2014 The Native Client Authors. All rights reserved. | 1 # Copyright (c) 2014 The Native Client 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/config/sysroot.gni") | 5 import("//build/config/sysroot.gni") |
6 import("//build/config/nacl/config.gni") | 6 import("//build/config/nacl/config.gni") |
7 import("//build/toolchain/nacl_toolchain.gni") | 7 import("//build/toolchain/nacl_toolchain.gni") |
8 | 8 |
9 # Add the toolchain revision as a preprocessor define so that sources are | 9 # Add the toolchain revision as a preprocessor define so that sources are |
10 # rebuilt when a toolchain is updated. | 10 # rebuilt when a toolchain is updated. |
11 # Idea we could use the toolchain deps feature, but currently that feature is | 11 # Idea we could use the toolchain deps feature, but currently that feature is |
12 # bugged and does not trigger a rebuild. | 12 # bugged and does not trigger a rebuild. |
13 # https://code.google.com/p/chromium/issues/detail?id=431880 | 13 # https://code.google.com/p/chromium/issues/detail?id=431880 |
14 # Calls to get the toolchain revision are relatively slow, so do them all in a | 14 # Calls to get the toolchain revision are relatively slow, so do them all in a |
15 # single batch to amortize python startup, etc. | 15 # single batch to amortize python startup, etc. |
16 revisions = exec_script("//native_client/build/get_toolchain_revision.py", | 16 revisions = exec_script("//native_client/build/get_toolchain_revision.py", |
17 [ | 17 [ |
18 "nacl_x86_glibc", | 18 "nacl_x86_glibc", |
19 "nacl_arm_glibc", | 19 "nacl_arm_glibc", |
20 "pnacl_newlib", | 20 "pnacl_newlib", |
21 ], | 21 ], |
22 "trim list lines") | 22 "trim list lines") |
23 nacl_x86_glibc_rev = revisions[0] | 23 nacl_x86_glibc_rev = revisions[0] |
24 nacl_arm_glibc_rev = revisions[1] | 24 nacl_arm_glibc_rev = revisions[1] |
25 | 25 |
26 # TODO(mcgrathr): Uncomment this when | 26 # TODO(mcgrathr): Uncomment this when |
27 # https://code.google.com/p/chromium/issues/detail?id=555724 is fixed. | 27 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. |
28 #pnacl_newlib_rev = revisions[2] | 28 #pnacl_newlib_rev = revisions[2] |
29 | 29 |
30 template("pnacl_toolchain") { | 30 template("pnacl_toolchain") { |
31 assert(defined(invoker.strip), "Must define strip") | 31 assert(defined(invoker.strip), "Must define strip") |
32 assert(defined(invoker.executable_extension), | 32 assert(defined(invoker.executable_extension), |
33 "Must define executable_extension") | 33 "Must define executable_extension") |
34 | 34 |
35 # TODO(mcgrathr): See above. | 35 # TODO(mcgrathr): See above. |
36 pnacl_newlib_rev = revisions[2] | 36 pnacl_newlib_rev = revisions[2] |
37 | 37 |
38 nacl_toolchain(target_name) { | 38 nacl_toolchain(target_name) { |
39 toolchain_package = "pnacl_newlib" | 39 toolchain_package = "pnacl_newlib" |
40 toolchain_revision = pnacl_newlib_rev | 40 toolchain_revision = pnacl_newlib_rev |
41 toolchain_cpu = "pnacl" | 41 toolchain_cpu = "pnacl" |
42 toolprefix = | 42 toolprefix = |
43 rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/pnacl-", | 43 rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/pnacl-", |
44 root_build_dir) | 44 root_build_dir) |
45 | 45 |
46 is_clang = true | 46 is_clang = true |
47 cc = toolprefix + "clang" | 47 cc = toolprefix + "clang" |
48 cxx = toolprefix + "clang++" | 48 cxx = toolprefix + "clang++" |
49 ar = toolprefix + "ar" | 49 ar = toolprefix + "ar" |
50 ld = cxx | 50 ld = cxx |
| 51 readelf = toolprefix + "readelf" |
| 52 nm = toolprefix + "nm" |
51 strip = toolprefix + invoker.strip | 53 strip = toolprefix + invoker.strip |
52 executable_extension = invoker.executable_extension | 54 executable_extension = invoker.executable_extension |
53 } | 55 } |
54 } | 56 } |
55 | 57 |
56 pnacl_toolchain("newlib_pnacl") { | 58 pnacl_toolchain("newlib_pnacl") { |
57 executable_extension = ".pexe" | 59 executable_extension = ".pexe" |
58 | 60 |
59 # The pnacl-finalize tool turns a .pexe.debug file into a .pexe file. | 61 # The pnacl-finalize tool turns a .pexe.debug file into a .pexe file. |
60 # It's very similar in purpose to the traditional "strip" utility: it | 62 # It's very similar in purpose to the traditional "strip" utility: it |
(...skipping 19 matching lines...) Expand all Loading... |
80 forward_variables_from(invoker, | 82 forward_variables_from(invoker, |
81 [ | 83 [ |
82 "toolchain_package", | 84 "toolchain_package", |
83 "toolchain_revision", | 85 "toolchain_revision", |
84 ]) | 86 ]) |
85 | 87 |
86 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 88 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
87 invoker.toolchain_tuple + "-", | 89 invoker.toolchain_tuple + "-", |
88 root_build_dir) | 90 root_build_dir) |
89 | 91 |
| 92 # TODO(mcgrathr): Hoist this to top level when |
| 93 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. |
| 94 if (host_os == "win") { |
| 95 toolsuffix = ".exe" |
| 96 } else { |
| 97 toolsuffix = "" |
| 98 } |
| 99 |
90 nacl_toolchain("glibc_" + toolchain_cpu) { | 100 nacl_toolchain("glibc_" + toolchain_cpu) { |
91 is_clang = false | 101 is_clang = false |
92 is_nacl_glibc = true | 102 is_nacl_glibc = true |
93 | 103 |
94 cc = toolprefix + "gcc" | 104 cc = toolprefix + "gcc" + toolsuffix |
95 cxx = toolprefix + "g++" | 105 cxx = toolprefix + "g++" + toolsuffix |
96 ar = toolprefix + "ar" | 106 ar = toolprefix + "ar" + toolsuffix |
97 ld = cxx | 107 ld = cxx |
| 108 readelf = toolprefix + "readelf" + toolsuffix |
| 109 nm = toolprefix + "nm" + toolsuffix |
| 110 strip = toolprefix + "strip" + toolsuffix |
98 } | 111 } |
99 } | 112 } |
100 | 113 |
101 nacl_glibc_toolchain("x86") { | 114 nacl_glibc_toolchain("x86") { |
102 toolchain_package = "nacl_x86_glibc" | 115 toolchain_package = "nacl_x86_glibc" |
103 toolchain_revision = nacl_x86_glibc_rev | 116 toolchain_revision = nacl_x86_glibc_rev |
104 toolchain_tuple = "i686-nacl" | 117 toolchain_tuple = "i686-nacl" |
105 } | 118 } |
106 | 119 |
107 nacl_glibc_toolchain("x64") { | 120 nacl_glibc_toolchain("x64") { |
(...skipping 14 matching lines...) Expand all Loading... |
122 | 135 |
123 # TODO(mcgrathr): See above. | 136 # TODO(mcgrathr): See above. |
124 pnacl_newlib_rev = revisions[2] | 137 pnacl_newlib_rev = revisions[2] |
125 | 138 |
126 toolchain_package = "pnacl_newlib" | 139 toolchain_package = "pnacl_newlib" |
127 toolchain_revision = pnacl_newlib_rev | 140 toolchain_revision = pnacl_newlib_rev |
128 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 141 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
129 invoker.toolchain_tuple + "-", | 142 invoker.toolchain_tuple + "-", |
130 root_build_dir) | 143 root_build_dir) |
131 | 144 |
| 145 # TODO(mcgrathr): Hoist this to top level when |
| 146 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. |
| 147 if (host_os == "win") { |
| 148 toolsuffix = ".exe" |
| 149 } else { |
| 150 toolsuffix = "" |
| 151 } |
| 152 |
132 nacl_toolchain("clang_newlib_" + toolchain_cpu) { | 153 nacl_toolchain("clang_newlib_" + toolchain_cpu) { |
133 is_clang = true | 154 is_clang = true |
134 cc = toolprefix + "clang" | 155 cc = toolprefix + "clang" + toolsuffix |
135 cxx = toolprefix + "clang++" | 156 cxx = toolprefix + "clang++" + toolsuffix |
136 ar = toolprefix + "ar" | 157 ar = toolprefix + "ar" + toolsuffix |
137 ld = cxx | 158 ld = cxx |
| 159 readelf = toolprefix + "readelf" + toolsuffix |
| 160 nm = toolprefix + "nm" + toolsuffix |
| 161 strip = toolprefix + "strip" + toolsuffix |
138 } | 162 } |
139 } | 163 } |
140 | 164 |
141 template("nacl_irt_toolchain") { | 165 template("nacl_irt_toolchain") { |
142 toolchain_cpu = target_name | 166 toolchain_cpu = target_name |
143 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") | 167 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") |
144 | 168 |
145 # TODO(mcgrathr): See above. | 169 # TODO(mcgrathr): See above. |
146 pnacl_newlib_rev = revisions[2] | 170 pnacl_newlib_rev = revisions[2] |
147 | 171 |
148 toolchain_package = "pnacl_newlib" | 172 toolchain_package = "pnacl_newlib" |
149 toolchain_revision = pnacl_newlib_rev | 173 toolchain_revision = pnacl_newlib_rev |
150 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + | 174 toolprefix = rebase_path("${nacl_toolchain_dir}/${toolchain_package}/bin/" + |
151 invoker.toolchain_tuple + "-", | 175 invoker.toolchain_tuple + "-", |
152 root_build_dir) | 176 root_build_dir) |
153 | 177 |
| 178 # TODO(mcgrathr): Hoist this to top level when |
| 179 # https://code.google.com/p/chromium/issues/detail?id=395883 is fixed. |
| 180 if (host_os == "win") { |
| 181 toolsuffix = ".exe" |
| 182 } else { |
| 183 toolsuffix = "" |
| 184 } |
| 185 |
154 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir) | 186 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir) |
155 | 187 |
156 tls_edit_label = | 188 tls_edit_label = |
157 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)" | 189 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)" |
158 host_toolchain_out_dir = | 190 host_toolchain_out_dir = |
159 rebase_path(get_label_info(tls_edit_label, "root_out_dir"), | 191 rebase_path(get_label_info(tls_edit_label, "root_out_dir"), |
160 root_build_dir) | 192 root_build_dir) |
161 tls_edit = "${host_toolchain_out_dir}/tls_edit" | 193 tls_edit = "${host_toolchain_out_dir}/tls_edit" |
162 | 194 |
163 nacl_toolchain("irt_" + toolchain_cpu) { | 195 nacl_toolchain("irt_" + toolchain_cpu) { |
164 is_clang = true | 196 is_clang = true |
165 cc = toolprefix + "clang" | 197 cc = toolprefix + "clang" + toolsuffix |
166 cxx = toolprefix + "clang++" | 198 cxx = toolprefix + "clang++" + toolsuffix |
167 ar = toolprefix + "ar" | 199 ar = toolprefix + "ar" + toolsuffix |
168 readelf = toolprefix + "readelf" | 200 readelf = toolprefix + "readelf" + toolsuffix |
169 strip = toolprefix + "strip" | 201 nm = toolprefix + "nm" + toolsuffix |
| 202 strip = toolprefix + "strip" + toolsuffix |
170 | 203 |
171 # Always build the IRT with full debugging symbols, regardless of | 204 # Always build the IRT with full debugging symbols, regardless of |
172 # how Chromium itself is being built (or other NaCl executables). | 205 # how Chromium itself is being built (or other NaCl executables). |
173 symbol_level = 2 | 206 symbol_level = 2 |
174 | 207 |
175 # Some IRT implementations (notably, Chromium's) contain C++ code, | 208 # Some IRT implementations (notably, Chromium's) contain C++ code, |
176 # so we need to link w/ the C++ linker. | 209 # so we need to link w/ the C++ linker. |
177 ld = "${python_path} ${link_irt} --tls-edit=${tls_edit} --link-cmd=${cxx} --
readelf-cmd=${readelf}" | 210 ld = "${python_path} ${link_irt} --tls-edit=${tls_edit} --link-cmd=${cxx} --
readelf-cmd=${readelf}" |
178 | 211 |
179 # TODO(ncbray): depend on link script | 212 # TODO(ncbray): depend on link script |
(...skipping 17 matching lines...) Expand all Loading... |
197 toolchain_tuple = "i686-nacl" | 230 toolchain_tuple = "i686-nacl" |
198 } | 231 } |
199 | 232 |
200 nacl_clang_toolchains("x64") { | 233 nacl_clang_toolchains("x64") { |
201 toolchain_tuple = "x86_64-nacl" | 234 toolchain_tuple = "x86_64-nacl" |
202 } | 235 } |
203 | 236 |
204 nacl_clang_toolchains("arm") { | 237 nacl_clang_toolchains("arm") { |
205 toolchain_tuple = "arm-nacl" | 238 toolchain_tuple = "arm-nacl" |
206 } | 239 } |
OLD | NEW |