blob: 824356488ce6a8c7d9ecda1748456b262f0a7114 [file] [log] [blame]
Wang Nanaa61fd02015-07-21 11:13:34 +00001/*
2 * Copyright (C) 2015, Wang Nan <wangnan0@huawei.com>
3 * Copyright (C) 2015, Huawei Inc.
4 */
5
Arnaldo Carvalho de Melo175729f2016-07-07 11:38:09 -03006#include <errno.h>
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -03007#include <limits.h>
Wang Nanaa61fd02015-07-21 11:13:34 +00008#include <stdio.h>
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -03009#include <stdlib.h>
Wang Nan2bd42de2016-11-26 07:03:30 +000010#include <linux/err.h>
Wang Nanaa61fd02015-07-21 11:13:34 +000011#include "debug.h"
12#include "llvm-utils.h"
Taeung Song41840d22016-06-23 17:55:17 +090013#include "config.h"
Arnaldo Carvalho de Melo175729f2016-07-07 11:38:09 -030014#include "util.h"
Wang Nanaa61fd02015-07-21 11:13:34 +000015
16#define CLANG_BPF_CMD_DEFAULT_TEMPLATE \
Wang Nan59f41af2015-11-04 11:20:04 +000017 "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
Wang Nan4a4f66a2015-11-04 11:20:05 +000018 "-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE " \
Wang Nan59f41af2015-11-04 11:20:04 +000019 "$CLANG_OPTIONS $KERNEL_INC_OPTIONS " \
20 "-Wno-unused-value -Wno-pointer-sign " \
21 "-working-directory $WORKING_DIR " \
22 "-c \"$CLANG_SOURCE\" -target bpf -O2 -o -"
Wang Nanaa61fd02015-07-21 11:13:34 +000023
24struct llvm_param llvm_param = {
25 .clang_path = "clang",
26 .clang_bpf_cmd_template = CLANG_BPF_CMD_DEFAULT_TEMPLATE,
27 .clang_opt = NULL,
28 .kbuild_dir = NULL,
29 .kbuild_opts = NULL,
Wang Nan9bc898c2015-07-08 10:04:02 +000030 .user_set_param = false,
Wang Nanaa61fd02015-07-21 11:13:34 +000031};
32
33int perf_llvm_config(const char *var, const char *value)
34{
35 if (prefixcmp(var, "llvm."))
36 return 0;
37 var += sizeof("llvm.") - 1;
38
39 if (!strcmp(var, "clang-path"))
40 llvm_param.clang_path = strdup(value);
41 else if (!strcmp(var, "clang-bpf-cmd-template"))
42 llvm_param.clang_bpf_cmd_template = strdup(value);
43 else if (!strcmp(var, "clang-opt"))
44 llvm_param.clang_opt = strdup(value);
45 else if (!strcmp(var, "kbuild-dir"))
46 llvm_param.kbuild_dir = strdup(value);
47 else if (!strcmp(var, "kbuild-opts"))
48 llvm_param.kbuild_opts = strdup(value);
Wang Nanf0784642016-06-16 08:02:40 +000049 else if (!strcmp(var, "dump-obj"))
50 llvm_param.dump_obj = !!perf_config_bool(var, value);
Arnaldo Carvalho de Meloecc4c562017-01-24 13:44:10 -030051 else {
52 pr_debug("Invalid LLVM config option: %s\n", value);
Wang Nanaa61fd02015-07-21 11:13:34 +000053 return -1;
Arnaldo Carvalho de Meloecc4c562017-01-24 13:44:10 -030054 }
Wang Nan9bc898c2015-07-08 10:04:02 +000055 llvm_param.user_set_param = true;
Wang Nanaa61fd02015-07-21 11:13:34 +000056 return 0;
57}
Wang Nan4cea3a92015-06-11 10:31:09 +000058
59static int
60search_program(const char *def, const char *name,
61 char *output)
62{
63 char *env, *path, *tmp = NULL;
64 char buf[PATH_MAX];
65 int ret;
66
67 output[0] = '\0';
68 if (def && def[0] != '\0') {
69 if (def[0] == '/') {
70 if (access(def, F_OK) == 0) {
71 strlcpy(output, def, PATH_MAX);
72 return 0;
73 }
74 } else if (def[0] != '\0')
75 name = def;
76 }
77
78 env = getenv("PATH");
79 if (!env)
80 return -1;
81 env = strdup(env);
82 if (!env)
83 return -1;
84
85 ret = -ENOENT;
86 path = strtok_r(env, ":", &tmp);
87 while (path) {
88 scnprintf(buf, sizeof(buf), "%s/%s", path, name);
89 if (access(buf, F_OK) == 0) {
90 strlcpy(output, buf, PATH_MAX);
91 ret = 0;
92 break;
93 }
94 path = strtok_r(NULL, ":", &tmp);
95 }
96
97 free(env);
98 return ret;
99}
100
101#define READ_SIZE 4096
102static int
103read_from_pipe(const char *cmd, void **p_buf, size_t *p_read_sz)
104{
105 int err = 0;
106 void *buf = NULL;
107 FILE *file = NULL;
108 size_t read_sz = 0, buf_sz = 0;
Arnaldo Carvalho de Melo76267142016-03-23 17:42:21 -0300109 char serr[STRERR_BUFSIZE];
Wang Nan4cea3a92015-06-11 10:31:09 +0000110
111 file = popen(cmd, "r");
112 if (!file) {
113 pr_err("ERROR: unable to popen cmd: %s\n",
Arnaldo Carvalho de Meloc8b5f2c2016-07-06 11:56:20 -0300114 str_error_r(errno, serr, sizeof(serr)));
Wang Nan4cea3a92015-06-11 10:31:09 +0000115 return -EINVAL;
116 }
117
118 while (!feof(file) && !ferror(file)) {
119 /*
120 * Make buf_sz always have obe byte extra space so we
121 * can put '\0' there.
122 */
123 if (buf_sz - read_sz < READ_SIZE + 1) {
124 void *new_buf;
125
126 buf_sz = read_sz + READ_SIZE + 1;
127 new_buf = realloc(buf, buf_sz);
128
129 if (!new_buf) {
130 pr_err("ERROR: failed to realloc memory\n");
131 err = -ENOMEM;
132 goto errout;
133 }
134
135 buf = new_buf;
136 }
137 read_sz += fread(buf + read_sz, 1, READ_SIZE, file);
138 }
139
140 if (buf_sz - read_sz < 1) {
141 pr_err("ERROR: internal error\n");
142 err = -EINVAL;
143 goto errout;
144 }
145
146 if (ferror(file)) {
147 pr_err("ERROR: error occurred when reading from pipe: %s\n",
Arnaldo Carvalho de Meloc8b5f2c2016-07-06 11:56:20 -0300148 str_error_r(errno, serr, sizeof(serr)));
Wang Nan4cea3a92015-06-11 10:31:09 +0000149 err = -EIO;
150 goto errout;
151 }
152
153 err = WEXITSTATUS(pclose(file));
154 file = NULL;
155 if (err) {
156 err = -EINVAL;
157 goto errout;
158 }
159
160 /*
161 * If buf is string, give it terminal '\0' to make our life
162 * easier. If buf is not string, that '\0' is out of space
163 * indicated by read_sz so caller won't even notice it.
164 */
165 ((char *)buf)[read_sz] = '\0';
166
167 if (!p_buf)
168 free(buf);
169 else
170 *p_buf = buf;
171
172 if (p_read_sz)
173 *p_read_sz = read_sz;
174 return 0;
175
176errout:
177 if (file)
178 pclose(file);
179 free(buf);
180 if (p_buf)
181 *p_buf = NULL;
182 if (p_read_sz)
183 *p_read_sz = 0;
184 return err;
185}
186
187static inline void
188force_set_env(const char *var, const char *value)
189{
190 if (value) {
191 setenv(var, value, 1);
192 pr_debug("set env: %s=%s\n", var, value);
193 } else {
194 unsetenv(var);
195 pr_debug("unset env: %s\n", var);
196 }
197}
198
199static void
200version_notice(void)
201{
202 pr_err(
203" \tLLVM 3.7 or newer is required. Which can be found from http://llvm.org\n"
204" \tYou may want to try git trunk:\n"
205" \t\tgit clone http://llvm.org/git/llvm.git\n"
206" \t\t and\n"
207" \t\tgit clone http://llvm.org/git/clang.git\n\n"
208" \tOr fetch the latest clang/llvm 3.7 from pre-built llvm packages for\n"
209" \tdebian/ubuntu:\n"
210" \t\thttp://llvm.org/apt\n\n"
211" \tIf you are using old version of clang, change 'clang-bpf-cmd-template'\n"
212" \toption in [llvm] section of ~/.perfconfig to:\n\n"
213" \t \"$CLANG_EXEC $CLANG_OPTIONS $KERNEL_INC_OPTIONS \\\n"
214" \t -working-directory $WORKING_DIR -c $CLANG_SOURCE \\\n"
215" \t -emit-llvm -o - | /path/to/llc -march=bpf -filetype=obj -o -\"\n"
216" \t(Replace /path/to/llc with path to your llc)\n\n"
217);
218}
219
Wang Nand325d782015-07-14 06:40:02 +0000220static int detect_kbuild_dir(char **kbuild_dir)
221{
222 const char *test_dir = llvm_param.kbuild_dir;
223 const char *prefix_dir = "";
224 const char *suffix_dir = "";
225
226 char *autoconf_path;
Wang Nand325d782015-07-14 06:40:02 +0000227
228 int err;
229
230 if (!test_dir) {
Wang Nan07bc5c62015-11-06 13:55:35 +0000231 /* _UTSNAME_LENGTH is 65 */
232 char release[128];
Wang Nand325d782015-07-14 06:40:02 +0000233
Wang Nan07bc5c62015-11-06 13:55:35 +0000234 err = fetch_kernel_version(NULL, release,
235 sizeof(release));
236 if (err)
237 return -EINVAL;
238
239 test_dir = release;
Wang Nand325d782015-07-14 06:40:02 +0000240 prefix_dir = "/lib/modules/";
241 suffix_dir = "/build";
242 }
243
244 err = asprintf(&autoconf_path, "%s%s%s/include/generated/autoconf.h",
245 prefix_dir, test_dir, suffix_dir);
246 if (err < 0)
247 return -ENOMEM;
248
249 if (access(autoconf_path, R_OK) == 0) {
250 free(autoconf_path);
251
252 err = asprintf(kbuild_dir, "%s%s%s", prefix_dir, test_dir,
253 suffix_dir);
254 if (err < 0)
255 return -ENOMEM;
256 return 0;
257 }
258 free(autoconf_path);
259 return -ENOENT;
260}
261
Wang Nan0c6d18b2015-06-11 11:25:49 +0000262static const char *kinc_fetch_script =
263"#!/usr/bin/env sh\n"
264"if ! test -d \"$KBUILD_DIR\"\n"
265"then\n"
266" exit -1\n"
267"fi\n"
268"if ! test -f \"$KBUILD_DIR/include/generated/autoconf.h\"\n"
269"then\n"
270" exit -1\n"
271"fi\n"
272"TMPDIR=`mktemp -d`\n"
273"if test -z \"$TMPDIR\"\n"
274"then\n"
275" exit -1\n"
276"fi\n"
277"cat << EOF > $TMPDIR/Makefile\n"
278"obj-y := dummy.o\n"
279"\\$(obj)/%.o: \\$(src)/%.c\n"
280"\t@echo -n \"\\$(NOSTDINC_FLAGS) \\$(LINUXINCLUDE) \\$(EXTRA_CFLAGS)\"\n"
281"EOF\n"
282"touch $TMPDIR/dummy.c\n"
283"make -s -C $KBUILD_DIR M=$TMPDIR $KBUILD_OPTS dummy.o 2>/dev/null\n"
284"RET=$?\n"
285"rm -rf $TMPDIR\n"
286"exit $RET\n";
287
Wang Nan2bd42de2016-11-26 07:03:30 +0000288void llvm__get_kbuild_opts(char **kbuild_dir, char **kbuild_include_opts)
Wang Nand325d782015-07-14 06:40:02 +0000289{
Wang Nan2bd42de2016-11-26 07:03:30 +0000290 static char *saved_kbuild_dir;
291 static char *saved_kbuild_include_opts;
Wang Nand325d782015-07-14 06:40:02 +0000292 int err;
293
Wang Nan0c6d18b2015-06-11 11:25:49 +0000294 if (!kbuild_dir || !kbuild_include_opts)
Wang Nand325d782015-07-14 06:40:02 +0000295 return;
296
297 *kbuild_dir = NULL;
Wang Nan0c6d18b2015-06-11 11:25:49 +0000298 *kbuild_include_opts = NULL;
Wang Nand325d782015-07-14 06:40:02 +0000299
Wang Nan2bd42de2016-11-26 07:03:30 +0000300 if (saved_kbuild_dir && saved_kbuild_include_opts &&
301 !IS_ERR(saved_kbuild_dir) && !IS_ERR(saved_kbuild_include_opts)) {
302 *kbuild_dir = strdup(saved_kbuild_dir);
303 *kbuild_include_opts = strdup(saved_kbuild_include_opts);
304
305 if (*kbuild_dir && *kbuild_include_opts)
306 return;
307
308 zfree(kbuild_dir);
309 zfree(kbuild_include_opts);
310 /*
311 * Don't fall through: it may breaks saved_kbuild_dir and
312 * saved_kbuild_include_opts if detect them again when
313 * memory is low.
314 */
315 return;
316 }
317
Wang Nand325d782015-07-14 06:40:02 +0000318 if (llvm_param.kbuild_dir && !llvm_param.kbuild_dir[0]) {
319 pr_debug("[llvm.kbuild-dir] is set to \"\" deliberately.\n");
320 pr_debug("Skip kbuild options detection.\n");
Wang Nan2bd42de2016-11-26 07:03:30 +0000321 goto errout;
Wang Nand325d782015-07-14 06:40:02 +0000322 }
323
324 err = detect_kbuild_dir(kbuild_dir);
325 if (err) {
326 pr_warning(
327"WARNING:\tunable to get correct kernel building directory.\n"
328"Hint:\tSet correct kbuild directory using 'kbuild-dir' option in [llvm]\n"
329" \tsection of ~/.perfconfig or set it to \"\" to suppress kbuild\n"
330" \tdetection.\n\n");
Wang Nan2bd42de2016-11-26 07:03:30 +0000331 goto errout;
Wang Nand325d782015-07-14 06:40:02 +0000332 }
Wang Nan0c6d18b2015-06-11 11:25:49 +0000333
334 pr_debug("Kernel build dir is set to %s\n", *kbuild_dir);
335 force_set_env("KBUILD_DIR", *kbuild_dir);
336 force_set_env("KBUILD_OPTS", llvm_param.kbuild_opts);
337 err = read_from_pipe(kinc_fetch_script,
338 (void **)kbuild_include_opts,
339 NULL);
340 if (err) {
341 pr_warning(
342"WARNING:\tunable to get kernel include directories from '%s'\n"
343"Hint:\tTry set clang include options using 'clang-bpf-cmd-template'\n"
344" \toption in [llvm] section of ~/.perfconfig and set 'kbuild-dir'\n"
345" \toption in [llvm] to \"\" to suppress this detection.\n\n",
346 *kbuild_dir);
347
348 free(*kbuild_dir);
349 *kbuild_dir = NULL;
Wang Nan2bd42de2016-11-26 07:03:30 +0000350 goto errout;
Wang Nan0c6d18b2015-06-11 11:25:49 +0000351 }
352
353 pr_debug("include option is set to %s\n", *kbuild_include_opts);
Wang Nan2bd42de2016-11-26 07:03:30 +0000354
355 saved_kbuild_dir = strdup(*kbuild_dir);
356 saved_kbuild_include_opts = strdup(*kbuild_include_opts);
357
358 if (!saved_kbuild_dir || !saved_kbuild_include_opts) {
359 zfree(&saved_kbuild_dir);
360 zfree(&saved_kbuild_include_opts);
361 }
362 return;
363errout:
364 saved_kbuild_dir = ERR_PTR(-EINVAL);
365 saved_kbuild_include_opts = ERR_PTR(-EINVAL);
Wang Nand325d782015-07-14 06:40:02 +0000366}
367
Wang Nan2bd42de2016-11-26 07:03:30 +0000368int llvm__get_nr_cpus(void)
369{
370 static int nr_cpus_avail = 0;
371 char serr[STRERR_BUFSIZE];
372
373 if (nr_cpus_avail > 0)
374 return nr_cpus_avail;
375
376 nr_cpus_avail = sysconf(_SC_NPROCESSORS_CONF);
377 if (nr_cpus_avail <= 0) {
378 pr_err(
379"WARNING:\tunable to get available CPUs in this system: %s\n"
380" \tUse 128 instead.\n", str_error_r(errno, serr, sizeof(serr)));
381 nr_cpus_avail = 128;
382 }
383 return nr_cpus_avail;
384}
385
386void llvm__dump_obj(const char *path, void *obj_buf, size_t size)
Wang Nanf0784642016-06-16 08:02:40 +0000387{
388 char *obj_path = strdup(path);
389 FILE *fp;
390 char *p;
391
392 if (!obj_path) {
Alexander Alemayhu042cfb52016-10-13 18:18:11 +0200393 pr_warning("WARNING: Not enough memory, skip object dumping\n");
Wang Nanf0784642016-06-16 08:02:40 +0000394 return;
395 }
396
397 p = strrchr(obj_path, '.');
398 if (!p || (strcmp(p, ".c") != 0)) {
399 pr_warning("WARNING: invalid llvm source path: '%s', skip object dumping\n",
400 obj_path);
401 goto out;
402 }
403
404 p[1] = 'o';
405 fp = fopen(obj_path, "wb");
406 if (!fp) {
407 pr_warning("WARNING: failed to open '%s': %s, skip object dumping\n",
408 obj_path, strerror(errno));
409 goto out;
410 }
411
412 pr_info("LLVM: dumping %s\n", obj_path);
413 if (fwrite(obj_buf, size, 1, fp) != 1)
414 pr_warning("WARNING: failed to write to file '%s': %s, skip object dumping\n",
415 obj_path, strerror(errno));
416 fclose(fp);
417out:
418 free(obj_path);
419}
420
Wang Nan4cea3a92015-06-11 10:31:09 +0000421int llvm__compile_bpf(const char *path, void **p_obj_buf,
422 size_t *p_obj_buf_sz)
423{
Wang Nan07bc5c62015-11-06 13:55:35 +0000424 size_t obj_buf_sz;
425 void *obj_buf = NULL;
Wang Nan59f41af2015-11-04 11:20:04 +0000426 int err, nr_cpus_avail;
Wang Nan07bc5c62015-11-06 13:55:35 +0000427 unsigned int kernel_version;
Wang Nan4a4f66a2015-11-04 11:20:05 +0000428 char linux_version_code_str[64];
Wang Nan4cea3a92015-06-11 10:31:09 +0000429 const char *clang_opt = llvm_param.clang_opt;
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -0300430 char clang_path[PATH_MAX], abspath[PATH_MAX], nr_cpus_avail_str[64];
431 char serr[STRERR_BUFSIZE];
Wang Nan0c6d18b2015-06-11 11:25:49 +0000432 char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
Wang Nan07bc5c62015-11-06 13:55:35 +0000433 const char *template = llvm_param.clang_bpf_cmd_template;
Wang Nan4cea3a92015-06-11 10:31:09 +0000434
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -0300435 if (path[0] != '-' && realpath(path, abspath) == NULL) {
436 err = errno;
437 pr_err("ERROR: problems with path %s: %s\n",
Arnaldo Carvalho de Meloc8b5f2c2016-07-06 11:56:20 -0300438 path, str_error_r(err, serr, sizeof(serr)));
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -0300439 return -err;
440 }
441
Wang Nan4cea3a92015-06-11 10:31:09 +0000442 if (!template)
443 template = CLANG_BPF_CMD_DEFAULT_TEMPLATE;
444
445 err = search_program(llvm_param.clang_path,
446 "clang", clang_path);
447 if (err) {
448 pr_err(
449"ERROR:\tunable to find clang.\n"
450"Hint:\tTry to install latest clang/llvm to support BPF. Check your $PATH\n"
451" \tand 'clang-path' option in [llvm] section of ~/.perfconfig.\n");
452 version_notice();
453 return -ENOENT;
454 }
455
Wang Nand325d782015-07-14 06:40:02 +0000456 /*
457 * This is an optional work. Even it fail we can continue our
458 * work. Needn't to check error return.
459 */
Wang Nan2bd42de2016-11-26 07:03:30 +0000460 llvm__get_kbuild_opts(&kbuild_dir, &kbuild_include_opts);
Wang Nand325d782015-07-14 06:40:02 +0000461
Wang Nan2bd42de2016-11-26 07:03:30 +0000462 nr_cpus_avail = llvm__get_nr_cpus();
Wang Nan59f41af2015-11-04 11:20:04 +0000463 snprintf(nr_cpus_avail_str, sizeof(nr_cpus_avail_str), "%d",
464 nr_cpus_avail);
465
Wang Nan07bc5c62015-11-06 13:55:35 +0000466 if (fetch_kernel_version(&kernel_version, NULL, 0))
467 kernel_version = 0;
468
Wang Nan4a4f66a2015-11-04 11:20:05 +0000469 snprintf(linux_version_code_str, sizeof(linux_version_code_str),
Wang Nan07bc5c62015-11-06 13:55:35 +0000470 "0x%x", kernel_version);
Wang Nan4a4f66a2015-11-04 11:20:05 +0000471
Wang Nan59f41af2015-11-04 11:20:04 +0000472 force_set_env("NR_CPUS", nr_cpus_avail_str);
Wang Nan4a4f66a2015-11-04 11:20:05 +0000473 force_set_env("LINUX_VERSION_CODE", linux_version_code_str);
Wang Nan4cea3a92015-06-11 10:31:09 +0000474 force_set_env("CLANG_EXEC", clang_path);
475 force_set_env("CLANG_OPTIONS", clang_opt);
Wang Nan0c6d18b2015-06-11 11:25:49 +0000476 force_set_env("KERNEL_INC_OPTIONS", kbuild_include_opts);
Wang Nand325d782015-07-14 06:40:02 +0000477 force_set_env("WORKING_DIR", kbuild_dir ? : ".");
Wang Nan4cea3a92015-06-11 10:31:09 +0000478
479 /*
480 * Since we may reset clang's working dir, path of source file
481 * should be transferred into absolute path, except we want
482 * stdin to be source file (testing).
483 */
484 force_set_env("CLANG_SOURCE",
Arnaldo Carvalho de Melo78478262016-03-23 17:34:29 -0300485 (path[0] == '-') ? path : abspath);
Wang Nan4cea3a92015-06-11 10:31:09 +0000486
487 pr_debug("llvm compiling command template: %s\n", template);
488 err = read_from_pipe(template, &obj_buf, &obj_buf_sz);
489 if (err) {
490 pr_err("ERROR:\tunable to compile %s\n", path);
491 pr_err("Hint:\tCheck error message shown above.\n");
492 pr_err("Hint:\tYou can also pre-compile it into .o using:\n");
493 pr_err(" \t\tclang -target bpf -O2 -c %s\n", path);
494 pr_err(" \twith proper -I and -D options.\n");
495 goto errout;
496 }
497
Wang Nand325d782015-07-14 06:40:02 +0000498 free(kbuild_dir);
Wang Nan0c6d18b2015-06-11 11:25:49 +0000499 free(kbuild_include_opts);
Wang Nanf0784642016-06-16 08:02:40 +0000500
Wang Nan4cea3a92015-06-11 10:31:09 +0000501 if (!p_obj_buf)
502 free(obj_buf);
503 else
504 *p_obj_buf = obj_buf;
505
506 if (p_obj_buf_sz)
507 *p_obj_buf_sz = obj_buf_sz;
508 return 0;
509errout:
Wang Nand325d782015-07-14 06:40:02 +0000510 free(kbuild_dir);
Wang Nan0c6d18b2015-06-11 11:25:49 +0000511 free(kbuild_include_opts);
Wang Nan4cea3a92015-06-11 10:31:09 +0000512 free(obj_buf);
513 if (p_obj_buf)
514 *p_obj_buf = NULL;
515 if (p_obj_buf_sz)
516 *p_obj_buf_sz = 0;
517 return err;
518}
Wang Nan9bc898c2015-07-08 10:04:02 +0000519
520int llvm__search_clang(void)
521{
522 char clang_path[PATH_MAX];
523
524 return search_program(llvm_param.clang_path, "clang", clang_path);
525}