.. | .. |
---|
8 | 8 | #include <limits.h> |
---|
9 | 9 | #include <stdio.h> |
---|
10 | 10 | #include <stdlib.h> |
---|
| 11 | +#include <unistd.h> |
---|
11 | 12 | #include <linux/err.h> |
---|
| 13 | +#include <linux/string.h> |
---|
| 14 | +#include <linux/zalloc.h> |
---|
12 | 15 | #include "debug.h" |
---|
13 | 16 | #include "llvm-utils.h" |
---|
14 | 17 | #include "config.h" |
---|
.. | .. |
---|
19 | 22 | #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \ |
---|
20 | 23 | "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\ |
---|
21 | 24 | "-DLINUX_VERSION_CODE=$LINUX_VERSION_CODE " \ |
---|
22 | | - "$CLANG_OPTIONS $KERNEL_INC_OPTIONS $PERF_BPF_INC_OPTIONS " \ |
---|
| 25 | + "$CLANG_OPTIONS $PERF_BPF_INC_OPTIONS $KERNEL_INC_OPTIONS " \ |
---|
23 | 26 | "-Wno-unused-value -Wno-pointer-sign " \ |
---|
24 | 27 | "-working-directory $WORKING_DIR " \ |
---|
25 | 28 | "-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE" |
---|
.. | .. |
---|
262 | 265 | return -ENOMEM; |
---|
263 | 266 | return 0; |
---|
264 | 267 | } |
---|
| 268 | + pr_debug("%s: Couldn't find \"%s\", missing kernel-devel package?.\n", |
---|
| 269 | + __func__, autoconf_path); |
---|
265 | 270 | free(autoconf_path); |
---|
266 | 271 | return -ENOENT; |
---|
267 | 272 | } |
---|
.. | .. |
---|
285 | 290 | "obj-y := dummy.o\n" |
---|
286 | 291 | "\\$(obj)/%.o: \\$(src)/%.c\n" |
---|
287 | 292 | "\t@echo -n \"\\$(NOSTDINC_FLAGS) \\$(LINUXINCLUDE) \\$(EXTRA_CFLAGS)\"\n" |
---|
| 293 | +"\t\\$(CC) -c -o \\$@ \\$<\n" |
---|
288 | 294 | "EOF\n" |
---|
289 | 295 | "touch $TMPDIR/dummy.c\n" |
---|
290 | 296 | "make -s -C $KBUILD_DIR M=$TMPDIR $KBUILD_OPTS dummy.o 2>/dev/null\n" |
---|
.. | .. |
---|
352 | 358 | " \toption in [llvm] to \"\" to suppress this detection.\n\n", |
---|
353 | 359 | *kbuild_dir); |
---|
354 | 360 | |
---|
355 | | - free(*kbuild_dir); |
---|
356 | | - *kbuild_dir = NULL; |
---|
| 361 | + zfree(kbuild_dir); |
---|
357 | 362 | goto errout; |
---|
358 | 363 | } |
---|
359 | 364 | |
---|
.. | .. |
---|
416 | 421 | goto out; |
---|
417 | 422 | } |
---|
418 | 423 | |
---|
419 | | - pr_info("LLVM: dumping %s\n", obj_path); |
---|
| 424 | + pr_debug("LLVM: dumping %s\n", obj_path); |
---|
420 | 425 | if (fwrite(obj_buf, size, 1, fp) != 1) |
---|
421 | | - pr_warning("WARNING: failed to write to file '%s': %s, skip object dumping\n", |
---|
422 | | - obj_path, strerror(errno)); |
---|
| 426 | + pr_debug("WARNING: failed to write to file '%s': %s, skip object dumping\n", obj_path, strerror(errno)); |
---|
423 | 427 | fclose(fp); |
---|
424 | 428 | out: |
---|
425 | 429 | free(obj_path); |
---|