Exporting environment variables

113 views
Skip to first unread message

Slawomir Czarko

unread,
Dec 21, 2011, 5:20:14 AM12/21/11
to tup-users
Hi,

Would it be possible for tup to check if the environment variable is
present before exporting it?

Currently when an environment variable is not present it gets exported
with empty value. Some tools don't like that (for example ccache and
CCACHE_PREFIX). I'd like the variable to be either not exported at all
in such a case or to have an option to mark the variable as only
exported when it's set.

- Slawomir

Elliott Hird

unread,
Dec 21, 2011, 10:47:19 AM12/21/11
to tup-...@googlegroups.com
On 21 December 2011 10:20, Slawomir Czarko <slawomi...@gmail.com> wrote:
> Currently when an environment variable is not present it gets exported
> with empty value.

Semi-relatedly: It might be nice to be able to specify a default value.

Mike Shal

unread,
Dec 23, 2011, 3:04:46 PM12/23/11
to tup-...@googlegroups.com

Yes, please try the latest master. It should only put a variable in
the sub-process's environment if it exists in the user's environment.
It still gets tracked either way if you export it from the Tupfile.

Thanks for the feedback,
-Mike

Mike Shal

unread,
Dec 23, 2011, 3:06:59 PM12/23/11
to tup-...@googlegroups.com

This is definitely a useful feature, but I think the shell already
takes care of that sort of thing. It doesn't make sense to me to
duplicate the shell's environment capabilities in tup. I view tup's
role here as only monitoring it for changes, and as a pass-through to
the sub-process. Let me know if there's something tup is preventing
with its current implementation.

-Mike

Mike Shal

unread,
Dec 23, 2011, 8:06:01 PM12/23/11
to tup-...@googlegroups.com
On Wed, Dec 21, 2011 at 5:20 AM, Slawomir Czarko
<slawomi...@gmail.com> wrote:

Also I meant to ask - what has been your experience with ccache + tup?
If you have any suggestions for others trying to use them together
maybe they could go on the Tips & Tricks page.

Thanks!
-Mike

Slawomir Czarko

unread,
Dec 28, 2011, 1:01:02 PM12/28/11
to tup-users
On Dec 24, 2:06 am, Mike Shal <mar...@gmail.com> wrote:> On Wed, Dec
21, 2011 at 5:20 AM, Slawomir Czarko> > <slawomir.cza...@gmail.com>
Hi,
In theory ccache shouldn't be needed when using tup since tup should
make sure that the compiler shouldn't run at all if sources haven't
been modified. But if you do full builds for some reason then it does
help since ccache will reduce full build times. I think once I finish
porting the build system from make to tup then full builds will stop
or at least become very rare.
When using ccache + tup you need to export CCACHE_BASEDIR before
running ccache. It should be set to the top level directory of your
source files. Without that ccache doesn't really work with tup since
the path to source is different each time tup runs so you end up
having cache misses all the time in ccache. You can verify whether
ccache+tup works correctly by running "ccache -s" before and after
build. If sources were not modified then you should see increase in
"cache hit" and no increase in "cache miss". CCACHE_BASEDIR can be
useful also when not using tup if you compile the same/similar sources
in different directories.
The drawbacks of using CCACHE_BASEDIR are:
       ·   If you specify an absolute path to the source code file,
__FILE__ macros will be expanded to a relative path instead.
       ·   If you specify an absolute path to the source code file and
compile with -g, the source code path stored in the object file may
point to the wrong directory, which may prevent debuggers like       
   GDB from finding the source code. Sometimes, a work-around is to
change the directory explicitly with the “cd” command in GDB.
The other two environment variables used with ccache are CCACHE_DIR
and CCACHE_PREFIX.
CCACHE_DIR must be exported if you have ccache files in a different
location than ~/.ccache. Without exporting it ccache will use the
default location when running with tup.
CCACHE_PREFIX must be exported if you are using any other compiler
wrapper like for example distcc. Without exporting it the other
compiler wrapper will not be used.
- Slawomir
Reply all
Reply to author
Forward
0 new messages