--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -15,6 +15,7 @@
 #ifndef _UAPI_LINUX_PERF_EVENT_H
 #define _UAPI_LINUX_PERF_EVENT_H
 
+#include <linux/compiler.h>
 #include <linux/types.h>
 #include <linux/ioctl.h>
 #include <asm/byteorder.h>
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -33,6 +33,7 @@
 #include <sys/capability.h>
 #include <errno.h>
 #include <math.h>
+#include <limits.h>
 #include <linux/perf_event.h>
 #include <asm/unistd.h>
 #include <stdbool.h>
--- a/tools/bpf/bpf_jit_disasm.c
+++ b/tools/bpf/bpf_jit_disasm.c
@@ -306,7 +306,7 @@ int main(int argc, char **argv)
 		goto done;
 	}
 
-	ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, DEFFILEMODE);
+	ofd = open(ofile, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 	if (ofd < 0) {
 		fprintf(stderr, "Could not open file %s for writing: ", ofile);
 		perror(NULL);
--- a/tools/bpf/bpftool/btf_dumper.c
+++ b/tools/bpf/bpftool/btf_dumper.c
@@ -2,9 +2,15 @@
 /* Copyright (c) 2018 Facebook */
 
 #include <ctype.h>
+#include <stdbool.h>
 #include <stdio.h> /* for (FILE *) used by json_writer */
 #include <string.h>
 #include <unistd.h>
+
+#ifndef __always_inline
+#define __always_inline inline __attribute__((always_inline))
+#endif
+
 #include <asm/byteorder.h>
 #include <linux/bitops.h>
 #include <linux/btf.h>
--- a/tools/include/linux/err.h
+++ b/tools/include/linux/err.h
@@ -6,6 +6,11 @@
 #include <linux/types.h>
 
 #include <asm/errno.h>
+#include <stdbool.h>
+
+#ifndef __must_check
+#define __must_check __attribute__((warn_unused_result))
+#endif
 
 /*
  * Original kernel header comment:
