From patchwork Mon May 19 17:19:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 30394 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 95828202FE for ; Mon, 19 May 2014 17:19:46 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id oz11sf24629740veb.2 for ; Mon, 19 May 2014 10:19:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=bhXX7Dbr3/9LcMc4wOT8WTqG+Shl2QevRoNNSc3gP2o=; b=Bfa8hwROVaiCRTgWpxfnRwR1T1AAFkSw8z4M/BQ+Yfx48NqkJweHlS+snA5ZLN/qif nCBgs4o4XfuYgGfHicHkXDt+5ElVJFBA6jMzir2v6YEcdUqhCFFlV+HDh3fszzMyYphy cT5/QMmJemIATqoWU6PbYWQLztWEAc+d1rbUxXU1vpyfNKqK2ui6lJA0xzg3WBuVjIwl r9yDIMVkb9TTX4siPMvHUQr+HUTb78uztNZYEIoxcu3ut7IOpxsPaESy5uFN1II5xOGJ 0I2h2PP4cn8qweg5tjDS8c+dIS9aqmJg2cyzitxNN3WiyTRvu1Mcr+Ge7CqnSiiLqCa2 GTpw== X-Gm-Message-State: ALoCoQmm8OXBHB/MVF7rt8C2WuD64z03MQJ/5Y88yMvjB7JgND0Elt0/Z6eGmMUaScblTIEUMOJ9 X-Received: by 10.236.209.97 with SMTP id r61mr16256753yho.33.1400519986250; Mon, 19 May 2014 10:19:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.93.131 with SMTP id d3ls1890168qge.52.gmail; Mon, 19 May 2014 10:19:46 -0700 (PDT) X-Received: by 10.58.47.36 with SMTP id a4mr1259821ven.63.1400519986151; Mon, 19 May 2014 10:19:46 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id ti7si4106607veb.93.2014.05.19.10.19.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 May 2014 10:19:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id oz11so6840547veb.30 for ; Mon, 19 May 2014 10:19:46 -0700 (PDT) X-Received: by 10.58.186.207 with SMTP id fm15mr32663988vec.4.1400519985971; Mon, 19 May 2014 10:19:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp251130vcb; Mon, 19 May 2014 10:19:45 -0700 (PDT) X-Received: by 10.194.158.132 with SMTP id wu4mr3198029wjb.96.1400519984962; Mon, 19 May 2014 10:19:44 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id fx4si3766449wib.51.2014.05.19.10.19.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 19 May 2014 10:19:44 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WmRDy-0002Pt-Ux; Mon, 19 May 2014 18:19:42 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, qemu-trivial@nongnu.org, Paolo Bonzini , Eric Blake Subject: [PATCH] configure: Put tempfiles in a subdir of the build directory Date: Mon, 19 May 2014 18:19:42 +0100 Message-Id: <1400519982-9264-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.171 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , When libtool support was added to configure, the new temporary files were left out of the list of files cleaned up on exit; this results in a lot of stale .lo files being left around in /tmp. Worse, libtool creates a /tmp/.libs directory which we can't easily clean up. Put all our temporary files in a single temporary directory created as a subdirectory of the build directory, so we can easily clean it up, and don't need fragile or complicated code for creation to avoid it clashing with temporary directories from other instances of QEMU configure or being subject to attack from adversaries who can write to /tmp. Since the temporaries now live in the build tree, we have no need to jump through hoops with a trap handler to try to remove them when configure exits; this fixes some weird bugs where hitting ^C during a configure run wouldn't actually make it stop, because we would run the trap handler but then not stop. (It is possible to get the trap handler semantics right but it is convoluted largely because of bugs in dash, so it is simpler to just avoid it.) Note that "temporary files go in the build directory, not /tmp" is the way autoconf behaves. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake --- If we really wanted to run a cleanup handler then to cope with dash bugs I think this has to be: trap 'exit $?' INT QUIT TERM trap 'ret=$?; cleanup here; exit $?' EXIT (and even then this doesn't work if you run with -ex...) .gitignore | 1 + configure | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 8a52709..c658613 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /config-host.* /config-target.* /config.status +/config-temp /trace/generated-tracers.h /trace/generated-tracers.c /trace/generated-tracers-dtrace.h diff --git a/configure b/configure index 605a0ec..e06386a 100755 --- a/configure +++ b/configure @@ -2,26 +2,28 @@ # # qemu configure script (c) 2003 Fabrice Bellard # -# set temporary file name -if test ! -z "$TMPDIR" ; then - TMPDIR1="${TMPDIR}" -elif test ! -z "$TEMPDIR" ; then - TMPDIR1="${TEMPDIR}" -else - TMPDIR1="/tmp" + +# Temporary directory used for files created while +# configure runs. Since it is in the build directory +# we can safely blow away any previous version of it +# (and we need not jump through hoops to try to delete +# it when configure exits.) +TMPDIR1="config-temp" +rm -rf "${TMPDIR1}" +mkdir -p "${TMPDIR1}" +if [ $? -ne 0 ]; then + echo "ERROR: failed to create temporary directory" + exit 1 fi -TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c" -TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}" +TMPB="qemu-conf" +TMPC="${TMPDIR1}/${TMPB}.c" TMPO="${TMPDIR1}/${TMPB}.o" TMPCXX="${TMPDIR1}/${TMPB}.cxx" TMPL="${TMPDIR1}/${TMPB}.lo" TMPA="${TMPDIR1}/lib${TMPB}.la" -TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe" +TMPE="${TMPDIR1}/${TMPB}.exe" -# NB: do not call "exit" in the trap handler; this is buggy with some shells; -# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org> -trap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM rm -f config.log # Print a helpful header at the top of config.log