From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41128) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyzaX-0000vA-6o for qemu-devel@nongnu.org; Wed, 18 Nov 2015 05:03:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyzaT-0004Lm-JQ for qemu-devel@nongnu.org; Wed, 18 Nov 2015 05:03:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyzaT-0004Li-Bv for qemu-devel@nongnu.org; Wed, 18 Nov 2015 05:03:37 -0500 Date: Wed, 18 Nov 2015 10:03:32 +0000 From: "Daniel P. Berrange" Message-ID: <20151118100332.GA27591@redhat.com> References: <1447783185-32019-1-git-send-email-berrange@redhat.com> <564B7ACF.30701@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <564B7ACF.30701@redhat.com> Subject: Re: [Qemu-devel] [PATCH] configure: preserve various environment variables in config.status Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: Peter Maydell , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , Gerd Hoffmann On Tue, Nov 17, 2015 at 12:06:55PM -0700, Eric Blake wrote: > On 11/17/2015 10:59 AM, Daniel P. Berrange wrote: > > Suggested in > > > > https://lists.gnu.org/archive/html/qemu-devel/2015-11/msg03298.html > > > > The config.status script is auto-generated by configure upon > > completion. The intention is that config.status can be later > > invoked by the developer to re-detect the same environment > > that configure originally used. The current config.status > > script, however, only contains a record of the command line > > arguments to configure. Various environment variables have > > an effect on what configure will find. In particular the > > PKG_CONFIG_LIBDIR & PKG_CONFIG_PATH vars will affect what > > libraries pkg-config finds. The PATH var will affect what > > toolchain binaries and XXXX-config scripts are found. The > > LD_LIBRARY_PATH var will affect what libraries are found. > > All these key env variables should be recorded in the > > config.status script. > > > > Signed-off-by: Daniel P. Berrange > > --- > > > > Open question: are there more env vars we should preserve ? > > Yes - anything that autoconf would mark as precious. See below. > > > +++ b/configure > > @@ -5925,6 +5925,24 @@ cat <config.status > > # Compiler output produced by configure, useful for debugging > > # configure, is in config.log if it exists. > > EOD > > + > > +preserve_env() { > > + envname=$1 > > + > > + if test -n "${!envname}" > > Bashism, but configure is /bin/sh. This won't work on dash :( > > I think you'll have to use eval, and we'll just have to audit that > preserve_env can never be called with suspicious text where eval would > open a security hole. Ok, shouldn't be a big deal > > + then > > + echo "$envname=\"${!envname}\"" >> config.status > > Another use of the bashism. > > > + echo "export $envname" >> config.status > > + fi > > +} > > + > > +# Preserve various env variables that influence what > > +# features/build target configure will detect > > +preserve_env PATH > > +preserve_env LD_LIBRARY_PATH > > +preserve_env PKG_CONFIG_LIBDIR > > +preserve_env PKG_CONFIG_PATH > > + > > Autoconf preserves CC, CFLAGS, LDFLAGS, LIBS, CPPFLAGS, and CPP by > default. Also, PKG_CONFIG is typically preserved. If you run libvirt's > './configure --help', you'll also notice a bunch of *_CFLAGS and *_LIBS > in the precious list starting under the label "Some influential > environment variables". I'll add in env vars for all the commands like CC, CPP, MAKE, etc that QEMU's configure uses. I've tried preserving various *FLAGS vars but the problem here is that configure will modify/augment those variables while it is running, so when we get to preserve the original flags we only have the munged version. In any case recommendation is to use --extra-cflags rather than CFLAGS, so I figure its not a big deal to skip preserving CFLAGS/LDFLAGS Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|