OLD | NEW |
1 # Copyright (c) 2013 The Chromium 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 toolchain("x86_newlib") { | 5 import("//build/config/sysroot.gni") |
6 toolprefix = "gen/sdk/toolchain/linux_x86_newlib/bin/x86_64-nacl-" | 6 import("//build/toolchain/nacl_toolchain.gni") |
| 7 |
| 8 nacl_toolchain_dir = rebase_path("//native_client/toolchain", root_build_dir) |
| 9 os_toolchain_dir = "${nacl_toolchain_dir}/${current_os}_x86" |
| 10 |
| 11 # Add the toolchain revision as a preprocessor define so that sources are |
| 12 # rebuilt when a toolchain is updated. |
| 13 # Idea we could use the toolchain deps feature, but currently that feature is |
| 14 # bugged and does not trigger a rebuild. |
| 15 # https://code.google.com/p/chromium/issues/detail?id=431880 |
| 16 # Calls to get the toolchain revision are relatively slow, so do them all in a |
| 17 # single batch to amortize python startup, etc. |
| 18 revisions = exec_script("//native_client/build/get_toolchain_revision.py", |
| 19 [ |
| 20 "nacl_arm_newlib", |
| 21 "nacl_x86_newlib", |
| 22 "nacl_x86_glibc", |
| 23 "pnacl_newlib", |
| 24 ], |
| 25 "trim list lines") |
| 26 nacl_arm_newlib_rev = revisions[0] |
| 27 nacl_x86_newlib_rev = revisions[1] |
| 28 nacl_x86_glibc_rev = revisions[2] |
| 29 pnacl_newlib_rev = revisions[3] |
| 30 |
| 31 nacl_toolchain("newlib_arm") { |
| 32 toolchain_package = "nacl_arm_newlib" |
| 33 toolchain_revision = nacl_arm_newlib_rev |
| 34 toolchain_cpu = "arm" |
| 35 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/arm-nacl-" |
| 36 is_clang = false |
| 37 |
7 cc = toolprefix + "gcc" | 38 cc = toolprefix + "gcc" |
8 cxx = toolprefix + "g++" | 39 cxx = toolprefix + "g++" |
9 ld = toolprefix + "g++" | 40 ar = toolprefix + "ar" |
| 41 ld = cxx |
| 42 } |
10 | 43 |
11 tool("cc") { | 44 nacl_toolchain("newlib_x86") { |
12 command = "$cc -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_c -c
\$in -o \$out" | 45 toolchain_package = "nacl_x86_newlib" |
13 description = "CC(NaCl x86 Newlib) \$out" | 46 toolchain_revision = nacl_x86_newlib_rev |
14 depfile = "\$out.d" | 47 toolchain_cpu = "x86" |
15 depsformat = "gcc" | 48 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-" |
16 } | 49 is_clang = false |
17 tool("cxx") { | |
18 # cflags_pch_cc | |
19 command = "$cxx -MMD -MF \$out.d \$defines \$includes \$cflags \$cflags_cc -
c \$in -o \$out" | |
20 description = "CXX(NaCl x86 Newlib) \$out" | |
21 depfile = "\$out.d" | |
22 depsformat = "gcc" | |
23 } | |
24 tool("alink") { | |
25 command = "rm -f \$out && ${toolprefix}ar rcs \$out \$in" | |
26 description = "AR(NaCl x86 Newlib) \$out" | |
27 } | |
28 tool("solink") { | |
29 command = "if [ ! -e \$lib -o ! -e \${lib}.TOC ]; then $ld -shared \$ldflags
-o \$lib -Wl,-soname=\$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-
archive \$libs && { readelf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut
-f1-2 -d' '; } > \${lib}.TOC; else $ld -shared \$ldflags -o \$lib -Wl,-soname=\
$soname -Wl,--whole-archive \$in \$solibs -Wl,--no-whole-archive \$libs && { rea
delf -d \${lib} | grep SONAME ; nm -gD -f p \${lib} | cut -f1-2 -d' '; } > \${li
b}.tmp && if ! cmp -s \${lib}.tmp \${lib}.TOC; then mv \${lib}.tmp \${lib}.TOC ;
fi; fi" | |
30 description = "SOLINK(NaCl x86 Newlib) \$lib" | |
31 | 50 |
32 #pool = "link_pool" | 51 cc = toolprefix + "gcc" |
33 restat = "1" | 52 cxx = toolprefix + "g++" |
34 } | 53 ar = toolprefix + "ar" |
35 tool("link") { | 54 ld = cxx |
36 command = "$ld \$ldflags -o \$out -Wl,--start-group \$in \$solibs -Wl,--end-
group \$libs" | 55 } |
37 description = "LINK(NaCl x86 Newlib) \$out" | |
38 | 56 |
39 #pool = "link_pool" | 57 nacl_toolchain("newlib_x64") { |
40 } | 58 toolchain_package = "nacl_x86_newlib" |
| 59 toolchain_revision = nacl_x86_newlib_rev |
| 60 toolchain_cpu = "x64" |
| 61 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-" |
| 62 is_clang = false |
41 | 63 |
42 if (is_win) { | 64 cc = toolprefix + "gcc" |
43 tool("stamp") { | 65 cxx = toolprefix + "g++" |
44 command = "$python_path gyp-win-tool stamp \$out" | 66 ar = toolprefix + "ar" |
45 description = "STAMP \$out" | 67 ld = cxx |
46 } | 68 } |
47 } else { | |
48 tool("stamp") { | |
49 command = "touch \$out" | |
50 description = "STAMP \$out" | |
51 } | |
52 } | |
53 | 69 |
54 toolchain_args() { | 70 nacl_toolchain("newlib_pnacl") { |
55 # Override the default OS detection. The build config will set the is_* | 71 toolchain_package = "pnacl_newlib" |
56 # flags accordingly. | 72 toolchain_revision = pnacl_newlib_rev |
57 current_os = "nacl" | 73 toolchain_cpu = "pnacl" |
| 74 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/pnacl-" |
58 | 75 |
59 # Component build not supported in NaCl, since it does not support shared | 76 cc = toolprefix + "clang" |
60 # libraries. | 77 cxx = toolprefix + "clang++" |
61 is_component_build = false | 78 ar = toolprefix + "ar" |
| 79 ld = cxx |
| 80 executable_extension = ".pexe.debug" |
| 81 |
| 82 finalize = toolprefix + "finalize" |
| 83 nonfinal_file = |
| 84 "{{root_out_dir}}/{{target_output_name}}${executable_extension}" |
| 85 finalized_file = "{{root_out_dir}}/{{target_output_name}}.pexe" |
| 86 postlink = "$finalize $nonfinal_file -o $finalized_file" |
| 87 link_outputs = [ finalized_file ] |
| 88 } |
| 89 |
| 90 nacl_toolchain("glibc_x86") { |
| 91 toolchain_package = "nacl_x86_glibc" |
| 92 toolchain_revision = nacl_x86_glibc_rev |
| 93 toolchain_cpu = "x86" |
| 94 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-" |
| 95 is_clang = false |
| 96 |
| 97 cc = toolprefix + "gcc" |
| 98 cxx = toolprefix + "g++" |
| 99 ar = toolprefix + "ar" |
| 100 ld = cxx |
| 101 } |
| 102 |
| 103 nacl_toolchain("glibc_x64") { |
| 104 toolchain_package = "nacl_x86_glibc" |
| 105 toolchain_revision = nacl_x86_glibc_rev |
| 106 toolchain_cpu = "x64" |
| 107 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-" |
| 108 is_clang = false |
| 109 |
| 110 cc = toolprefix + "gcc" |
| 111 cxx = toolprefix + "g++" |
| 112 ar = toolprefix + "ar" |
| 113 ld = cxx |
| 114 } |
| 115 |
| 116 nacl_toolchain("clang_newlib_x86") { |
| 117 toolchain_package = "pnacl_newlib" |
| 118 toolchain_revision = pnacl_newlib_rev |
| 119 toolchain_cpu = "x86" |
| 120 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-" |
| 121 is_clang = true |
| 122 |
| 123 cc = toolprefix + "clang" |
| 124 cxx = toolprefix + "clang++" |
| 125 ar = toolprefix + "ar" |
| 126 ld = cxx |
| 127 } |
| 128 |
| 129 nacl_toolchain("clang_newlib_x64") { |
| 130 toolchain_package = "pnacl_newlib" |
| 131 toolchain_revision = pnacl_newlib_rev |
| 132 toolchain_cpu = "x64" |
| 133 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-" |
| 134 is_clang = true |
| 135 |
| 136 cc = toolprefix + "clang" |
| 137 cxx = toolprefix + "clang++" |
| 138 ar = toolprefix + "ar" |
| 139 ld = cxx |
| 140 } |
| 141 |
| 142 template("nacl_irt_toolchain") { |
| 143 toolchain_cpu = target_name |
| 144 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple") |
| 145 |
| 146 toolchain_package = "pnacl_newlib" |
| 147 toolchain_revision = pnacl_newlib_rev |
| 148 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/" + |
| 149 invoker.toolchain_tuple + "-" |
| 150 |
| 151 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir) |
| 152 |
| 153 tls_edit_label = |
| 154 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)" |
| 155 host_toolchain_out_dir = |
| 156 rebase_path(get_label_info(tls_edit_label, "root_out_dir"), |
| 157 root_build_dir) |
| 158 tls_edit = "${host_toolchain_out_dir}/tls_edit" |
| 159 |
| 160 nacl_toolchain("irt_" + toolchain_cpu) { |
| 161 is_clang = true |
| 162 cc = toolprefix + "clang" |
| 163 cxx = toolprefix + "clang++" |
| 164 ar = toolprefix + "ar" |
| 165 readelf = toolprefix + "readelf" |
| 166 |
| 167 # Some IRT implementations (notably, Chromium's) contain C++ code, |
| 168 # so we need to link w/ the C++ linker. |
| 169 ld = "${python_path} ${link_irt} --tls-edit=${tls_edit} --link-cmd=${cxx} --
readelf-cmd=${readelf}" |
| 170 |
| 171 # TODO(ncbray): depend on link script |
| 172 deps = [ |
| 173 tls_edit_label, |
| 174 ] |
62 } | 175 } |
63 } | 176 } |
| 177 |
| 178 nacl_irt_toolchain("x86") { |
| 179 toolchain_tuple = "i686-nacl" |
| 180 } |
| 181 |
| 182 nacl_irt_toolchain("x64") { |
| 183 toolchain_tuple = "x86_64-nacl" |
| 184 } |
| 185 |
| 186 nacl_irt_toolchain("arm") { |
| 187 toolchain_tuple = "arm-nacl" |
| 188 } |
OLD | NEW |