1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/compiler/compiler.gni")
import("//build/config/sysroot.gni")
import("//build/toolchain/cros_toolchain.gni")
import("//build/toolchain/gcc_toolchain.gni")
# This is mostly identical to gcc_toolchain, but handles relativizing toolchain
# paths. This is needed for CrOS since these paths often change based on the
# environment. For example, cxx is a relative path picked up on $PATH in the
# chroot. But in Simple Chrome, cxx is a system-absolute path.
template("cros_toolchain") {
gcc_toolchain(target_name) {
forward_variables_from(invoker, "*")
# CrOS's target toolchain wrapper prefers to invoke gomacc itself, so pass
# it the gomacc path via cmd-line arg. Otherwise, for both CrOS's host
# wrapper (used in the ebuild) and Chrome's clang (used in Simple Chrome),
# prepend gomacc like normal.
if (use_goma && toolchain_args.needs_gomacc_path_arg) {
extra_cppflags += " --gomacc-path $goma_dir/gomacc"
}
if (use_rbe && toolchain_args.needs_gomacc_path_arg) {
extra_cppflags += " --gomacc-path $rbe_cros_cc_wrapper"
}
# Relativize path if compiler is specified such that not to lookup from $PATH
# and cc/cxx does not contain additional flags.
if (cc != get_path_info(cc, "file") && string_replace(cc, " ", "") == cc) {
cc = rebase_path(cc, root_build_dir)
}
if (cxx != get_path_info(cxx, "file") &&
string_replace(cxx, " ", "") == cxx) {
cxx = rebase_path(cxx, root_build_dir)
}
if (ar != get_path_info(ar, "file") && string_replace(ar, " ", "") == ar) {
ar = rebase_path(ar, root_build_dir)
}
if (ld != get_path_info(ld, "file") && string_replace(ld, " ", "") == ld) {
ld = rebase_path(ld, root_build_dir)
}
}
}
# This is the normal toolchain for most targets.
cros_toolchain("target") {
ar = cros_target_ar
cc = cros_target_cc
cxx = cros_target_cxx
ld = cros_target_ld
if (cros_target_nm != "") {
nm = cros_target_nm
}
if (cros_target_readelf != "") {
readelf = cros_target_readelf
}
extra_cflags = cros_target_extra_cflags
extra_cppflags = cros_target_extra_cppflags
extra_cxxflags = cros_target_extra_cxxflags
extra_ldflags = cros_target_extra_ldflags
toolchain_args = {
cc_wrapper = ""
needs_gomacc_path_arg = true
clang_use_chrome_plugins = false
target_cpu = target_cpu
current_os = "chromeos"
is_clang = is_clang
use_debug_fission = use_debug_fission
use_gold = use_gold
use_sysroot = use_sysroot
sysroot = target_sysroot
}
}
# This is a special toolchain needed just for the nacl_bootstrap target in
# //native_client/src/trusted/service_runtime/linux. It is identical
# to ":target" except that it forces use_debug_fission, use_gold, and
# use_sysroot off, and allows the user to set different sets of extra flags.
cros_toolchain("nacl_bootstrap") {
ar = cros_target_ar
cc = cros_target_cc
cxx = cros_target_cxx
ld = cros_target_ld
if (cros_target_nm != "") {
nm = cros_target_nm
}
if (cros_target_readelf != "") {
readelf = cros_target_readelf
}
extra_cflags = cros_nacl_bootstrap_extra_cflags
extra_cppflags = cros_nacl_bootstrap_extra_cppflags
extra_cxxflags = cros_nacl_bootstrap_extra_cxxflags
extra_ldflags = cros_nacl_bootstrap_extra_ldflags
toolchain_args = {
cc_wrapper = ""
needs_gomacc_path_arg = true
clang_use_chrome_plugins = false
target_cpu = target_cpu
current_os = "chromeos"
is_clang = is_clang
use_debug_fission = false
use_gold = false
use_sysroot = false
}
}
cros_toolchain("host") {
# These are args for the template.
ar = cros_host_ar
cc = cros_host_cc
cxx = cros_host_cxx
ld = cros_host_ld
if (cros_host_nm != "") {
nm = cros_host_nm
}
if (cros_host_readelf != "") {
readelf = cros_host_readelf
}
extra_cflags = cros_host_extra_cflags
extra_cppflags = cros_host_extra_cppflags
extra_cxxflags = cros_host_extra_cxxflags
extra_ldflags = cros_host_extra_ldflags
toolchain_args = {
cc_wrapper = ""
needs_gomacc_path_arg = false
clang_use_chrome_plugins = false
is_clang = cros_host_is_clang
target_cpu = host_cpu
current_os = "linux"
use_sysroot = use_sysroot
sysroot = cros_host_sysroot
}
}
cros_toolchain("v8_snapshot") {
# These are args for the template.
ar = cros_v8_snapshot_ar
cc = cros_v8_snapshot_cc
cxx = cros_v8_snapshot_cxx
ld = cros_v8_snapshot_ld
if (cros_v8_snapshot_nm != "") {
nm = cros_v8_snapshot_nm
}
if (cros_v8_snapshot_readelf != "") {
readelf = cros_v8_snapshot_readelf
}
extra_cflags = cros_v8_snapshot_extra_cflags
extra_cppflags = cros_v8_snapshot_extra_cppflags
extra_cxxflags = cros_v8_snapshot_extra_cxxflags
extra_ldflags = cros_v8_snapshot_extra_ldflags
toolchain_args = {
cc_wrapper = ""
needs_gomacc_path_arg = false
clang_use_chrome_plugins = false
is_clang = cros_v8_snapshot_is_clang
if (target_cpu == "x86" || target_cpu == "arm" || target_cpu == "mipsel") {
target_cpu = "x86"
} else {
target_cpu = "x64"
}
v8_target_cpu = v8_target_cpu
current_os = "linux"
use_sysroot = use_sysroot
sysroot = cros_v8_snapshot_sysroot
}
}
|