[linux-yocto] [PATCH 01/14] Kbuild, lto: Set TMPDIR for LTO v4
alejandro.hernandez at linux.intel.com
Mon Feb 13 12:41:14 PST 2017
From: Andi Kleen <ak at linux.intel.com>
LTO gcc puts a lot of data into $TMPDIR, essentially another copy
of the object directory to pass the repartitioned object files
to the code generation processes.
TMPDIR defaults to /tmp With /tmp as tmpfs it's easy to drive systems to
out of memory, because they will compete with the already high anonymous
memory consumption of the wpa LTO pass.
When LTO is set always set TMPDIR to the object directory. This could
be slightly slower, but is far safer and eliminates another parameter
the LTO user would need to set manually.
I made it conditional on LTO for now.
v2: Allow user to override (H. Peter Anvin)
v3: Use standard kernel variable style
v4: Print message for redirection (M.Marek)
Signed-off-by: Andi Kleen <ak at linux.intel.com>
Signed-off-by: Tom Zanussi <tom.zanussi at linux.intel.com>
Makefile | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/Makefile b/Makefile
index 3728746..c51cbcf 100644
@@ -422,6 +422,17 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
+# LTO gcc creates a lot of files in TMPDIR, and with /tmp as tmpfs
+# it's easy to drive the machine OOM. Use the object directory
+TMPDIR ?= $(objtree)
+$(info setting TMPDIR=$(objtree) for LTO build)
# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
# even be read-only.
More information about the linux-yocto