From 6dcfac476fdb8334fc682304e12a5db6f21b3a22 Mon Sep 17 00:00:00 2001 From: Mohammad Akhlaghi Date: Wed, 19 Feb 2020 03:38:51 +0000 Subject: Building of GCC now only done when /dev/shm has more than 10GB free Until now, like all software on GNU/Linux systems GCC would be built in RAM (to speed up the build slightly and also not put too much stress on the HDDs/SSDs). But some systems don't have enough RAM for building GCC and will complain and crash. With this commit, we have added a check on the amount of free space in the `build_tmp' directory (which will be `/dev/shm' on GNU/Linux systems). If the amount of free space isn't more than 10GB, then GCC won't be built there and a temporary directory will be built under the `$(BDIR)/software' directory for it. This bug was found by Zahra Sharbaf. This fixes bug #57853. --- reproduce/software/make/basic.mk | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'reproduce/software/make/basic.mk') diff --git a/reproduce/software/make/basic.mk b/reproduce/software/make/basic.mk index 4a290b6..212c738 100644 --- a/reproduce/software/make/basic.mk +++ b/reproduce/software/make/basic.mk @@ -1261,15 +1261,27 @@ $(ibidir)/gcc: | $(ibidir)/binutils \ ccinfo=$$(gcc --version | awk 'NR==1'); \ echo "C compiler (""$$ccinfo"")" > $@; \ else \ + current_dir=$$(pwd); \ rm -f $(ibdir)/gcc* $(ibdir)/g++ $(ibdir)/gfortran $(ibdir)/gcov*;\ rm -rf $(ildir)/gcc $(ildir)/libcc* $(ildir)/libgcc*; \ rm -rf $(ildir)/libgfortran* $(ildir)/libstdc* rm $(idir)/x86_64*;\ \ ln -fs $(ildir) $(idir)/lib64; \ - \ - cd $(ddir); \ + \ + in_ram=$$(df $(ddir) \ + | awk 'NR==2{print ($$4>10000000) ? "yes" : "no"}'); \ + if [ $$in_ram = "yes" ]; then odir=$(ddir); \ + else \ + odir=$(BDIR)/software/build-tmp-gcc; \ + if [ -d $$odir ]; then rm -rf $$odir; fi; \ + mkdir $$odir; \ + fi; \ + cd $$odir; \ rm -rf gcc-$(gcc-version); \ - tar xf $(word 1,$(filter $(tdir)/%,$|)) \ + tar xf $(word 1,$(filter $(tdir)/%,$|)); \ + if [ $$odir != $(ddir) ]; then \ + ln -s $$odir/gcc-$(gcc-version) $(ddir)/gcc-$(gcc-version); \ + fi \ && cd gcc-$(gcc-version) \ && mkdir build \ && cd build \ @@ -1296,7 +1308,7 @@ $(ibidir)/gcc: | $(ibidir)/binutils \ && make SHELL=$(ibdir)/bash -j$(numthreads) \ && make SHELL=$(ibdir)/bash install \ && cd ../.. \ - && tempname=$(ddir)/gcc-$(gcc-version)/build/rpath-temp-copy \ + && tempname=$$odir/gcc-$(gcc-version)/build/rpath-temp-copy \ && if [ "x$(on_mac_os)" != xyes ]; then \ patchelf --add-needed $(ildir)/libiconv.so $(ildir)/libstdc++.so; \ for f in $$(find $(idir)/libexec/gcc) $(ildir)/libstdc++*; do \ @@ -1309,6 +1321,11 @@ $(ibidir)/gcc: | $(ibidir)/binutils \ done; \ fi \ && rm -rf gcc-$(gcc-version) \ + && cd $$current_dir \ + && if [ "$$odir" != "$(ddir)" ]; then \ + rm -rf $$odir; \ + rm $(ddir)/gcc-$(gcc-version); \ + fi \ && ln -sf $(ibdir)/gcc $(ibdir)/cc \ && echo "GNU Compiler Collection (GCC) $(gcc-version)" > $@; \ fi -- cgit v1.2.1