hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/tools/perf/util/llvm-utils.c
....@@ -8,7 +8,10 @@
88 #include <limits.h>
99 #include <stdio.h>
1010 #include <stdlib.h>
11
+#include <unistd.h>
1112 #include <linux/err.h>
13
+#include <linux/string.h>
14
+#include <linux/zalloc.h>
1215 #include "debug.h"
1316 #include "llvm-utils.h"
1417 #include "config.h"
....@@ -19,7 +22,7 @@
1922 #define CLANG_BPF_CMD_DEFAULT_TEMPLATE \
2023 "$CLANG_EXEC -D__KERNEL__ -D__NR_CPUS__=$NR_CPUS "\
2124 "-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 " \
2326 "-Wno-unused-value -Wno-pointer-sign " \
2427 "-working-directory $WORKING_DIR " \
2528 "-c \"$CLANG_SOURCE\" -target bpf $CLANG_EMIT_LLVM -O2 -o - $LLVM_OPTIONS_PIPE"
....@@ -262,6 +265,8 @@
262265 return -ENOMEM;
263266 return 0;
264267 }
268
+ pr_debug("%s: Couldn't find \"%s\", missing kernel-devel package?.\n",
269
+ __func__, autoconf_path);
265270 free(autoconf_path);
266271 return -ENOENT;
267272 }
....@@ -285,6 +290,7 @@
285290 "obj-y := dummy.o\n"
286291 "\\$(obj)/%.o: \\$(src)/%.c\n"
287292 "\t@echo -n \"\\$(NOSTDINC_FLAGS) \\$(LINUXINCLUDE) \\$(EXTRA_CFLAGS)\"\n"
293
+"\t\\$(CC) -c -o \\$@ \\$<\n"
288294 "EOF\n"
289295 "touch $TMPDIR/dummy.c\n"
290296 "make -s -C $KBUILD_DIR M=$TMPDIR $KBUILD_OPTS dummy.o 2>/dev/null\n"
....@@ -352,8 +358,7 @@
352358 " \toption in [llvm] to \"\" to suppress this detection.\n\n",
353359 *kbuild_dir);
354360
355
- free(*kbuild_dir);
356
- *kbuild_dir = NULL;
361
+ zfree(kbuild_dir);
357362 goto errout;
358363 }
359364
....@@ -416,10 +421,9 @@
416421 goto out;
417422 }
418423
419
- pr_info("LLVM: dumping %s\n", obj_path);
424
+ pr_debug("LLVM: dumping %s\n", obj_path);
420425 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));
423427 fclose(fp);
424428 out:
425429 free(obj_path);