summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2014-04-02 21:49:26 +0200
committerMichal Marek <mmarek@suse.cz>2014-04-07 21:50:58 +0200
commit810361b9f65daa6144922ac88087a8426eeae817 (patch)
treeae2eae104550a28601e7d5265e458e3ee0db79b0 /Makefile
parent176ab02d4916f09d5d8cb63372d142df4378cdea (diff)
Kbuild, lto: Set TMPDIR for LTO v4
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@linux.intel.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 11 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index e5ac8a62e6e5..81dca6680f1e 100644
--- a/Makefile
+++ b/Makefile
@@ -407,6 +407,17 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
export KBUILD_ARFLAGS
+ifdef CONFIG_LTO
+# 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
+# instead.
+ifndef TMPDIR
+TMPDIR ?= $(objtree)
+export TMPDIR
+$(info setting TMPDIR=$(objtree) for LTO build)
+endif
+endif
+
# 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.