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
3 # found in the LICENSE file.
5 import("//build/config/sysroot.gni")
6 import("//build/toolchain/nacl_toolchain.gni")
8 nacl_toolchain_dir = rebase_path("//native_client/toolchain", root_build_dir)
9 os_toolchain_dir = "${nacl_toolchain_dir}/${current_os}_x86"
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",
24 nacl_x86_glibc_rev = revisions[0]
25 pnacl_newlib_rev = revisions[1]
27 nacl_toolchain("newlib_pnacl") {
28 toolchain_package = "pnacl_newlib"
29 toolchain_revision = pnacl_newlib_rev
30 toolchain_cpu = "pnacl"
31 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/pnacl-"
33 cc = toolprefix + "clang"
34 cxx = toolprefix + "clang++"
35 ar = toolprefix + "ar"
37 executable_extension = ".pexe.debug"
39 finalize = toolprefix + "finalize"
41 "{{root_out_dir}}/{{target_output_name}}${executable_extension}"
42 finalized_file = "{{root_out_dir}}/{{target_output_name}}.pexe"
43 postlink = "$finalize $nonfinal_file -o $finalized_file"
44 link_outputs = [ finalized_file ]
47 nacl_toolchain("glibc_x86") {
48 toolchain_package = "nacl_x86_glibc"
49 toolchain_revision = nacl_x86_glibc_rev
51 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
54 cc = toolprefix + "gcc"
55 cxx = toolprefix + "g++"
56 ar = toolprefix + "ar"
60 nacl_toolchain("glibc_x64") {
61 toolchain_package = "nacl_x86_glibc"
62 toolchain_revision = nacl_x86_glibc_rev
64 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
67 cc = toolprefix + "gcc"
68 cxx = toolprefix + "g++"
69 ar = toolprefix + "ar"
73 nacl_toolchain("clang_newlib_x86") {
74 toolchain_package = "pnacl_newlib"
75 toolchain_revision = pnacl_newlib_rev
77 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/i686-nacl-"
80 cc = toolprefix + "clang"
81 cxx = toolprefix + "clang++"
82 ar = toolprefix + "ar"
86 nacl_toolchain("clang_newlib_x64") {
87 toolchain_package = "pnacl_newlib"
88 toolchain_revision = pnacl_newlib_rev
90 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/x86_64-nacl-"
93 cc = toolprefix + "clang"
94 cxx = toolprefix + "clang++"
95 ar = toolprefix + "ar"
99 template("nacl_irt_toolchain") {
100 toolchain_cpu = target_name
101 assert(defined(invoker.toolchain_tuple), "Must define toolchain_tuple")
103 toolchain_package = "pnacl_newlib"
104 toolchain_revision = pnacl_newlib_rev
105 toolprefix = "${os_toolchain_dir}/${toolchain_package}/bin/" +
106 invoker.toolchain_tuple + "-"
108 link_irt = rebase_path("//native_client/build/link_irt.py", root_build_dir)
111 "//native_client/src/tools/tls_edit:tls_edit($host_toolchain)"
112 host_toolchain_out_dir =
113 rebase_path(get_label_info(tls_edit_label, "root_out_dir"),
115 tls_edit = "${host_toolchain_out_dir}/tls_edit"
117 nacl_toolchain("irt_" + toolchain_cpu) {
119 cc = toolprefix + "clang"
120 cxx = toolprefix + "clang++"
121 ar = toolprefix + "ar"
122 readelf = toolprefix + "readelf"
124 # Some IRT implementations (notably, Chromium's) contain C++ code,
125 # so we need to link w/ the C++ linker.
126 ld = "${python_path} ${link_irt} --tls-edit=${tls_edit} --link-cmd=${cxx} --readelf-cmd=${readelf}"
128 # TODO(ncbray): depend on link script
135 nacl_irt_toolchain("x86") {
136 toolchain_tuple = "i686-nacl"
139 nacl_irt_toolchain("x64") {
140 toolchain_tuple = "x86_64-nacl"
143 nacl_irt_toolchain("arm") {
144 toolchain_tuple = "arm-nacl"