4 #include "../util/env.h" 5 #include "../util/util.h" 6 #include "../util/debug.h" 10 "arm-linux-androideabi-",
12 "arm-unknown-linux-gnu-",
13 "arm-unknown-linux-gnueabi-",
15 "arm-linux-gnueabihf-",
21 "aarch64-linux-android-",
27 "powerpc-unknown-linux-gnu-",
29 "powerpc64-unknown-linux-gnu-",
30 "powerpc64-linux-gnu-",
31 "powerpc64le-linux-gnu-",
42 "sh-unknown-linux-gnu-",
43 "sh64-unknown-linux-gnu-",
50 "sparc-unknown-linux-gnu-",
51 "sparc64-unknown-linux-gnu-",
57 "x86_64-pc-linux-gnu-",
58 "x86_64-unknown-linux-gnu-",
63 "i686-linux-android-",
64 "i686-android-linux-",
71 "mips-unknown-linux-gnu-",
72 "mipsel-linux-android-",
75 "mips64el-linux-gnuabi64-",
76 "mips64-linux-gnuabi64-",
84 char *path, *tmp = NULL;
86 char *env = getenv(
"PATH");
95 path = strtok_r(env,
":", &tmp);
97 scnprintf(buf,
sizeof(buf),
"%s/%s", path, name);
98 if (access(buf, F_OK) == 0) {
102 path = strtok_r(NULL,
":", &tmp);
113 for (i = 0; triplets[i] != NULL; i++) {
114 scnprintf(buf,
sizeof(buf),
"%s%s", triplets[i], name);
122 const char *
name,
const char **path)
126 const char *
const *path_list;
136 cross_env = getenv(
"CROSS_COMPILE");
138 if (asprintf(&buf,
"%s%s", cross_env, name) < 0)
141 if (access(buf, F_OK) == 0)
150 if (!strcmp(arch,
"arm"))
152 else if (!strcmp(arch,
"arm64"))
154 else if (!strcmp(arch,
"powerpc"))
156 else if (!strcmp(arch,
"sh"))
158 else if (!strcmp(arch,
"s390"))
160 else if (!strcmp(arch,
"sparc"))
162 else if (!strcmp(arch,
"x86"))
164 else if (!strcmp(arch,
"mips"))
167 ui__error(
"binutils for %s not supported.\n", arch);
174 "You can add it to PATH, set CROSS_COMPILE or " 175 "override the default using --%s.\n",
180 if (asprintf(&buf,
"%s%s", path_list[idx], name) < 0)
198 if (env->
arch == NULL)
static int lookup_triplets(const char *const *triplets, const char *name)
int ui__error(const char *format,...)
const char *const sh_triplets[]
static bool lookup_path(char *name)
static int perf_env__lookup_binutils_path(struct perf_env *env, const char *name, const char **path)
const char *const arm_triplets[]
const char *const mips_triplets[]
const char *const x86_triplets[]
const char *const arm64_triplets[]
int perf_env__lookup_objdump(struct perf_env *env, const char **path)
const char *const s390_triplets[]
const char * perf_env__arch(struct perf_env *env)
const char *const sparc_triplets[]
const char *const powerpc_triplets[]